Documentation ¶
Index ¶
- Constants
- Variables
- type OnRouteCapacityReachedHandler
- 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 = protocolerrors.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 = protocolerrors.New(false, "route capacity has been reached") )
Functions ¶
This section is empty.
Types ¶
type OnRouteCapacityReachedHandler ¶
type OnRouteCapacityReachedHandler func()
OnRouteCapacityReachedHandler is a function that is to be called when one of the routes reaches capacity.
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 ¶ added in v0.12.1
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 ¶ added in v0.9.2
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