Documentation
¶
Overview ¶
Package event implements event queue primitives to distribute events within the neural network.
Index ¶
Constants ¶
const ( // KindActivator represents the event service responsible for managing // activator events. KindActivator = "activator" // KindNetwork represents the event service responsible for managing // network events. KindNetwork = "network" // NamespaceDefault represents the default namespace in which signals can be // put that are not supposed to be queued in any custom namespace. NamespaceDefault = "default" // LabelWildcard represents a wildcard label which can be used to consume // events associated with all labels using Service.Search. LabelWildcard = "*" )
Variables ¶
This section is empty.
Functions ¶
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
func IsInvalidContext ¶
IsInvalidContext asserts invalidContextError.
func IsInvalidExecution ¶
IsInvalidExecution asserts invalidExecutionError.
Types ¶
type Backoff ¶
type Backoff interface {
// NextBackOff provides the duration expected to wait before retrying an
// action. time.Duration = -1 indicates that no more retry should be
// attempted.
NextBackOff() time.Duration
// Reset sets the backoff back to its initial state.
Reset()
}
Backoff represents the object managing backoff algorithms to retry actions.
type Collection ¶
type Collection struct {
Activator Service
Network Service
// contains filtered or unexported fields
}
Collection is the object bundling all services.
func NewCollection ¶
func NewCollection(config CollectionConfig) (*Collection, error)
NewCollection creates a new configured event Collection.
func (*Collection) Boot ¶
func (c *Collection) Boot()
func (*Collection) Shutdown ¶
func (c *Collection) Shutdown()
type CollectionConfig ¶
type CollectionConfig struct {
// Dependencies.
StorageCollection *storage.Collection
}
CollectionConfig represents the configuration used to create a new event collection.
func DefaultCollectionConfig ¶
func DefaultCollectionConfig() CollectionConfig
DefaultCollectionConfig provides a default configuration to create a new event collection by best effort.
type Config ¶
Config represents the configuration used to create a new event.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig provides a default configuration to create a new event by best effort.
type Event ¶
type Service ¶
type Service interface {
// Boot initializes and starts the whole service like booting a machine. The
// call to Boot blocks until the service is completely initialized, so you
// might want to call it in a separate goroutine.
Boot()
// Create publishes the given event and associates it with the given labels.
Create(ctx context.Context, event Event, labels ...string) error
// Delete removes the given event which is associated with the given labels.
//
// Delete does not unqueue events. That is why delete must be called on an
// event that was already consumed from a queue using Service.Search. In case
// Delete is called on an event that is still queued, upcoming tries to
// consume the deleted event will fail.
Delete(ctx context.Context, event Event, labels ...string) error
// ExistsAny checks whether there is any event queued associated within the
// given labels.
ExistsAny(ctx context.Context, labels ...string) (bool, error)
// Limit trims the number of events within a labeled queue by cutting off
// events from the queue's tail.
Limit(ctx context.Context, max int, labels ...string) error
// Search blocks until the next event associated with the given labels can be
// returned. Consuming any event regardless their labeling can be done by
// providing the wildcard label LabelWildcard.
Search(ctx context.Context, labels ...string) (Event, error)
// SearchAll returns all events associated with the given labels. While
// Service.Search blocks until one event is available and can be returned,
// Service.SearchAll returns all events at once and in case there is no single
// event available, a not found error is returned.
SearchAll(ctx context.Context, labels ...string) ([]Event, error)
// Shutdown ends all processes of the service like shutting down a machine.
// The call to Shutdown blocks until the service is completely shut down, so
// you might want to call it in a separate goroutine.
Shutdown()
// WriteAll overwrites all events associated with the provided labels with the
// given list of events, no matter if there have been events before or not.
WriteAll(ctx context.Context, events []Event, labels ...string) error
}
func NewService ¶
func NewService(config ServiceConfig) (Service, error)
NewService creates a new configured event service.
type ServiceConfig ¶
type ServiceConfig struct {
// Dependencies.
BackoffService func() Backoff
InstrumentorCollection *instrumentor.Collection
StorageCollection *storage.Collection
// Settings.
Kind string
}
ServiceConfig represents the configuration used to create a new event service.
func DefaultServiceConfig ¶
func DefaultServiceConfig() ServiceConfig
DefaultServiceConfig provides a default configuration to create a new event service by best effort.
type Signal ¶
func NewSignal ¶
func NewSignal(config SignalConfig) (Signal, error)
NewSignal creates a new configured signal event.
func NewSignalFromEvent ¶
func NewSignalFromSignals ¶
type SignalConfig ¶
type SignalConfig struct {
// Settings.
Arguments []reflect.Value
Context context.Context
Created time.Time
ID string
}
SignalConfig represents the configuration used to create a new signal event.
func DefaultSignalConfig ¶
func DefaultSignalConfig() SignalConfig
DefaultSignalConfig provides a default configuration to create a new signal event by best effort.