Documentation ¶
Index ¶
- Constants
- Variables
- func Errorf(shouldBan bool, format string, args ...interface{}) error
- func New(shouldBan bool, message string) error
- func Wrap(shouldBan bool, err error, message string) error
- func Wrapf(shouldBan bool, err error, format string, args ...interface{}) error
- type OnRouteCapacityReachedHandler
- type ProtocolError
- type Route
- type Router
- func (r *Router) AddIncomingRoute(name string, messageTypes []appmessage.MessageCommand) (*Route, error)
- func (r *Router) AddIncomingRouteWithCapacity(name string, capacity int, messageTypes []appmessage.MessageCommand) (*Route, error)
- func (r *Router) Close()
- func (r *Router) EnqueueIncomingMessage(message appmessage.Message) error
- func (r *Router) OutgoingRoute() *Route
- func (r *Router) RemoveRoute(messageTypes []appmessage.MessageCommand) error
Constants ¶
const (
// DefaultMaxMessages is the default capacity for a route with a capacity defined
DefaultMaxMessages = 200
)
Variables ¶
var ( // ErrTimeout signifies that one of the router functions had a timeout. ErrTimeout = New(false, "timeout expired") // ErrRouteClosed indicates that a route was closed while reading/writing. ErrRouteClosed = errors.New("route is closed") // ErrRouteCapacityReached indicates that route's capacity has been reached ErrRouteCapacityReached = New(false, "route capacity has been reached") )
Functions ¶
func Errorf ¶
Errorf formats according to a format specifier and returns the string as a ProtocolError.
func New ¶
New returns a ProtocolError with the supplied message. New also records the stack trace at the point it was called.
Types ¶
type OnRouteCapacityReachedHandler ¶
type OnRouteCapacityReachedHandler func()
OnRouteCapacityReachedHandler is a function that is to be called when one of the routes reaches capacity.
type ProtocolError ¶
func (ProtocolError) Error ¶
func (e ProtocolError) Error() string
func (ProtocolError) Unwrap ¶
func (e ProtocolError) Unwrap() error
Unwrap returns the cause of ProtocolError, to be used with `errors.Unwrap()`
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route represents an incoming or outgoing Router route
func (*Route) Dequeue ¶
func (r *Route) Dequeue() (appmessage.Message, error)
Dequeue dequeues a message from the Route
func (*Route) DequeueWithTimeout ¶
DequeueWithTimeout attempts to dequeue a message from the Route and returns an error if the given timeout expires first.
func (*Route) Enqueue ¶
func (r *Route) Enqueue(message appmessage.Message) error
Enqueue enqueues a message to the Route
func (*Route) MaybeEnqueue ¶
func (r *Route) MaybeEnqueue(message appmessage.Message) error
MaybeEnqueue enqueues a message to the route, but doesn't throw an error if it's closed or its capacity has been reached.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router routes messages by type to their respective input channels
func (*Router) AddIncomingRoute ¶
func (r *Router) AddIncomingRoute(name string, messageTypes []appmessage.MessageCommand) (*Route, error)
AddIncomingRoute registers the messages of types `messageTypes` to be routed to the given `route`
func (*Router) AddIncomingRouteWithCapacity ¶
func (r *Router) AddIncomingRouteWithCapacity(name string, capacity int, messageTypes []appmessage.MessageCommand) (*Route, error)
AddIncomingRouteWithCapacity registers the messages of types `messageTypes` to be routed to the given `route` with a capacity of `capacity`
func (*Router) Close ¶
func (r *Router) Close()
Close shuts down the router by closing all registered incoming routes and the outgoing route
func (*Router) EnqueueIncomingMessage ¶
func (r *Router) EnqueueIncomingMessage(message appmessage.Message) error
EnqueueIncomingMessage enqueues the given message to the appropriate route
func (*Router) OutgoingRoute ¶
OutgoingRoute returns the outgoing route
func (*Router) RemoveRoute ¶
func (r *Router) RemoveRoute(messageTypes []appmessage.MessageCommand) error
RemoveRoute unregisters the messages of types `messageTypes` from the router