Documentation
¶
Overview ¶
Package provider defines the provider-neutral durable job store contract. Implementations own their SQL, their DDL bootstrap, and database-time semantics; callers never receive executable SQL and never name a table.
Index ¶
- Constants
- Variables
- func NewIdentifier() (string, error)
- func ValidateClaim(options ClaimOptions) error
- func ValidateClaimResource(resource ClaimResource) error
- func ValidateCode(code string) error
- func ValidateCountQuery(query CountQuery) error
- func ValidateDelay(delay time.Duration) error
- func ValidateEnqueue(request EnqueueRequest) error
- func ValidateFailedQuery(query FailedQuery) error
- func ValidateIdentity(id, token string) error
- func ValidateJobIdentity(id string) error
- func ValidateJobQuery(query JobQuery) error
- func ValidateLease(duration time.Duration) error
- func ValidateOperatorIDs(ids []string) error
- func ValidateRetention(policy RetentionPolicy) error
- type CancelBatch
- type CancelResult
- type ClaimOptions
- type ClaimResource
- type CountQuery
- type EnqueueRequest
- type EnqueueResult
- type Executor
- type FailedCursor
- type FailedPage
- type FailedQuery
- type JobCursor
- type JobPage
- type JobQuery
- type Record
- type Renewal
- type RetentionPolicy
- type State
- type StateCounts
- type Store
- type Summary
Constants ¶
const ( MaximumClaimJobs = 256 MaximumClaimTypes = 256 MaximumRetentionRows = 4096 MaximumPayloadBytes = 1 << 20 MaximumKeyBytes = 256 MaximumOperatorBatch = 256 MaximumIdentityBytes = 64 CodeAttemptsExhausted = "attempts_exhausted" CodeCanceled = "canceled" )
Variables ¶
var ErrNotFound = errors.New("QUEUE_JOB_NOT_FOUND: job is absent")
ErrNotFound reports an inspection of an absent job.
Functions ¶
func NewIdentifier ¶
NewIdentifier returns a canonical UUIDv4 without importing a general UUID package into provider implementations. It supplies both job identities and per-claim lease tokens.
func ValidateClaim ¶
func ValidateClaim(options ClaimOptions) error
func ValidateClaimResource ¶
func ValidateClaimResource(resource ClaimResource) error
ValidateClaimResource refuses ambiguous or unbounded shared-resource plans.
func ValidateCode ¶
func ValidateCountQuery ¶
func ValidateCountQuery(query CountQuery) error
ValidateCountQuery refuses ambiguous operator counts.
func ValidateDelay ¶
func ValidateEnqueue ¶
func ValidateEnqueue(request EnqueueRequest) error
func ValidateFailedQuery ¶
func ValidateFailedQuery(query FailedQuery) error
ValidateFailedQuery refuses unbounded or unstable operator discovery.
func ValidateIdentity ¶
func ValidateJobIdentity ¶
func ValidateJobQuery ¶
ValidateJobQuery refuses unbounded or unstable operator discovery.
func ValidateLease ¶
func ValidateOperatorIDs ¶
ValidateOperatorIDs refuses unbounded or ambiguous bulk recovery.
func ValidateRetention ¶
func ValidateRetention(policy RetentionPolicy) error
Types ¶
type CancelBatch ¶
type CancelBatch struct {
Changed int
Terminal []CancelResult
}
CancelBatch carries partial progress and the immediate terminal transitions an operator must observe.
type CancelResult ¶
CancelResult distinguishes immediate terminal cancellation from a durable request observed later by the lease owner.
type ClaimOptions ¶
type ClaimOptions struct {
Types []string
Limit int
LeaseDuration time.Duration
Resource *ClaimResource
}
ClaimOptions bounds one claim. An empty Types list claims nothing, which is how a worker whose every registered type is saturated stands down.
type ClaimResource ¶
ClaimResource is one normalized fleet-wide weighted concurrency budget.
type CountQuery ¶
type CountQuery struct {
Types []string
}
CountQuery selects the job types included in state counts.
type EnqueueRequest ¶
type EnqueueRequest struct {
ID string
Type string
Payload []byte
MaxAttempts int
Delay time.Duration
DedupeKey string
ExclusiveKey string
}
EnqueueRequest is one durable insert. ID is the caller's proposed identity; a dedupe collision with active work returns the existing identity instead.
type EnqueueResult ¶
EnqueueResult identifies the active job selected by an enqueue and whether this request inserted it. State is the active row state observed while the enqueue decision was serialized.
type Executor ¶
type Executor interface {
ExecContext(ctx context.Context, query string, arguments ...any) (sql.Result, error)
QueryRowContext(ctx context.Context, query string, arguments ...any) *sql.Row
}
Executor is the seam a transactional enqueue runs on. Both *sqlx.DB and *sqlx.Tx satisfy it, so an enqueue can join the caller's transaction rather than escaping to the pool.
type FailedCursor ¶
FailedCursor is the stable position immediately after one failed job.
type FailedPage ¶
FailedPage carries payload-free failed jobs and whether another page exists.
type FailedQuery ¶
type FailedQuery struct {
Types []string
Limit int
Before *FailedCursor
}
FailedQuery selects one bounded page of failed jobs.
type Record ¶
type Record struct {
ID string
Type string
Payload []byte
State State
AttemptCount int64
MaxAttempts int64
AvailableAt time.Time
LeaseToken string
LeaseUntil *time.Time
DedupeKey string
ExclusiveKey string
CancelRequested bool
LastCode string
EnqueuedAt time.Time
FinishedAt *time.Time
UpdatedAt time.Time
}
Record is one sanitized durable job row. It carries the payload bytes a worker must decode and no SQL, driver text, or lease bookkeeping beyond the token that fences this owner's transitions.
func CloneRecords ¶
CloneRecords copies every record's payload so a claimed batch cannot alias provider buffers.
type Renewal ¶
Renewal is the result of one fenced heartbeat. CancelRequested carries the durable cancellation flag, so renewal doubles as the cancellation poll.
type RetentionPolicy ¶
RetentionPolicy bounds one retention run over terminal rows.
type State ¶
type State string
State is the durable job state. It mirrors queue.State without importing the public package into provider implementations.
func RetentionStates ¶
func RetentionStates(policy RetentionPolicy) []State
RetentionStates returns the selected terminal states or every terminal state.
type StateCounts ¶
StateCounts is the number of stored jobs in each durable state.
type Store ¶
type Store interface {
EnsureSchema(ctx context.Context) error
Enqueue(ctx context.Context, executor Executor, request EnqueueRequest) (EnqueueResult, error)
Claim(ctx context.Context, options ClaimOptions) ([]Record, error)
Renew(ctx context.Context, id, token string, duration time.Duration) (Renewal, error)
Succeed(ctx context.Context, id, token, code string) (bool, error)
Fail(ctx context.Context, id, token, code string) (bool, error)
RetryAt(ctx context.Context, id, token string, delay time.Duration, code string, uncounted bool) (bool, error)
MarkCanceled(ctx context.Context, id, token, code string) (bool, error)
Release(ctx context.Context, id, token string) (bool, error)
Inspect(ctx context.Context, id string) (Record, error)
List(ctx context.Context, query JobQuery) (JobPage, error)
ListFailed(ctx context.Context, query FailedQuery) (FailedPage, error)
CountByState(ctx context.Context, query CountQuery) (StateCounts, error)
Cancel(ctx context.Context, id string) (CancelResult, error)
CancelMany(ctx context.Context, ids []string) (CancelBatch, error)
Requeue(ctx context.Context, id string) (bool, error)
RequeueFailed(ctx context.Context, ids []string) (int, error)
RunRetention(ctx context.Context, policy RetentionPolicy) (int, error)
}
Store is the sole mutable seam for _golem_queue. Every token-fenced transition reports changed=false for a stale lease rather than allowing it to mutate a row another worker now owns.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package providertest contains the provider-neutral durable job store conformance gates.
|
Package providertest contains the provider-neutral durable job store conformance gates. |