Documentation
¶
Overview ¶
Package ctxrl implements context-based rate limiting. It is intended to be used on TMI for rate limiting messages to channels in slow mode. It implements a message queue in order to integrate with a blocking rate limiter that ensures a global maximum rate.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextMessage ¶
A ContextMessage describes a message to-be-enqueued.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
A Limiter rate-limits messages to a context, such as a Twitch channel.
func (*Limiter) Output ¶
Output should be used as a background routine that writes message according to the rate limit of each context.
func (*Limiter) Pending ¶
Pending returns the number of outstanding (to be sent) messages for the given context.
func (*Limiter) Send ¶
func (b *Limiter) Send(msg ContextMessage, ival time.Duration) int
Send schedules a message to be sent in a context. It is up to the caller to limit the total number of messages that can be queued.
A negative `ival` means it is not known, in which case the previous interval will be assumed to be correct.
type Publisher ¶
type Publisher interface {
Publish()
}
A Publisher pushes the output to the desired connection behind the scenes. The call should block until it is reasonably certain the message will be sent as soon as possible, to avoid conflicting with the rate limiting.