Documentation
¶
Overview ¶
Package hybrid splits one workflow.Client across two backends: every schedule fires on a scheduler client (usually the in-process memory driver) while every run lives on a jobs client (a durable driver), the common "cron in the process, jobs in the database" shape.
A workflow registered here is registered on the jobs client without its schedule fields, and on the scheduler client as a one-step forwarder of the same name that enqueues the real job onto the jobs client with the fired run's labels (schedule ID, tick time) and an idempotency key made from the schedule and the tick, so a forwarder retried after a jobs outage does not start the job twice (on a jobs client with CapIdempotencyKey).
Each node of a cluster runs its own scheduler, so a schedule fires once per node: use it where that is wanted (one node runs schedules) or the idempotency key absorbs it (every node fires the same tick, the jobs client keeps one run while the first is unfinished). For a schedule that must fire once per cluster, schedule on the durable driver itself.
Index ¶
- type Client
- func (c *Client) Cancel(ctx context.Context, ref workflow.RunRef) error
- func (c *Client) Capabilities() workflow.Caps
- func (c *Client) Enqueue(ctx context.Context, job workflow.Job) (workflow.RunRef, error)
- func (c *Client) OnRunFinished(fn workflow.RunFinishedFunc) error
- func (c *Client) OnTick(workflow.TickObserver) error
- func (c *Client) PauseSchedule(ctx context.Context, t workflow.ScheduleTarget) error
- func (c *Client) Register(wf workflow.Workflow) error
- func (c *Client) ResumeSchedule(ctx context.Context, t workflow.ScheduleTarget) error
- func (c *Client) Schedule(ctx context.Context, s workflow.Schedule) (workflow.ScheduleID, error)
- func (c *Client) Schedules(ctx context.Context) ([]workflow.ScheduleInfo, error)
- func (c *Client) Signal(ctx context.Context, ev workflow.Event) error
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) Status(ctx context.Context, ref workflow.RunRef) (workflow.Status, error)
- func (c *Client) TriggerSchedule(context.Context, workflow.ScheduleID) (workflow.RunRef, error)
- func (c *Client) Unschedule(ctx context.Context, id workflow.ScheduleID) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
workflow.Forward // run-side optional interfaces go to the jobs client
// contains filtered or unexported fields
}
Client is a workflow.Client whose schedules fire on one backend and whose runs live on another. Build it with New.
func New ¶
New returns a client firing schedules on scheduler and running every job on jobs. Neither is started; Start starts both.
func (*Client) Capabilities ¶
Capabilities is the jobs client's, with the schedule family taken from the scheduler client (see scheduleCaps and notForwarded).
func (*Client) OnRunFinished ¶
func (c *Client) OnRunFinished(fn workflow.RunFinishedFunc) error
OnRunFinished observes the jobs client's run ends.
func (*Client) OnTick ¶
func (c *Client) OnTick(workflow.TickObserver) error
OnTick is refused: ticks would name forwarder runs.
func (*Client) PauseSchedule ¶
PauseSchedule pauses on the scheduler client.
func (*Client) Register ¶
Register registers wf on the jobs client without its schedule fields and, as a forwarder, on the scheduler client. A workflow asking for what this split cannot honour (CronOverlap, CronKeepRuns) is refused.
func (*Client) ResumeSchedule ¶
ResumeSchedule resumes on the scheduler client.
func (*Client) Schedule ¶
Schedule adds a schedule on the scheduler client; it refuses what the split cannot honour (Overlap, KeepRuns).
func (*Client) Start ¶
Start starts the jobs client, then the scheduler client; when the scheduler fails to start, the error names it (cancel ctx to stop the jobs client).
func (*Client) TriggerSchedule ¶
TriggerSchedule is refused: a trigger would return the forwarder's run, which the jobs client does not know.
func (*Client) Unschedule ¶
Unschedule removes a schedule from the scheduler client.