api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CoreID is the constant value returned by the CoreEvent.GetSourceIdentifier method. All emersyx components can use
	// this constant value to identify events generated by the emersyx core.
	CoreID = "emersyx_core"
	// CoreUpdate is the constant value used for the CoreEvent.Type field for events which notify of updates.
	CoreUpdate = "emersyx_core_update"
	// CoreError is the constant value used for the CoreEvent.Status field for events which notify of errors.
	CoreError = "emersyx_core_error"
	// PeripheralsLoaded is the constant value used for the CoreEvent.Status field for updates which notify that all
	// peripherals have been loaded and are available via the emersyx router.
	PeripheralsLoaded = "emersyx_core_peripherals_loaded"
	// RouterStarted is the constant value used for the CoreEvent.Status field for updates which notify that the emersyx
	// router has been started and is currently routing events from receptors and processors.
	RouterStarted = "emersyx_core_router_started"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core interface {
	// GetPeripheral must search for the Peripheral object loaded by the emersyx core. If such an instance is found,
	// then it must be returned.
	GetPeripheral(id string) (Peripheral, bool)
	// ForEachPeripheral must call the function provided as argument, sequentially with each peripheral currently
	// available to the core as argument.
	ForEachPeripheral(f func(Peripheral)) error
}

Core is the interface which must be implemented by the emersyx core component. This interface defines all the core services which can be performed for any emersyx component.

type CoreEvent

type CoreEvent struct {
	Type   string
	Status string
}

CoreEvent is the type which implements the Event interface and is used for events generated by the emersyx core. The Type and Status fields have predefined constant values from the core.go source file.

func NewCoreEvent

func NewCoreEvent(evType string, evStatus string) CoreEvent

NewCoreEvent is a utility function for creating CoreEvent instances with the specified type and status fields.

func (CoreEvent) GetSourceIdentifier

func (ev CoreEvent) GetSourceIdentifier() string

GetSourceIdentifier returns the constant value CoreID.

type Event

type Event interface {
	// GetSourceIdentifier must return the identifier of the emersyx peripheral which generated the event.
	GetSourceIdentifier() string
}

Event is the interface for all events supported by the various emersyx components. The emersyx event router uses this type to support multiple event types.

type Peripheral

type Peripheral interface {
	// GetIdentifier must return the identifier of the peripheral.
	GetIdentifier() string
}

Peripheral is a low-level interface (w.r.t. hierarchy of types in the emersyx framework) for all components which have to be uniquely identifiable. This includes gateways and processors, regardless of their implementation of the Receptor interface.

func NewPeripheral

func NewPeripheral(opts PeripheralOptions, path string) (Peripheral, error)

NewPeripheral is a utility wrapper function. It opens a go plugin from the specified path and looks up the function with the same name. On success, it calls the exported function with the the options given as argument, and returns the same values as returned by the exported function. On failure, it returns an error.

type PeripheralBase

type PeripheralBase struct {
	Identifier string
	Core       Core
	Log        *log.EmersyxLogger
}

PeripheralBase is the base type on which Peripheral type should be build. It is not mandatory for a Peripheral type to embed the PeripheralBase, from the point of view of the emersyx platform. However it can be embedded to provide some of the basic functionality out of the box.

func (*PeripheralBase) InitializeBase

func (pb *PeripheralBase) InitializeBase(opts PeripheralOptions) error

InitializeBase performs basic validation and initializtion of a PeripheralBase object.

type PeripheralOptions

type PeripheralOptions struct {
	// Identifier is the unique ID string for the Peripheral instance.
	Identifier string
	// Core is the emersyx core instance which provides services to the Peripheral instance.
	Core Core
	// LogWriter is the io.Writer instance where logging messages are written to.
	LogWriter io.Writer
	// LogLevel is the verbosity level for logging messages.
	LogLevel uint
	// ConfigPath is the path to the configuration file from which the peripheral instance loads additional options.
	ConfigPath string
}

PeripheralOptions specifies the options common to all Peripherals. Instances of this type are to be used when creating new peripherals, using the NewPeripheral function.

type Processor

type Processor interface {
	// GetEventsInChannel must return the channel via which the Processor implementation receives Event objects. The
	// channel is write-only and can not be read from.
	GetEventsInChannel() chan<- Event
}

Processor is the interface for all event processors part of the emersyx platform. Each processor component must expose a channel via which events are received for processing. An emersyx component may implement the Processor interface (next to the Peripheral interface) if the component is meant to process events received via Receptors.

type Receptor

type Receptor interface {
	// GetEventsOutChannel must return the channel via which the Receptor implementation pushes Event objects. The
	// channel is read-only and can not be written to.
	GetEventsOutChannel() <-chan Event
}

Receptor is the interface for all event receptors part of the emersyx platform. Each receptor component must expose a channel via which events are pushed. An emersyx component may implement the Receptor interface (next to the Peripheral interface) if the component can capture events.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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