Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { sync.Mutex // ErrCh receives errors reported by the consumer. ErrCh <-chan *errors.Werr // contains filtered or unexported fields }
Controller is used to manage the messages reader.
func NewController ¶ added in v0.6.0
func NewController( errCh <-chan *errors.Werr, ) (*Controller, context.Context, chan<- struct{})
NewController creates a new controller.
errCh is exposed by the Controller so the errors (i.e. communication, message handler) can be handled asynchronously.
The function returns one buffered channel of size 1 which is used to acknowledge that operation (i.e. send back an empty struct as a confirmation). Besides that, the returned context must be injected in the reader or explicitly checking periodically if it has cancelled or not by using Context.Done.
When *Controller.Shutdown is called, the context is cancelled.
func (*Controller) Shutdown ¶
func (c *Controller) Shutdown()
Tells to close the events reader. This function blocks until the readed is closed. On future calls, the function does nothing.
type ErrorLimiter ¶ added in v0.6.0
type ErrorLimiter struct {
// contains filtered or unexported fields
}
Errorlimiter is responsable for slowing down the message reading process in cases when there's a continuous flux of communication errors with the event broker.
func NewLimiter ¶ added in v0.6.0
func NewLimiter(opt *ErrorLimiterOptions) *ErrorLimiter
NewLimiter returns a new messages reader limiter.
func (*ErrorLimiter) Slowdown ¶ added in v0.6.0
func (el *ErrorLimiter) Slowdown()
Slowdown applies a cooldown in the current goroutine if this func was called to many times.
type ErrorLimiterOptions ¶ added in v0.6.0
type ErrorLimiterOptions struct { // Rate represents the number of // errors received per second. Rate rate.Limit // Burst is the max received errors. Burst int // The ammount of time to wait // after receiving too much errors. Cooldown time.Duration }
ErrorLimiterOptions contains the parameters to configure the rate limiter.