Documentation ¶
Index ¶
- type CreateReminderRequest
- type CreateTimerRequest
- type Reminder
- func (r Reminder) ActorKey() string
- func (r Reminder) HasRepeats() bool
- func (r Reminder) Key() string
- func (r *Reminder) MarshalBSON() ([]byte, error)
- func (r *Reminder) MarshalJSON() ([]byte, error)
- func (r Reminder) NextTick() time.Time
- func (r Reminder) RepeatsLeft() int
- func (r Reminder) String() string
- func (r *Reminder) TickExecuted() (done bool)
- func (r *Reminder) UnmarshalJSON(data []byte) error
- func (r *Reminder) UpdateFromTrack(track *ReminderTrack)
- type ReminderPeriod
- type ReminderTrack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateReminderRequest ¶
type CreateReminderRequest struct { Name string ActorType string ActorID string Data json.RawMessage `json:"data"` DueTime string `json:"dueTime"` Period string `json:"period"` TTL string `json:"ttl"` }
CreateReminderRequest is the request object to create a new reminder.
type CreateTimerRequest ¶
type CreateTimerRequest struct { Name string ActorType string ActorID string DueTime string `json:"dueTime"` Period string `json:"period"` TTL string `json:"ttl"` Callback string `json:"callback"` Data json.RawMessage `json:"data"` }
CreateTimerRequest is the request object to create a new timer.
type Reminder ¶
type Reminder struct { ActorID string `json:"actorID,omitempty"` ActorType string `json:"actorType,omitempty"` Name string `json:"name,omitempty"` Data json.RawMessage `json:"data,omitempty"` Period ReminderPeriod `json:"period,omitempty"` RegisteredTime time.Time `json:"registeredTime,omitempty"` DueTime string `json:"dueTime,omitempty"` // Exact input value from user ExpirationTime time.Time `json:"expirationTime,omitempty"` Callback string `json:"callback,omitempty"` // Used by timers only }
Reminder represents a reminder or timer for a unique actor.
func NewReminderFromCreateReminderRequest ¶
func NewReminderFromCreateReminderRequest(req *CreateReminderRequest, now time.Time) (reminder *Reminder, err error)
NewReminderFromCreateReminderRequest returns a new Reminder from a CreateReminderRequest object.
func NewReminderFromCreateTimerRequest ¶
func NewReminderFromCreateTimerRequest(req *CreateTimerRequest, now time.Time) (reminder *Reminder, err error)
NewReminderFromCreateTimerRequest returns a new Timer from a CreateTimerRequest object.
func (Reminder) HasRepeats ¶
HasRepeats returns true if the reminder has repeats left.
func (*Reminder) MarshalBSON ¶ added in v1.10.8
MarshalBSON implements bson.Marshaler. It encodes the message into a map[string]any before calling bson.Marshal.
func (*Reminder) MarshalJSON ¶
func (Reminder) RepeatsLeft ¶
RepeatsLeft returns the number of repeats left.
func (*Reminder) TickExecuted ¶
TickExecuted should be called after a reminder has been executed. "done" will be true if the reminder is done, i.e. no more executions should happen. If the reminder is not done, call "NextTick" to get the time it should tick next. Note: this method is not concurrency-safe.
func (*Reminder) UnmarshalJSON ¶
func (*Reminder) UpdateFromTrack ¶
func (r *Reminder) UpdateFromTrack(track *ReminderTrack)
UpdateFromTrack updates the reminder with data from the track object.
type ReminderPeriod ¶
type ReminderPeriod struct {
// contains filtered or unexported fields
}
ReminderPeriod contains the parsed period for a reminder.
func NewEmptyReminderPeriod ¶
func NewEmptyReminderPeriod() ReminderPeriod
NewEmptyReminderPeriod returns an empty ReminderPeriod, which has unlimited repeats.
func NewReminderPeriod ¶
func NewReminderPeriod(val string) (p ReminderPeriod, err error)
NewReminderPeriod parses a reminder period from a string and validates it.
func (ReminderPeriod) GetFollowing ¶
func (p ReminderPeriod) GetFollowing(t time.Time) time.Time
GetNext returns the next time the periodic reminder should fire after a given time.
func (ReminderPeriod) HasRepeats ¶
func (p ReminderPeriod) HasRepeats() bool
HasRepeats returns true if the period will repeat.
func (ReminderPeriod) MarshalJSON ¶
func (p ReminderPeriod) MarshalJSON() ([]byte, error)
func (ReminderPeriod) String ¶
func (p ReminderPeriod) String() string
String implements fmt.Stringer. It returns the value.
func (*ReminderPeriod) UnmarshalJSON ¶
func (p *ReminderPeriod) UnmarshalJSON(data []byte) error
type ReminderTrack ¶
type ReminderTrack struct { LastFiredTime time.Time `json:"lastFiredTime"` RepetitionLeft int `json:"repetitionLeft"` Etag *string `json:",omitempty"` }
ReminderTrack is a persisted object that keeps track of the last time a reminder fired.
func (*ReminderTrack) MarshalJSON ¶
func (r *ReminderTrack) MarshalJSON() ([]byte, error)
func (*ReminderTrack) UnmarshalJSON ¶
func (r *ReminderTrack) UnmarshalJSON(data []byte) error