factorymodule

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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:

  1. All events destined for an existing submodule are forwarded to it automatically regardless of the event type.
  2. 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.
  3. 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 (fm *FactoryModule) ApplyEvents(evts *events.EventList) (*events.EventList, error)

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.

Jump to

Keyboard shortcuts

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