api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package api implements the ConnectRPC services of conveyord: the task enqueue API, the worker session protocol, and the bearer-token authentication shared by every service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthInterceptor

func NewAuthInterceptor(tokens []string) connect.Interceptor

NewAuthInterceptor builds the bearer-token interceptor from the accepted tokens. Token comparison is constant-time per candidate.

func NewReadOnlyInterceptor

func NewReadOnlyInterceptor() connect.Interceptor

NewReadOnlyInterceptor builds an interceptor that denies admin mutations.

Types

type AdminService

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

AdminService serves the inspection and operations API.

func NewAdminService

func NewAdminService(engine *actors.Engine, taskLog broker.Broker, timeSource clock.Clock, sessions SessionLister, allowInsecureWebhooks bool) *AdminService

NewAdminService assembles the admin API service.

func (*AdminService) ArchiveTask

ArchiveTask dead-letters a waiting (scheduled, pending, or retry) task.

func (*AdminService) BatchArchiveTasks

BatchArchiveTasks dead-letters each listed task.

func (*AdminService) BatchCancelTasks

BatchCancelTasks cancels each listed task.

func (*AdminService) BatchDeleteTasks

BatchDeleteTasks deletes each listed task, reporting per-id outcomes.

func (*AdminService) BatchRunTasks

BatchRunTasks makes each listed task due immediately.

func (*AdminService) BrokerInfo

BrokerInfo reports the storage engine's driver and runtime statistics.

func (*AdminService) CancelTask

CancelTask cancels a scheduled, pending, or retry task durably. An active task instead receives a best-effort Cancel frame through its executing worker session: the handler's context is canceled and the aborted attempt is archived instead of retried; only a genuine success reported before the cancel lands still completes the task.

func (*AdminService) ClusterInfo

ClusterInfo reports this node and its best-effort view of cluster peers.

func (*AdminService) DeleteCron

DeleteCron removes a cron entry; deleting an absent id succeeds.

func (*AdminService) DeleteGroupConfig added in v0.3.0

DeleteGroupConfig clears a group's override, reverting it to the queue-wide or global default. The sweeper picks up the change on its next tick.

func (*AdminService) DeleteQueueConcurrencyLimit added in v0.2.0

DeleteQueueConcurrencyLimit clears a queue's concurrency limit and reverts the live queue grain to unbounded keys (a zero max-active in the change message).

func (*AdminService) DeleteQueueRateLimit

DeleteQueueRateLimit clears a queue's override and reverts the live queue grain to the server's global default (a zero rate in the change message).

func (*AdminService) DeleteTask

DeleteTask removes a task in any state except active.

func (*AdminService) DeleteWebhookWorker added in v0.4.0

DeleteWebhookWorker removes one registration; deleting an absent name succeeds.

func (*AdminService) ListConcurrencyLimits added in v0.2.0

ListConcurrencyLimits returns every per-queue concurrency limit, ordered by queue name.

func (*AdminService) ListCron

ListCron returns all persisted cron entries ordered by id.

func (*AdminService) ListGroupConfigs added in v0.3.0

ListGroupConfigs returns every per-group aggregation override, ordered by queue then group.

func (*AdminService) ListQueues

ListQueues reports every known queue with its pause flag and per-state task counts.

func (*AdminService) ListRateLimits

ListRateLimits returns every per-queue dispatch-rate override, ordered by queue name.

func (*AdminService) ListTasks

ListTasks pages through tasks newest first, optionally filtered by queue and state.

func (*AdminService) ListWebhookWorkers added in v0.4.0

ListWebhookWorkers returns every registration with its secrets redacted: they are write-only credentials, and a dashboard listing must never leak them.

func (*AdminService) ListWorkerSessions

ListWorkerSessions reports the worker sessions connected to this node.

func (*AdminService) PauseCron

PauseCron suspends materialization of one cron entry.

func (*AdminService) PauseQueue

PauseQueue persists the pause flag and drains the live queue grain so dispatching stops immediately; queued work stays in the broker.

func (*AdminService) PauseWebhookWorker added in v0.4.0

PauseWebhookWorker suspends delivery to one registration.

func (*AdminService) RescheduleTask added in v0.3.0

RescheduleTask moves a waiting (scheduled, pending, or retry) task's due time to a new instant. A future time leaves the task scheduled; a past or present time makes it due immediately and wakes its queue grain.

func (*AdminService) ResumeCron

ResumeCron resumes materialization of one cron entry.

func (*AdminService) ResumeQueue

ResumeQueue clears the pause flag and triggers an immediate lease cycle on the queue grain.

func (*AdminService) ResumeWebhookWorker added in v0.4.0

ResumeWebhookWorker resumes delivery to one paused registration.

func (*AdminService) RunTask

RunTask makes a scheduled, pending, retry, or archived task due immediately and wakes its queue grain.

func (*AdminService) SetGroupConfig added in v0.3.0

