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.
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 ¶
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