Documentation
¶
Index ¶
- Variables
- type AppendAuditParams
- type AppendEventBatchResults
- type AppendEventParams
- type AppendLogChunkBatchResults
- type AppendLogChunkParams
- type Artifact
- type AssignTaskParams
- type AuditLog
- type ConsumeEnrollmentTokenParams
- type CreateArtifactParams
- type CreateEnrollmentTokenParams
- type CreateNodeParams
- type CreateSessionParams
- type CreateTaskParams
- type DBTX
- type EnrollmentToken
- type ExtendLeaseParams
- type InsertInstanceParams
- type Instance
- type ListArtifactsByKindParams
- type ListAuditParams
- type ListEventsParams
- type ListLogChunksParams
- type ListTasksOnNodeParams
- type ListTasksParams
- type MarkLogsRolledUpParams
- type MarkScheduleAttemptParams
- type Node
- type Queries
- func (q *Queries) AppendAudit(ctx context.Context, arg AppendAuditParams) (AuditLog, error)
- func (q *Queries) AppendEvent(ctx context.Context, arg []AppendEventParams) *AppendEventBatchResults
- func (q *Queries) AppendLogChunk(ctx context.Context, arg []AppendLogChunkParams) *AppendLogChunkBatchResults
- func (q *Queries) AssignTask(ctx context.Context, arg AssignTaskParams) (Task, error)
- func (q *Queries) ClaimActiveTasks(ctx context.Context) ([]Task, error)
- func (q *Queries) ClaimQueuedTasks(ctx context.Context, pageLimit int32) ([]Task, error)
- func (q *Queries) ConsumeEnrollmentToken(ctx context.Context, arg ConsumeEnrollmentTokenParams) (EnrollmentToken, error)
- func (q *Queries) CreateArtifact(ctx context.Context, arg CreateArtifactParams) (Artifact, error)
- func (q *Queries) CreateEnrollmentToken(ctx context.Context, arg CreateEnrollmentTokenParams) (EnrollmentToken, error)
- func (q *Queries) CreateNode(ctx context.Context, arg CreateNodeParams) (Node, error)
- func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
- func (q *Queries) CreateTask(ctx context.Context, arg CreateTaskParams) (Task, error)
- func (q *Queries) DeleteNode(ctx context.Context, id string) (int64, error)
- func (q *Queries) DeleteRegistry(ctx context.Context, host string) (int64, error)
- func (q *Queries) DeleteSecret(ctx context.Context, name string) (int64, error)
- func (q *Queries) DeleteSessionByTokenHash(ctx context.Context, tokenHash []byte) error
- func (q *Queries) ExtendLease(ctx context.Context, arg ExtendLeaseParams) (int64, error)
- func (q *Queries) GetArtifact(ctx context.Context, id string) (Artifact, error)
- func (q *Queries) GetEnrollmentTokenByHash(ctx context.Context, tokenHash []byte) (EnrollmentToken, error)
- func (q *Queries) GetInstance(ctx context.Context) (Instance, error)
- func (q *Queries) GetNode(ctx context.Context, id string) (Node, error)
- func (q *Queries) GetNodeByKeyHash(ctx context.Context, nodeKeyHash []byte) (Node, error)
- func (q *Queries) GetRegistries(ctx context.Context, hosts []string) ([]Registry, error)
- func (q *Queries) GetSecret(ctx context.Context, name string) (Secret, error)
- func (q *Queries) GetSecrets(ctx context.Context, names []string) ([]Secret, error)
- func (q *Queries) GetSessionByTokenHash(ctx context.Context, tokenHash []byte) (Session, error)
- func (q *Queries) GetTask(ctx context.Context, id string) (Task, error)
- func (q *Queries) GetTaskForUpdate(ctx context.Context, id string) (Task, error)
- func (q *Queries) GetUser(ctx context.Context, login string) (User, error)
- func (q *Queries) InsertInstance(ctx context.Context, arg InsertInstanceParams) (Instance, error)
- func (q *Queries) ListArtifacts(ctx context.Context, taskID string) ([]Artifact, error)
- func (q *Queries) ListArtifactsByKind(ctx context.Context, arg ListArtifactsByKindParams) ([]Artifact, error)
- func (q *Queries) ListAudit(ctx context.Context, arg ListAuditParams) ([]AuditLog, error)
- func (q *Queries) ListEvents(ctx context.Context, arg ListEventsParams) ([]TaskEvent, error)
- func (q *Queries) ListLogChunks(ctx context.Context, arg ListLogChunksParams) ([]TaskLogChunk, error)
- func (q *Queries) ListNodes(ctx context.Context) ([]Node, error)
- func (q *Queries) ListRegistries(ctx context.Context) ([]Registry, error)
- func (q *Queries) ListRegistriesForUpdate(ctx context.Context) ([]Registry, error)
- func (q *Queries) ListSecrets(ctx context.Context) ([]Secret, error)
- func (q *Queries) ListSecretsForUpdate(ctx context.Context) ([]Secret, error)
- func (q *Queries) ListTasks(ctx context.Context, arg ListTasksParams) ([]Task, error)
- func (q *Queries) ListTasksOnNode(ctx context.Context, arg ListTasksOnNodeParams) ([]Task, error)
- func (q *Queries) MarkLogsRolledUp(ctx context.Context, arg MarkLogsRolledUpParams) error
- func (q *Queries) MarkScheduleAttempt(ctx context.Context, arg MarkScheduleAttemptParams) error
- func (q *Queries) MaxEventSeq(ctx context.Context, taskID string) (int64, error)
- func (q *Queries) MaxLogChunkSeq(ctx context.Context, taskID string) (int64, error)
- func (q *Queries) MaxTaskSeq(ctx context.Context, taskID string) (int64, error)
- func (q *Queries) NotifyTaskEvents(ctx context.Context, taskID string) error
- func (q *Queries) PruneRolledUpLogChunks(ctx context.Context, olderThan time.Time) (int64, error)
- func (q *Queries) ReEncryptRegistry(ctx context.Context, arg ReEncryptRegistryParams) (int64, error)
- func (q *Queries) ReEncryptSecret(ctx context.Context, arg ReEncryptSecretParams) (int64, error)
- func (q *Queries) RequestCancel(ctx context.Context, arg RequestCancelParams) (Task, error)
- func (q *Queries) SetNodeDraining(ctx context.Context, arg SetNodeDrainingParams) (int64, error)
- func (q *Queries) SetNodeLabels(ctx context.Context, arg SetNodeLabelsParams) (Node, error)
- func (q *Queries) SetNodeMaxTasks(ctx context.Context, arg SetNodeMaxTasksParams) (int64, error)
- func (q *Queries) SetNodeStatus(ctx context.Context, arg SetNodeStatusParams) (int64, error)
- func (q *Queries) SetNodeTSStableID(ctx context.Context, arg SetNodeTSStableIDParams) (int64, error)
- func (q *Queries) SetUserRoles(ctx context.Context, arg SetUserRolesParams) (User, error)
- func (q *Queries) TaskLogRollUp(ctx context.Context, id string) (TaskLogRollUpRow, error)
- func (q *Queries) TaskStreamOffsets(ctx context.Context, taskID string) (TaskStreamOffsetsRow, error)
- func (q *Queries) TasksPendingLogRollUp(ctx context.Context, arg TasksPendingLogRollUpParams) ([]string, error)
- func (q *Queries) UpdateNodeHeartbeat(ctx context.Context, arg UpdateNodeHeartbeatParams) (Node, error)
- func (q *Queries) UpdateTaskTransition(ctx context.Context, arg UpdateTaskTransitionParams) (Task, error)
- func (q *Queries) UpsertRegistry(ctx context.Context, arg UpsertRegistryParams) (Registry, error)
- func (q *Queries) UpsertSecret(ctx context.Context, arg UpsertSecretParams) (Secret, error)
- func (q *Queries) UpsertUser(ctx context.Context, arg UpsertUserParams) (User, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type ReEncryptRegistryParams
- type ReEncryptSecretParams
- type Registry
- type RequestCancelParams
- type Secret
- type Session
- type SetNodeDrainingParams
- type SetNodeLabelsParams
- type SetNodeMaxTasksParams
- type SetNodeStatusParams
- type SetNodeTSStableIDParams
- type SetUserRolesParams
- type Task
- type TaskEvent
- type TaskLogChunk
- type TaskLogRollUpRow
- type TaskStreamOffsetsRow
- type TasksPendingLogRollUpParams
- type UpdateNodeHeartbeatParams
- type UpdateTaskTransitionParams
- type UpsertRegistryParams
- type UpsertSecretParams
- type UpsertUserParams
- type User
Constants ¶
This section is empty.
Variables ¶
var (
ErrBatchAlreadyClosed = errors.New("batch already closed")
)
Functions ¶
This section is empty.
Types ¶
type AppendAuditParams ¶
type AppendEventBatchResults ¶
type AppendEventBatchResults struct {
// contains filtered or unexported fields
}
func (*AppendEventBatchResults) Close ¶
func (b *AppendEventBatchResults) Close() error
func (*AppendEventBatchResults) Exec ¶
func (b *AppendEventBatchResults) Exec(f func(int, error))
type AppendEventParams ¶
type AppendLogChunkBatchResults ¶
type AppendLogChunkBatchResults struct {
// contains filtered or unexported fields
}
func (*AppendLogChunkBatchResults) Close ¶
func (b *AppendLogChunkBatchResults) Close() error
func (*AppendLogChunkBatchResults) Exec ¶
func (b *AppendLogChunkBatchResults) Exec(f func(int, error))
type AppendLogChunkParams ¶
type AssignTaskParams ¶
type CreateArtifactParams ¶
type CreateNodeParams ¶
type CreateSessionParams ¶ added in v0.2.0
type CreateTaskParams ¶
type EnrollmentToken ¶
type ExtendLeaseParams ¶
type InsertInstanceParams ¶ added in v0.2.0
type ListAuditParams ¶
type ListEventsParams ¶
type ListLogChunksParams ¶
type ListTasksOnNodeParams ¶
type ListTasksParams ¶
type MarkLogsRolledUpParams ¶
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AppendAudit ¶
func (*Queries) AppendEvent ¶
func (q *Queries) AppendEvent(ctx context.Context, arg []AppendEventParams) *AppendEventBatchResults
AppendEvent is issued as a pgx batch, so a whole event batch costs one round trip. The (task_id, seq) primary key plus DO NOTHING makes a replayed batch a no-op.
func (*Queries) AppendLogChunk ¶
func (q *Queries) AppendLogChunk(ctx context.Context, arg []AppendLogChunkParams) *AppendLogChunkBatchResults
func (*Queries) AssignTask ¶
func (*Queries) ClaimActiveTasks ¶
ClaimActiveTasks is the reconciliation sweep: every task the control plane still owes someone an answer for. It is deliberately not paginated — a control plane with more than a few thousand tasks in flight has a bigger problem than this query.
func (*Queries) ClaimQueuedTasks ¶
ClaimQueuedTasks must run inside a transaction: FOR UPDATE SKIP LOCKED only partitions candidates between concurrent claimers for as long as their transactions stay open.
func (*Queries) ConsumeEnrollmentToken ¶
func (q *Queries) ConsumeEnrollmentToken(ctx context.Context, arg ConsumeEnrollmentTokenParams) (EnrollmentToken, error)
ConsumeEnrollmentToken is the whole single-use check: one statement, so two racing enrollments cannot both win.
func (*Queries) CreateArtifact ¶
func (*Queries) CreateEnrollmentToken ¶
func (q *Queries) CreateEnrollmentToken(ctx context.Context, arg CreateEnrollmentTokenParams) (EnrollmentToken, error)
func (*Queries) CreateNode ¶
func (*Queries) CreateSession ¶ added in v0.2.0
func (*Queries) CreateTask ¶
func (*Queries) DeleteNode ¶
func (*Queries) DeleteRegistry ¶
func (*Queries) DeleteSecret ¶
func (*Queries) DeleteSessionByTokenHash ¶ added in v0.2.0
func (*Queries) ExtendLease ¶
ExtendLease pushes a live task's lease out. It is guarded by the lease id as well as the id, so a stale scheduler cannot extend a lease that has already moved to another node.
func (*Queries) GetArtifact ¶
func (*Queries) GetEnrollmentTokenByHash ¶
func (*Queries) GetInstance ¶ added in v0.2.0
func (*Queries) GetNodeByKeyHash ¶
func (*Queries) GetRegistries ¶
func (*Queries) GetSecrets ¶
func (*Queries) GetSessionByTokenHash ¶ added in v0.2.0
func (*Queries) GetTaskForUpdate ¶
func (*Queries) InsertInstance ¶ added in v0.2.0
func (*Queries) ListArtifacts ¶
func (*Queries) ListArtifactsByKind ¶
func (q *Queries) ListArtifactsByKind(ctx context.Context, arg ListArtifactsByKindParams) ([]Artifact, error)
ListArtifactsByKind is how the roll-up finds the objects it wrote for a task, so a pruned task's logs can be served back from the object store.
func (*Queries) ListEvents ¶
func (*Queries) ListLogChunks ¶
func (q *Queries) ListLogChunks(ctx context.Context, arg ListLogChunksParams) ([]TaskLogChunk, error)
func (*Queries) ListRegistries ¶
func (*Queries) ListRegistriesForUpdate ¶
func (*Queries) ListSecretsForUpdate ¶
ListSecretsForUpdate is the rotation read: it locks every row so a concurrent SetSecret waits rather than being re-encrypted under a key it did not use.
func (*Queries) ListTasks ¶
The search clause uses starts_with/strpos rather than like, so a user typing % or _ is searching for those characters instead of writing a wildcard nobody asked for.
func (*Queries) ListTasksOnNode ¶
func (*Queries) MarkLogsRolledUp ¶
func (q *Queries) MarkLogsRolledUp(ctx context.Context, arg MarkLogsRolledUpParams) error
func (*Queries) MarkScheduleAttempt ¶
func (q *Queries) MarkScheduleAttempt(ctx context.Context, arg MarkScheduleAttemptParams) error
func (*Queries) MaxEventSeq ¶
func (*Queries) MaxLogChunkSeq ¶
func (*Queries) MaxTaskSeq ¶
MaxTaskSeq folds in tasks.logs_high_seq for the same reason TaskStreamOffsets folds in the offsets: pruning a rolled-up task's chunks must not let the high-water mark drop, or a synthetic event would collide with a sequence number that is already spent.
func (*Queries) NotifyTaskEvents ¶
func (*Queries) PruneRolledUpLogChunks ¶
PruneRolledUpLogChunks drops the hot rows of tasks whose logs are safely in the object store and have been for longer than the grace period. It is deliberately scoped by task rather than by chunk age: a task still running after the horizon would otherwise have its own log truncated under it.
func (*Queries) ReEncryptRegistry ¶
func (*Queries) ReEncryptSecret ¶
func (*Queries) RequestCancel ¶
RequestCancel records a durable stop intent. TransitionTask reads it back and rewrites the terminal status the node's finished event would otherwise have produced, so a server restart between the request and the event cannot lose it.
func (*Queries) SetNodeDraining ¶
func (*Queries) SetNodeLabels ¶
func (*Queries) SetNodeMaxTasks ¶
func (*Queries) SetNodeStatus ¶
func (*Queries) SetNodeTSStableID ¶
func (*Queries) SetUserRoles ¶ added in v0.2.0
func (*Queries) TaskLogRollUp ¶
func (*Queries) TaskStreamOffsets ¶
func (q *Queries) TaskStreamOffsets(ctx context.Context, taskID string) (TaskStreamOffsetsRow, error)
TaskStreamOffsets is the reconciliation answer for one task: how far into each of the container's own streams the control plane has committed. Sidecar chunks are excluded — an adopted task's sidecars are never re-attached, so their offsets mean nothing.
The stored roll-up watermarks are folded in with greatest() so the answer cannot go backwards when a rolled-up task's chunks are pruned. A node resumed from a smaller offset would re-send the whole container log under fresh sequence numbers, which is exactly the duplicate step 12 exists to have fixed.
func (*Queries) TasksPendingLogRollUp ¶
func (q *Queries) TasksPendingLogRollUp(ctx context.Context, arg TasksPendingLogRollUpParams) ([]string, error)
TasksPendingLogRollUp is every terminal task whose logs are still only in Postgres. finished_at is null for a task the control plane wrote off without a node event, so coalesce it to created_at rather than skipping the task forever.
func (*Queries) UpdateNodeHeartbeat ¶
func (*Queries) UpdateTaskTransition ¶
func (q *Queries) UpdateTaskTransition(ctx context.Context, arg UpdateTaskTransitionParams) (Task, error)
UpdateTaskTransition applies the patch columns; a nil patch field leaves the column alone. Requeueing (to_status = 'queued') always clears the node and lease bookkeeping.
func (*Queries) UpsertRegistry ¶
func (*Queries) UpsertSecret ¶
func (*Queries) UpsertUser ¶
type ReEncryptRegistryParams ¶
type ReEncryptSecretParams ¶
type RequestCancelParams ¶
type SetNodeDrainingParams ¶
type SetNodeLabelsParams ¶
type SetNodeMaxTasksParams ¶
type SetNodeStatusParams ¶
type SetNodeTSStableIDParams ¶
type SetUserRolesParams ¶ added in v0.2.0
type Task ¶
type Task struct {
ID string
Spec []byte
Status string
Priority int32
RequestedBy string
NodeID *string
LeaseID *string
LeaseExpiresAt *time.Time
Attempts int32
MaxAttempts int32
CreatedAt time.Time
ScheduledAt *time.Time
StartedAt *time.Time
FinishedAt *time.Time
ExitCode *int32
Usage []byte
FailureReason *string
LastScheduleAttemptAt *time.Time
QueuedReason *string
CancelRequestedAt *time.Time
CancelReason *string
CancelStatus *string
LogsRolledUpAt *time.Time
LogsHighSeq int64
LogsStdoutOffset int64
LogsStderrOffset int64
}