SetGroupConfig persists a group's aggregation override. The group sweeper reads the new value on its next tick (firing is poll-based), so no live actor wake is needed, unlike the queue-grain rate-limit path. An empty group sets the queue-wide default applied to every group on the queue without its own override.

func (*AdminService) SetQueueConcurrencyLimit added in v0.2.0

SetQueueConcurrencyLimit persists a queue's per-key concurrency limit and pushes the new value to the live queue grain so it takes effect immediately.

func (*AdminService) SetQueueRateLimit

SetQueueRateLimit persists a queue's dispatch-rate override and pushes the new values to the live queue grain so the limit takes effect immediately.

func (*AdminService) UpsertCron

UpsertCron validates and persists a cron entry by id.

func (*AdminService) UpsertWebhookWorker added in v0.4.0

UpsertWebhookWorker creates or replaces one registration and nudges the webhook manager so the change applies immediately.

func (*AdminService) WatchEvents added in v0.2.0

WatchEvents streams task lifecycle transitions to the caller until the client disconnects. It subscribes to the node-local event bus with the request's queue and event-type filters; a watcher too slow to keep up has events dropped (counted by the events.dropped metric), never stalling dispatch.

type SessionLister

type SessionLister interface {
	// Sessions returns a snapshot of the live worker sessions.
	Sessions() []SessionSnapshot
}

SessionLister reports the worker sessions connected to this node. The WorkerService implements it; AdminService surfaces it for the dashboard.

type SessionSnapshot

type SessionSnapshot struct {
	// ID is the server-assigned session id.
	ID string
	// Queues are the queue names the worker serves, sorted.
	Queues []string
	// Concurrency is the worker's declared concurrency.
	Concurrency int32
	// SDKVersion is the worker's reported SDK version.
	SDKVersion string
	// ConnectedAt is when the session's Hello was accepted.
	ConnectedAt time.Time
}

SessionSnapshot is the externally visible description of one connected worker session, surfaced by the AdminService worker-topology view.

type TaskService

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

TaskService serves the enqueue-side API.

func NewTaskService

func NewTaskService(engine *actors.Engine, taskLog broker.Broker, timeSource clock.Clock, defaultMaxRetry int32) *TaskService

NewTaskService assembles the enqueue-side API service.

func (*TaskService) Enqueue

Enqueue durably commits one task and reports its initial state.

func (*TaskService) EnqueueBatch

EnqueueBatch commits many tasks in one call. Items fail independently: each result carries either the committed task or that item's error.

func (*TaskService) EnqueueTx added in v0.4.0

EnqueueTx commits every task atomically: either all are enqueued or none are. A validation failure on any task rejects the whole request before the broker is touched; a broker failure rolls the whole set back. On success it returns the committed tasks in request order.

func (*TaskService) GetTask

GetTask returns the current state of one task.

type WebhookService added in v0.4.0

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

WebhookService serves the asynchronous-completion callbacks of webhook workers. It is authenticated by per-delivery lease tokens, never by API bearer tokens, so it mounts without the bearer interceptor: an endpoint holding a token may heartbeat and resolve exactly one delivery.

func NewWebhookService added in v0.4.0

func NewWebhookService(engine *actors.Engine, taskLog broker.Broker) *WebhookService

NewWebhookService assembles the webhook callback service.

func (*WebhookService) Heartbeat added in v0.4.0

Heartbeat extends one asynchronously completing delivery's lease.

func (*WebhookService) ReportResult added in v0.4.0

ReportResult resolves one asynchronously completing delivery.

type WorkerService

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

WorkerService serves the worker session protocol: one bidirectional stream per worker process, bridged to a per-session gateway actor.

func NewWorkerService

func NewWorkerService(engine *actors.Engine, logger *slog.Logger, timeSource clock.Clock) *WorkerService

NewWorkerService assembles the worker session service.

func (*WorkerService) ActiveSessions

func (s *WorkerService) ActiveSessions() int64

ActiveSessions returns the number of live worker sessions.

func (*WorkerService) DrainSessions

func (s *WorkerService) DrainSessions(ctx context.Context) error

DrainSessions ends every live worker session and rejects new ones, then waits until each closed session has stopped its gateway — releasing all in-flight tasks for immediate redelivery — or the context lapses. The server runs it before stopping the engine: once the actor system begins stopping it rejects all user messages, and gateways can no longer process drain requests.

func (*WorkerService) Session

Session implements the worker stream protocol: the first frame must be Hello, the server answers Welcome, and every later frame is validated and forwarded to the session's gateway actor. Any protocol violation ends the stream; the deferred gateway stop releases all in-flight tasks for immediate redelivery, whatever the reason the stream ended.

func (*WorkerService) Sessions

func (s *WorkerService) Sessions() []SessionSnapshot

Sessions returns a snapshot of the live worker sessions on this node, sorted by session id for a stable ordering.

Jump to

Keyboard shortcuts

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