Documentation ¶
Index ¶
Constants ¶
const (
DefaultMsgBufSize = 1024 * 1024 // 1 MB
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FactoryModule ¶
type FactoryModule struct {
// contains filtered or unexported fields
}
FactoryModule provides the basic functionality of "submodules". It can be used to dynamically create and garbage-collect passive modules, and it automatically forwards events to them. See: protos/factorypb/factorypb.proto for details on the interface of the factory module itself.
The forwarding mechanism is as follows:
- All events destined for an existing submodule are forwarded to it automatically regardless of the event type.
- Incoming network messages destined for non-existent submodules are buffered within a limit. Once the limit is exceeded, the oldest messages are discarded. If a single message is too large to fit into the buffer, it is discarded.
- Other events destined for non-existent submodules are ignored.
func New ¶
func New(id t.ModuleID, params ModuleParams, logger logging.Logger) *FactoryModule
New creates a new factory module.
func (*FactoryModule) ApplyEvents ¶
func (*FactoryModule) ImplementsModule ¶
func (fm *FactoryModule) ImplementsModule()
type ModuleGenerator ¶
type ModuleGenerator func(id t.ModuleID, params *factorypbtypes.GeneratorParams) (modules.PassiveModule, error)
ModuleGenerator is a function that generates a passive module from a module ID and the parameters. The parameters format is defined in .proto files (see file: protos/factorypb/factorypb.proto).
type ModuleParams ¶
type ModuleParams struct { Generator ModuleGenerator MsgBufSize int }
ModuleParams contains the parameters for creating a factory module.
func DefaultParams ¶
func DefaultParams(generator ModuleGenerator) ModuleParams
DefaultParams creates a valid ModuleParams with default values.