reminders

package
v1.11.0-rc.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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) ActorKey

func (r Reminder) ActorKey() string

ActorKey returns the key of the actor for this reminder.

func (Reminder) HasRepeats

func (r Reminder) HasRepeats() bool

HasRepeats returns true if the reminder has repeats left.

func (Reminder) Key

func (r Reminder) Key() string

Key returns the key for this unique reminder.

func (*Reminder) MarshalJSON

func (r *Reminder) MarshalJSON() ([]byte, error)

func (Reminder) NextTick

func (r Reminder) NextTick() time.Time

NextTick returns the time the reminder should tick again next.

func (Reminder) RepeatsLeft

func (r Reminder) RepeatsLeft() int

RepeatsLeft returns the number of repeats left.

func (Reminder) String

func (r Reminder) String() string

String implements fmt.Stringer and is used for debugging.

func (*Reminder) TickExecuted

func (r *Reminder) TickExecuted() (done bool)

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 (r *Reminder) UnmarshalJSON(data []byte) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL