Documentation
¶
Overview ¶
Package schema has the heartbeats' schedules, and what they are: a prompt for a session, at a time, or on a schedule
Index ¶
Constants ¶
const HeartbeatListMax uint64 = 100
HeartbeatListMax is the most heartbeats which are listed at once
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FireEvent ¶ added in v1.0.1
type FireEvent struct {
Heartbeat uuid.UUID `json:"heartbeat" help:"Identifier of the heartbeat"`
Title string `json:"title" help:"What it's for"`
Prompt string `json:"prompt" help:"The instruction for the model"`
Session uuid.UUID `json:"session" help:"Session which the prompt is for"`
Scheduled time.Time `json:"scheduled" help:"When it was due"`
Fired time.Time `json:"fired" help:"When it fired"`
}
FireEvent is a heartbeat which fired, which is run: what it is, when it was due, and when it fired, which is later, such as when the server wasn't running, so what runs it can say it's late, or not run it
type Heartbeat ¶
type Heartbeat struct {
ID uuid.UUID `json:"id" readonly:"" help:"Identifier of the heartbeat"`
HeartbeatMeta
Created time.Time `json:"created,omitzero" readonly:"" help:"When it was created"`
Modified time.Time `json:"modified,omitzero" readonly:"" help:"When it was last changed"`
Fired *time.Time `json:"fired,omitempty" readonly:"" help:"When it last fired"`
Next *time.Time `json:"next,omitempty" readonly:"" help:"When it fires next, or none, when it won't, as it fired once"`
}
Heartbeat is a heartbeat, its identifier, when it was created and last changed, when it last fired, and when it fires next, when it does
type HeartbeatList ¶
type HeartbeatList struct {
HeartbeatListRequest
Count uint `json:"count" help:"How many heartbeats there are"`
Body []Heartbeat `json:"body,omitzero" help:"The heartbeats"`
}
HeartbeatList is the heartbeats which are listed, which fire soonest first, and those which won't fire again last, and how many there are
func (HeartbeatList) String ¶ added in v1.0.1
func (l HeartbeatList) String() string
type HeartbeatListRequest ¶
type HeartbeatListRequest struct {
Session string `json:"session,omitempty" help:"Identifier of the session whose heartbeats are listed, or every heartbeat" optional:""`
Offset uint64 `json:"offset,omitempty" help:"How many heartbeats to skip" optional:""`
Limit *uint64 `json:"limit,omitempty" help:"Most heartbeats to return" optional:""`
}
HeartbeatListRequest is which heartbeats are listed: those for the session, when there is one, from the offset, and at most the limit of them
func (HeartbeatListRequest) Page ¶ added in v1.0.1
func (r HeartbeatListRequest) Page(heartbeats []Heartbeat) HeartbeatList
Page returns the heartbeats of the request's page, from its offset, and at most its limit, or HeartbeatListMax, of them, and how many there are
func (HeartbeatListRequest) Query ¶ added in v1.0.1
func (r HeartbeatListRequest) Query() url.Values
Query returns the request as URL query values
func (HeartbeatListRequest) String ¶ added in v1.0.1
func (r HeartbeatListRequest) String() string
type HeartbeatMeta ¶
type HeartbeatMeta struct {
Title string `json:"title" help:"What it's for, in a few words" example:"Morning briefing"`
Prompt string `` /* 218-byte string literal not displayed */
Session uuid.UUID `json:"session" help:"Session which the prompt is for"`
Schedule string `` /* 192-byte string literal not displayed */
At *time.Time `json:"at,omitempty" help:"When it fires, once, with its offset, such as 2026-11-06T15:00:00+01:00" optional:""`
Timezone string `` /* 177-byte string literal not displayed */
}
HeartbeatMeta is a prompt for a session, which fires once, at a time, or on a schedule, in a time zone, or the person's, when it has none, so it follows them, as their time zone changes
func (HeartbeatMeta) Validate ¶ added in v1.0.1
func (m HeartbeatMeta) Validate() (HeartbeatMeta, error)
Validate returns the heartbeat, with its title and prompt trimmed, and its time in UTC, or ErrBadParameter when it has no title, or a title of more than one line, no prompt, or session, neither a schedule nor a time, or both, or a time zone which isn't known, or a time zone with a time, which has its offset
func (HeartbeatMeta) When ¶ added in v1.0.1
func (m HeartbeatMeta) When() string
When returns when the heartbeat fires: its schedule, and its time zone, when it has one, or its time
type HeartbeatRequest ¶ added in v1.0.1
type HeartbeatRequest struct {
Title *string `json:"title,omitempty" help:"What it's for, in a few words" optional:""`
Prompt *string `json:"prompt,omitempty" help:"The instruction for the model, when it fires" optional:""`
Schedule *string `json:"schedule,omitempty" help:"When it fires, again and again, as a cron expression, which replaces its time" optional:""`
At *time.Time `json:"at,omitempty" help:"When it fires, once, which replaces its schedule" optional:""`
Timezone *string `json:"timezone,omitempty" help:"Time zone of its schedule, or empty, for the person's" optional:""`
}
HeartbeatRequest is a change to a heartbeat: what's set is changed, and a schedule replaces a time, and a time a schedule, and an empty time zone follows the person's
func (HeartbeatRequest) Apply ¶ added in v1.0.1
func (r HeartbeatRequest) Apply(m HeartbeatMeta) HeartbeatMeta
Apply returns the heartbeat, with the changes of the request
type TimeSpec ¶
type TimeSpec struct {
Minute []int // 0-59
Hour []int // 0-23
Day []int // 1-31
Month []int // 1-12
Weekday []int // 0-6, from Sunday
}
TimeSpec is a recurring schedule, as a cron expression of five fields, "minute hour day month weekday", such as "0 9 * * 1-5" for nine in the morning on weekdays. Each field is the values it matches, or any value, when it's empty. It has no time zone: it's the time on a clock, which Next finds in a time zone.
func ParseTimeSpec ¶ added in v1.0.1
ParseTimeSpec returns the schedule of the cron expression, whose fields are each "*", for any value, a value, a range, such as "1-5", a step, such as "*/15" or "0-30/10", or a list of those, such as "0,30". A weekday of 7 is Sunday, as 0 is. Returns ErrBadParameter when it isn't valid, or never matches, such as the 31st of February.
func (TimeSpec) MarshalJSON ¶
MarshalJSON returns the schedule as a cron expression
func (TimeSpec) Next ¶
Next returns the first time which matches the schedule, on a clock in the time zone, at or after the time, to the minute, or the zero time, when none does within five years. When the clocks change, a time which is skipped, as they go forward, happens once, when it would have, on the clock as it was, which is after they change, such as 02:30 as 03:30, and a time which is repeated, as they go back, happens once, the first time. The repeated hour is a time like any other, so a schedule of every fifteen minutes happens in it once.
func (*TimeSpec) UnmarshalJSON ¶
UnmarshalJSON parses the schedule from a cron expression