Documentation ¶
Index ¶
- Constants
- func Path(namespace, subscription string) string
- type Event
- type EventType
- type Pool
- type Ring
- func (r *Ring) Add(ctx context.Context, value string, keepalive int64) (rerr error)
- func (r *Ring) IsEmpty(ctx context.Context) (bool, error)
- func (r *Ring) Remove(ctx context.Context, value string) error
- func (r *Ring) Watch(ctx context.Context, name string, values, interval int, cron string) <-chan Event
Constants ¶
const MinInterval = 5
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct { // Type is the type of the event. Type EventType // Values are the ring items associated with the event. For trigger events, // the length of Values will be equal to the results per interval. Values []string // Err is any error that occurred while processing the event. Err error }
Event represents an event that occurred in a ring. The event can originate from any ring client.
type EventType ¶
type EventType int
EventType is an enum that describes the type of event received by watchers.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a pool of rings. It exists to help users avoid creating too many watchers.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
func (*Ring) Add ¶
Add adds a new value to the ring. If the value already exists, its keepalive will be reset. Values that are not kept alive will expire and be removed from the ring.
func (*Ring) Remove ¶
Remove removes a value from the list. If the value does not exist, nothing happens.
func (*Ring) Watch ¶
func (r *Ring) Watch(ctx context.Context, name string, values, interval int, cron string) <-chan Event
Watch watches the ring for events. The events are sent on the channel that is returned. For each interval duration in seconds, one or more values will be delivered, if there are any values in the ring.
If the underlying etcd watcher fails, then the Event will contain a non-nil error.
If the context is canceled, EventClosing will be sent on the channel, and it will be closed.
The name parameter specifies the name of the watch. Watchers should use unique names when requesting different numbers of values.
The interval parameter sets the interval at which ring items will be delivered, in seconds.
If the cron parameter is not the empty string, the interval parameter will be ignored, and the watcher will deliver values according to the cron schedule.
The values parameter controls how many ring values the event will contain. If the requested number of values is greater than the number of items in the values will contain repetitions in order to satisfy the request.