Documentation
¶
Overview ¶
Package scheduler runs durable one-off and daily local-time notifications. Storage and delivery are interfaces; the Firestore adapter lives in firestore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("schedule not found")
Functions ¶
Types ¶
type Daily ¶
type Daily struct {
LocalTime int `json:"localTime" firestore:"localTime"`
Timezone string `json:"timezone" firestore:"timezone"`
}
Daily uses HHMM and an IANA timezone. Nonexistent wall times are skipped; repeated wall times fire at the first occurrence only.
type Job ¶
type Job struct {
ID string `firestore:"id"`
RecipientID string `firestore:"recipientId"`
Daily *Daily `firestore:"daily,omitempty"`
Message push.Message `firestore:"message"`
State State `firestore:"state"`
Shard int `firestore:"shard"`
DueAt time.Time `firestore:"dueAt"`
AvailableAt time.Time `firestore:"availableAt"`
LeaseToken string `firestore:"leaseToken"`
Attempts int `firestore:"attempts"`
Completed []string `firestore:"completed"`
InvalidTargets []string `firestore:"invalidTargets"`
LastError string `firestore:"lastError"`
HasPermanentFailure bool `firestore:"hasPermanentFailure"`
UpdatedAt time.Time `firestore:"updatedAt"`
}
Job is adapter data, not a client-writeable API. AvailableAt is the indexed retry/lease deadline; DueAt remains stable for the current occurrence.
type Schedule ¶
type Store ¶
type Store interface {
Put(context.Context, Job) error
Get(context.Context, string, string) (Job, error)
Cancel(context.Context, string, string, time.Time) error
ClaimDue(context.Context, time.Time, int, int, time.Duration) ([]Job, error)
Finish(context.Context, Job, Job) error
}
Store must claim and finish with atomic compare-and-set semantics. A stale lease cannot finish, overwrite a replacement, or resurrect a canceled job.