action

package
v9.1.79+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	// Execute to invoke when a message is received. Return nil to not send a response or return an instance to send in response
	Execute(event datamodel.ModelReceiveEvent) (datamodel.ModelSendEvent, error)
}

Action defines a specific action interface for running an action in response to an event

func NewAction

func NewAction(callback ActionFunc) Action

NewAction is a convenient wrapper that implements the Action interface

type ActionFunc

type ActionFunc func(instance datamodel.ModelReceiveEvent) (datamodel.ModelSendEvent, error)

ActionFunc is a callback function for an action

type ActionSubscription

type ActionSubscription struct {
	// contains filtered or unexported fields
}

ActionSubscription is returned to control when the subscription should be closed

func Register

func Register(ctx context.Context, action Action, config Config) (*ActionSubscription, error)

Register an action and return a subscription. You must call Close on the response when you're done (or shutting down)

func (*ActionSubscription) Close

func (s *ActionSubscription) Close() error

Close should be called to stop receiving data from event server

func (*ActionSubscription) WaitForReady

func (s *ActionSubscription) WaitForReady()

WaitForReady will block until the subscription is ack

type Config

type Config struct {
	// Topic to use when subscribing TODO: Deprecate in favor of Topics
	Topic string
	// Factory is a model factory if you need to modify to use a different once
	Factory ModelFactory

	event.Subscription
}

Config for the action

type ModelFactory

type ModelFactory interface {
	New(name datamodel.ModelNameType) datamodel.Model
}

ModelFactory creates new instances of models

Jump to

Keyboard shortcuts

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