action

package
v9.1.76+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 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 {
	// GroupID is the consumer group id
	GroupID string
	// Channel to use when subscribing
	Channel string
	// APIKey to use when subscribing
	APIKey string
	// Headers to use when subscribing
	Headers map[string]string
	// HTTPHeaders to use when subscribing
	HTTPHeaders map[string]string
	// Topics to use when subscribing more than one topic
	Topics []string
	// Topic to use when subscribing
	Topic string
	// Errors is a channel for writing any errors during processing
	Errors chan<- error
	// Factory is a model factory if you need to modify to use a different once
	Factory ModelFactory
	// Offset controls where to start reading from. if not provided, will be from the latest
	Offset string
	// set the logger to use
	Logger log.Logger
	// Temporary if the subscription is temporary and if true, will not receive events if not connected
	Temporary bool
	// Filter are the subscription filters for more advanced filtering of subscription results
	Filter *event.SubscriptionFilter
}

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