Documentation
¶
Overview ¶
Package claimer hosts the operators a dispatcher claims. It polls ClaimOperators for the rows this dispatcher should run (leasing manager DISPATCHER), 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. The claim asks only for rows the claimer has a factory for; a row with no factory handed to Reconcile 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 ¶
- type Claimer
- type Claims
- type Factory
- type Opt
- func WithClaims(c Claims) Opt
- func WithDispatcherId(id uuid.UUID) Opt
- func WithFactory(kind sqlcv1.V1OperatorKind, f Factory) Opt
- func WithHost(h operator.Host) Opt
- func WithLogger(l *zerolog.Logger) Opt
- func WithNamedFactory(name string, f Factory) Opt
- func WithPollInterval(d time.Duration) Opt
- func WithTeardownTimeout(d time.Duration) Opt
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 (*Claimer) Reconcile ¶
func (c *Claimer) Reconcile(ctx context.Context, claimed []*sqlcv1.ClaimOperatorsRow)
Reconcile hosts the claimed rows that are not running yet and tears down the running operators the claim does not mark held. A running row returned as taken rather than held has lost its worker: another dispatcher's registration released it while this dispatcher's heartbeat lagged. It is opened again on a new worker on a later poll.
type Claims ¶
type Claims interface {
ClaimOperators(ctx context.Context, dispatcherId uuid.UUID, opts repository.ClaimOperatorsOpts) ([]*sqlcv1.ClaimOperatorsRow, error)
}
Claims is the claim query: the operator rows this dispatcher should run, among the ones it can build.
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 WithDispatcherId ¶
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 WithLogger ¶
func WithNamedFactory ¶
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 ¶
WithPollInterval sets how often the claim query runs.
func WithTeardownTimeout ¶
WithTeardownTimeout bounds one operator's pause, drain and close.