Documentation ¶
Overview ¶
Package alarm defines the Alarm type that resend events at given times.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFakeAlarm ¶
func NewFakeAlarm(chanSize int, opts ...Option) (Alarm, FakeAlarmController)
NewFakeAlarm creates a fake alarm replacement that resent one event each time FakeAlarmController.Tick() is called.
Types ¶
type Alarm ¶
Alarm resends events at the requested time, or later. Closing the Send channel asks the alarm to terminate, which is notified by closing Receive.
type Event ¶
type Event struct { // Time indicates when the Event must be resent by Alarms. Time time.Time // Data is untouched by Alarm. Data interface{} // Remaining is set by Alarm to the number of remaining waiting events, when the event is resent. Remaining int }
Events is the structure that is sent to and received from Alarm.
type FakeAlarmController ¶
type FakeAlarmController interface { // Tick asks the fake alarm to send its most recent event. Tick() Close() QueueLength() int }
FakeAlarmController allows to control a fake alarm returned by NewFakeAlarm.
type Option ¶
type Option func(evt *alarmLogic)
Option is the type of options given as optional arguments to New.
var ( // DiscardLaterEvent is an Option to ignore Events received by Alarm with Time greater than any // waiting event. DiscardLaterEvent Option = func(evt *alarmLogic) { evt.discardLaterEvent = true } // DiscardDuplicates is an Option to ignore Events received with tsame Data as any waiting event. DiscardDuplicates Option = func(evt *alarmLogic) { evt.discardDuplicates = true } // DiscardLateDuplicates is an Option to ignore Events received with same Data and later Time than // some waiting event. DiscardLateDuplicates Option = func(evt *alarmLogic) { evt.discardLateDuplicates = true } )
Click to show internal directories.
Click to hide internal directories.