claimer

package
v0.109.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package claimer hosts the operators a dispatcher claims. It polls ClaimOperators for the rows the dispatcher claims (leasing manager DISPATCHER) assigned to it, builds each one from a factory, opens it through the in-process host with the row as its identity, and starts the operator on the session. An operator that leaves the claim result is torn down the way every host tears an operator down: pause the worker, drain the operator, close the session. Worker rows, heartbeats and the dispatcher's routing table are the host's; the claimer owns placement and lifecycle only.

A factory is found by the row's kind, except for GRPC rows, contract operators, which are found by the row's name: the kind says only that the row is a contract operator, the name says which one the engine should build. A claimed row with no factory is logged once and left alone.

It runs inside the dispatcher process, wired from cmd/hatchet-engine/engine next to the dispatcher, and stops before the dispatcher drains so events reported during a drain still have somewhere to go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claimer

type Claimer struct {
	// contains filtered or unexported fields
}

Claimer polls the claim query and keeps the claimed operators hosted.

func New

func New(fs ...Opt) (*Claimer, error)

func (*Claimer) Reconcile

func (c *Claimer) Reconcile(ctx context.Context, claimed []*sqlcv1.V1Operator)

Reconcile hosts the claimed rows that are not running yet and tears down the running operators that are no longer claimed: an operator assigned to this dispatcher cannot be claimed by another live dispatcher, so an absence means it was deleted or this dispatcher lost it.

func (*Claimer) Running

func (c *Claimer) Running() int

Running is the number of operators hosted right now.

func (*Claimer) Start

func (c *Claimer) Start(ctx context.Context)

Start begins polling. The first claim runs at once so the dispatcher's operators are live without waiting a full interval; Stop ends the polling.

func (*Claimer) Stop

func (c *Claimer) Stop(ctx context.Context)

Stop ends polling and tears every hosted operator down, concurrently, then waits for the teardowns already in flight. It runs once.

type Claims

type Claims interface {
	ClaimOperators(ctx context.Context, dispatcherId uuid.UUID) ([]*sqlcv1.V1Operator, error)
}

Claims is the claim query: the operator rows this dispatcher should run.

type Factory

Factory builds the operator for a claimed row and the options its session is opened with. The handler is set by the claimer.

func DAGFactory

func DAGFactory(l *zerolog.Logger, repo repository.Repository, writer operator.TaskEventWriter, defaultSlots int) Factory

DAGFactory builds DAG operators: the worker's durable slots come from the row's config or the server default.

type Opt

type Opt func(*opts)

func WithClaims

func WithClaims(c Claims) Opt

WithClaims sets the claim query. Required.

func WithDispatcherId

func WithDispatcherId(id uuid.UUID) Opt

WithDispatcherId sets the dispatcher whose claims this claimer hosts. Required.

func WithFactory

func WithFactory(kind sqlcv1.V1OperatorKind, f Factory) Opt

WithFactory registers how claimed rows of one kind are built. GRPC rows are not built by kind, see WithNamedFactory. A claimed row of a kind with no factory is left alone.

func WithHost

func WithHost(h operator.Host) Opt

WithHost sets the host claimed operators are opened on. Required.

func WithLogger

func WithLogger(l *zerolog.Logger) Opt

func WithNamedFactory

func WithNamedFactory(name string, f Factory) Opt

WithNamedFactory registers how claimed GRPC rows named name are built: a contract operator the engine hosts in process under a lease the dispatcher holds. A claimed GRPC row with no factory of its name is left alone.

func WithPollInterval

func WithPollInterval(d time.Duration) Opt

WithPollInterval sets how often the claim query runs.

func WithTeardownTimeout

func WithTeardownTimeout(d time.Duration) Opt

WithTeardownTimeout bounds one operator's pause, drain and close.

Jump to

Keyboard shortcuts

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