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 ¶
- 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.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.
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 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.