subsystems

package
v0.0.0-...-841f565 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func(wg *sync.WaitGroup, ctx context.Context) func() error

Factory a produces a function that can start a process The callback is responsible for calling wg.Done() to complete process registration

func Reactor

func Reactor(topic cqrs.RouteKey, broker cqrs.Broker, logger logz.FieldLogger, onMessage cqrs.OnMessageFunc, onError cqrs.OnMessageErrorFunc, ackDeadline *time.Duration) Factory

Reactor subscribes using the given topic and processes messages using the provided handlers

type Manager

type Manager struct {
	StartTimeout       time.Duration
	DisabledSubsystems sync.Map
	// contains filtered or unexported fields
}

Manager handles the registration and lifecycle of Process

func NewManager

func NewManager(ctx context.Context) *Manager

NewManager creates a new Manager instance StartTimeout defaults to 10 seconds

func (*Manager) Register

func (m *Manager) Register(subsystems ...*Process) error

Register store a Process on the Manager An error is returned if a process with that name already exists

func (*Manager) Start

func (m *Manager) Start() error

Start uses all registered subsystem factories to create subsystems and kicks them off in their own go routines This method blocks until all subsystems have successfully started by synchronizing on a wait group

func (*Manager) Wait

func (m *Manager) Wait() error

Wait blocks until all subsystem go routines have exited or until one returns an error

type Process

type Process struct {
	Name    string
	Factory Factory
}

Process a unit that can be started and managed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL