hybrid

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

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

func New(scheduler, jobs workflow.Client) *Client

New returns a client firing schedules on scheduler and running every job on jobs. Neither is started; Start starts both.

func (*Client) Cancel

func (c *Client) Cancel(ctx context.Context, ref workflow.RunRef) error

Cancel cancels a run on the jobs client.

func (*Client) Capabilities

func (c *Client) Capabilities() workflow.Caps

Capabilities is the jobs client's, with the schedule family taken from the scheduler client (see scheduleCaps and notForwarded).

func (*Client) Enqueue

func (c *Client) Enqueue(ctx context.Context, job workflow.Job) (workflow.RunRef, error)

Enqueue runs a job on the jobs client.

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

func (c *Client) PauseSchedule(ctx context.Context, t workflow.ScheduleTarget) error

PauseSchedule pauses on the scheduler client.

func (*Client) Register

func (c *Client) Register(wf workflow.Workflow) error

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

func (c *Client) ResumeSchedule(ctx context.Context, t workflow.ScheduleTarget) error

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

func (c *Client) Schedules(ctx context.Context) ([]workflow.ScheduleInfo, error)

Schedules lists the scheduler client's schedules.

func (*Client) Signal

func (c *Client) Signal(ctx context.Context, ev workflow.Event) error

Signal signals the jobs client, where the runs wait.

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

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

func (c *Client) Status(ctx context.Context, ref workflow.RunRef) (workflow.Status, error)

Status reports a run on the jobs client.

func (*Client) TriggerSchedule

func (c *Client) TriggerSchedule(context.Context, workflow.ScheduleID) (workflow.RunRef, error)

TriggerSchedule is refused: a trigger would return the forwarder's run, which the jobs client does not know.

func (*Client) Unschedule

func (c *Client) Unschedule(ctx context.Context, id workflow.ScheduleID) error

Unschedule removes a schedule from the scheduler client.

Jump to

Keyboard shortcuts

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