hndlrs

package
v0.0.0-...-c4da03f Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FnHandler

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

FnHandler implements the Handler interface for any provided function that has the HandleFn signature.

func (FnHandler) Handle

func (h FnHandler) Handle(event Event) APIResp

Handle implements the Handler interface for FnHandler

type HandleFn

type HandleFn func(Event) APIResp

HandleFn is a type alias for the Handler.Handle() function signature. It is a function which takes an Event as its only argument. And returns an APIResp.

type Handler

type Handler interface {
	// Handle will be called once for each event received. The received event
	// will be passed as the `event` argument. An APIResp should be returned, to
	// be sent as a response to the client who sent the event.
	Handle(event Event) APIResp
}

Handler is used to process received events.

func NewHandler

func NewHandler(hndlFn HandleFn) Handler

NewHandler creates a new Handler, given any function of type HandleFn

type Invoker

type Invoker interface {
	// Invoke runs the action specified by the `event` argument.
	//
	// `ctx` can be cancelled to stop execution of a handler.
	//
	// It returns a channel which will receive exactly one error before
	// closing, to signify Invoke's completion. Nil on success.
	Invoke(ctx context.Context, event Event) <-chan error
}

Invoker wraps the Invoke method. Which runs the appropriate resource action handler for the provided event.

type Loader

type Loader interface {
	// Load should register any required Handlers with the Registry provided in
	// the `r` argument. An error should be returned if one occurs, otherwise
	// `nil`.
	Load(r Registry) error
}

Loader provides an interface for registering a group of handlers in a Registry.

type Registry

type Registry interface {
	// Register adds the Handler provided in the `hndlr` argument to the central
	// registry under the provided Target. The specifics of this registry
	// are left up to the implementation.
	Register(t Target, hndlr Handler) error

	// WithTarget returns the Handler which is registered under the Target
	// provided by the `t` argument. An error is returned if the one occurs,
	// otherwise nil will be returned.
	WithTarget(t Target) (Handler, error)
}

Registry provides an interface to add and query event action handlers

Directories

Path Synopsis
Package actions is a package which holds the Creator, Getter, Updater, and Deleter interfaces.
Package actions is a package which holds the Creator, Getter, Updater, and Deleter interfaces.

Jump to

Keyboard shortcuts

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