Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitSimpleLifecycle ¶
func InitSimpleLifecycle[T Module](m T, optShutdown ...func(T)) T
InitSimpleLifecycle is a helper function that sets up the default lifecycle for the given module. If no shutdown function is provided, then the default shutdown function will be used, which automatically triggers the StoppedEvent.
Note: If a more complex lifecycle is required, then it needs to be implemented manually.
func TriggerAll ¶
TriggerAll triggers the given event on all given modules.
Types ¶
type Module ¶
type Module interface { // ConstructedEvent is the getter for an Event that is triggered when the Module was constructed. ConstructedEvent() reactive.Event // InitializedEvent is the getter for an Event that is triggered when the Module was initialized. InitializedEvent() reactive.Event // ShutdownEvent is the getter for an Event that is triggered when the Module begins its shutdown process. ShutdownEvent() reactive.Event // StoppedEvent is the getter for an Event that is triggered when the Module finishes its shutdown process. StoppedEvent() reactive.Event // NewSubModule creates a new reactive submodule with the given name. NewSubModule(name string) Module // Logger is the logger of the Module. log.Logger }
Module is a trait that exposes logging and lifecycle related API capabilities, that can be used to create a modular architecture where different modules can listen and wait for each other to reach certain states.
func NewTestModule ¶
NewTestModule creates a new pre-configured Module for testing purposes.