Documentation
¶
Overview ¶
Package resources provides REST resource implementations for the Spooled API.
Index ¶
- Constants
- Variables
- func AddPaginationParams(v url.Values, limit, offset *int)
- func CoerceFailureMessage(msg string) string
- func IsUnsupportedError(err error) bool
- type APIKey
- type APIKeysResource
- func (r *APIKeysResource) Create(ctx context.Context, req *CreateAPIKeyRequest) (*CreateAPIKeyResponse, error)
- func (r *APIKeysResource) Delete(ctx context.Context, id string) error
- func (r *APIKeysResource) Get(ctx context.Context, id string) (*APIKey, error)
- func (r *APIKeysResource) List(ctx context.Context) ([]APIKey, error)
- func (r *APIKeysResource) Update(ctx context.Context, id string, req *UpdateAPIKeyRequest) (*APIKey, error)
- type AddDependenciesRequest
- type AddDependenciesResponse
- type AdminCreateAPIKeyRequest
- type AdminCreateOrganizationRequest
- type AdminJobStats
- type AdminOrgStats
- type AdminOrganizationList
- type AdminPlanCount
- type AdminResource
- func (r *AdminResource) CreateAPIKey(ctx context.Context, orgID string, req *AdminCreateAPIKeyRequest) (*CreateAPIKeyResponse, error)
- func (r *AdminResource) CreateOrganization(ctx context.Context, req *AdminCreateOrganizationRequest) (*CreateOrganizationResponse, error)
- func (r *AdminResource) DeleteOrganization(ctx context.Context, id string, hard bool) error
- func (r *AdminResource) GetOrganization(ctx context.Context, id string) (*Organization, error)
- func (r *AdminResource) GetPlans(ctx context.Context) ([]PlanLimits, error)
- func (r *AdminResource) GetStats(ctx context.Context) (*AdminStats, error)
- func (r *AdminResource) ListOrganizations(ctx context.Context, params *ListOrganizationsParams) (*AdminOrganizationList, error)
- func (r *AdminResource) ResetUsage(ctx context.Context, orgID string) error
- func (r *AdminResource) UpdateOrganization(ctx context.Context, id string, req *AdminUpdateOrganizationRequest) (*Organization, error)
- type AdminStats
- type AdminSystemStats
- type AdminUpdateOrganizationRequest
- type AdminWorkerStats
- type AuthResource
- func (r *AuthResource) CheckEmail(ctx context.Context, email string) (*CheckEmailResponse, error)
- func (r *AuthResource) Login(ctx context.Context, req *LoginRequest) (*LoginResponse, error)
- func (r *AuthResource) Logout(ctx context.Context, refreshToken ...string) error
- func (r *AuthResource) Me(ctx context.Context) (*MeResponse, error)
- func (r *AuthResource) Refresh(ctx context.Context, req *RefreshRequest) (*RefreshResponse, error)
- func (r *AuthResource) StartEmailLogin(ctx context.Context, req *StartEmailLoginRequest) (*StartEmailLoginResponse, error)
- func (r *AuthResource) Validate(ctx context.Context, req *ValidateRequest) (*ValidateResponse, error)
- func (r *AuthResource) VerifyEmail(ctx context.Context, req *VerifyEmailRequest) (*VerifyEmailResponse, error)
- type Base
- func (b *Base) AdminDelete(ctx context.Context, path string) error
- func (b *Base) AdminGet(ctx context.Context, path string, result any) error
- func (b *Base) AdminPatch(ctx context.Context, path string, body any, result any) error
- func (b *Base) AdminPost(ctx context.Context, path string, body any, result any) error
- func (b *Base) AdminPut(ctx context.Context, path string, body any, result any) error
- func (b *Base) Delete(ctx context.Context, path string) error
- func (b *Base) DeleteWithBody(ctx context.Context, path string, body any, result any) error
- func (b *Base) Get(ctx context.Context, path string, result any) error
- func (b *Base) GetWithQuery(ctx context.Context, path string, query url.Values, result any) error
- func (b *Base) Patch(ctx context.Context, path string, body any, result any) error
- func (b *Base) Post(ctx context.Context, path string, body any, result any) error
- func (b *Base) PostAck(ctx context.Context, path string, body any, result any) error
- func (b *Base) PostIdempotent(ctx context.Context, path string, body any, result any) error
- func (b *Base) Put(ctx context.Context, path string, body any, result any) error
- type BatchJobStatus
- type BillingResource
- type BillingStatus
- type BoostPriorityRequest
- type BoostPriorityResponse
- type BulkEnqueueRequest
- type BulkEnqueueResponse
- type BulkJobFailure
- type BulkJobItem
- type BulkJobSuccess
- type CheckEmailResponse
- type CheckSlugResponse
- type ClaimJobsRequest
- type ClaimJobsResponse
- type ClaimedJob
- type CompleteJobRequest
- type CreateAPIKeyRequest
- type CreateAPIKeyResponse
- type CreateJobRequest
- type CreateJobResponse
- type CreateOrganizationRequest
- type CreateOrganizationResponse
- type CreateOutgoingWebhookRequest
- type CreatePortalRequest
- type CreatePortalResponse
- type CreateScheduleRequest
- type CreateWorkflowRequest
- type CreateWorkflowResponse
- type CustomWebhookRequest
- type CustomWebhookResponse
- type DLQResource
- func (r *DLQResource) List(ctx context.Context, params *ListDLQParams) ([]Job, error)
- func (r *DLQResource) ListPage(ctx context.Context, params *ListDLQParams) (*JobsPage, error)
- func (r *DLQResource) Purge(ctx context.Context, req *PurgeDLQRequest) (*PurgeDLQResponse, error)
- func (r *DLQResource) Retry(ctx context.Context, req *RetryDLQRequest) (*RetryDLQResponse, error)
- type DashboardData
- type DashboardResource
- type DependencyInfo
- type DependencyMode
- type FailJobRequest
- type FailJobResponse
- type GenerateSlugResponse
- type GitHubIngestOptionsdeprecated
- type HealthResource
- type HealthResponse
- type HeartbeatRequest
- type InboundDeliveryStatus
- type InboundWebhookDelivery
- type IngestResource
- func (r *IngestResource) Custom(ctx context.Context, orgID string, req *CustomWebhookRequest) (*CustomWebhookResponse, error)
- func (r *IngestResource) CustomWithToken(ctx context.Context, orgID, webhookToken string, req *CustomWebhookRequest) (*CustomWebhookResponse, error)
- func (r *IngestResource) GitHub(_ context.Context, _ string, _ []byte, _ *GitHubIngestOptions) errordeprecated
- func (r *IngestResource) ListDeliveries(ctx context.Context, params *ListInboundDeliveriesParams) ([]InboundWebhookDelivery, error)
- func (r *IngestResource) Stripe(_ context.Context, _ string, _ []byte, _ *StripeIngestOptions) errordeprecated
- type Job
- type JobHistoryEvent
- type JobHistoryPage
- type JobHistoryParams
- type JobMetrics
- type JobStats
- type JobStatus
- type JobSummaryStats
- type JobWithDependencies
- type JobsPage
- type JobsResource
- func (r *JobsResource) BatchStatus(ctx context.Context, ids []string) ([]BatchJobStatus, error)
- func (r *JobsResource) BoostPriority(ctx context.Context, id string, req *BoostPriorityRequest) (*BoostPriorityResponse, error)
- func (r *JobsResource) BulkEnqueue(ctx context.Context, req *BulkEnqueueRequest) (*BulkEnqueueResponse, error)
- func (r *JobsResource) Cancel(ctx context.Context, id string) error
- func (r *JobsResource) Claim(ctx context.Context, req *ClaimJobsRequest) (*ClaimJobsResponse, error)
- func (r *JobsResource) Complete(ctx context.Context, id string, req *CompleteJobRequest) error
- func (r *JobsResource) Create(ctx context.Context, req *CreateJobRequest) (*CreateJobResponse, error)
- func (r *JobsResource) CreateAndGet(ctx context.Context, req *CreateJobRequest) (*Job, error)
- func (r *JobsResource) DLQ() *DLQResource
- func (r *JobsResource) Fail(ctx context.Context, id string, req *FailJobRequest) error
- func (r *JobsResource) FailWithResponse(ctx context.Context, id string, req *FailJobRequest) (*FailJobResponse, error)
- func (r *JobsResource) Get(ctx context.Context, id string) (*Job, error)
- func (r *JobsResource) GetStats(ctx context.Context) (*JobStats, error)
- func (r *JobsResource) Heartbeat(ctx context.Context, id string, req *HeartbeatRequest) error
- func (r *JobsResource) History(ctx context.Context, id string, params *JobHistoryParams) (*JobHistoryPage, error)
- func (r *JobsResource) List(ctx context.Context, params *ListJobsParams) ([]Job, error)
- func (r *JobsResource) ListPage(ctx context.Context, params *ListJobsParams) (*JobsPage, error)
- func (r *JobsResource) RenewLease(ctx context.Context, id string, req *RenewLeaseRequest) (*RenewLeaseResponse, error)
- func (r *JobsResource) Retry(ctx context.Context, id string) (*Job, error)
- func (r *JobsResource) UpdateProgress(_ context.Context, _ string, _ *UpdateProgressRequest) errordeprecated
- type ListDLQParams
- type ListDeliveriesParams
- type ListInboundDeliveriesParams
- type ListJobsParams
- type ListOrganizationsParams
- type ListSchedulesParams
- type ListWorkflowsParams
- type LoginRequest
- type LoginResponse
- type LogoutRequest
- type MeResponse
- type Metrics
- type MetricsResource
- type Organization
- type OrganizationMember
- type OrganizationsResource
- func (r *OrganizationsResource) CheckSlug(ctx context.Context, slug string) (*CheckSlugResponse, error)
- func (r *OrganizationsResource) ClearWebhookToken(_ context.Context, _ string) errordeprecated
- func (r *OrganizationsResource) Create(ctx context.Context, req *CreateOrganizationRequest) (*CreateOrganizationResponse, error)
- func (r *OrganizationsResource) Delete(ctx context.Context, id string) error
- func (r *OrganizationsResource) GenerateSlug(ctx context.Context, name string) (*GenerateSlugResponse, error)
- func (r *OrganizationsResource) Get(ctx context.Context, id string) (*Organization, error)
- func (r *OrganizationsResource) GetWebhookToken(ctx context.Context, id string) (*WebhookTokenResponse, error)
- func (r *OrganizationsResource) List(ctx context.Context) ([]Organization, error)
- func (r *OrganizationsResource) Members(ctx context.Context, id string) ([]OrganizationMember, error)
- func (r *OrganizationsResource) RegenerateWebhookToken(ctx context.Context, id string) (*WebhookTokenResponse, error)
- func (r *OrganizationsResource) Update(ctx context.Context, id string, req *UpdateOrganizationRequest) (*Organization, error)
- func (r *OrganizationsResource) Usage(ctx context.Context, id string) (*UsageInfo, error)
- type OutgoingWebhook
- type OutgoingWebhookDelivery
- type PauseQueueRequest
- type PauseQueueResponse
- type PlanInfo
- type PlanLimits
- type PlanPrice
- type PlanTier
- type PurgeDLQRequest
- type PurgeDLQResponse
- type QueueConfig
- type QueueListItem
- type QueueMetrics
- type QueueStats
- type QueueSummary
- type QueuesResource
- func (r *QueuesResource) Delete(ctx context.Context, name string) error
- func (r *QueuesResource) Get(ctx context.Context, name string) (*QueueConfig, error)
- func (r *QueuesResource) GetStats(ctx context.Context, name string) (*QueueStats, error)
- func (r *QueuesResource) List(ctx context.Context) ([]QueueListItem, error)
- func (r *QueuesResource) Pause(ctx context.Context, name string, req *PauseQueueRequest) (*PauseQueueResponse, error)
- func (r *QueuesResource) Resume(ctx context.Context, name string) (*ResumeQueueResponse, error)
- func (r *QueuesResource) UpdateConfig(ctx context.Context, name string, req *UpdateQueueConfigRequest) (*QueueConfig, error)
- type RecentActivity
- type RefreshRequest
- type RefreshResponse
- type RegisterWorkerRequest
- type RegisterWorkerResponse
- type RenewLeaseRequest
- type RenewLeaseResponse
- type ResourceUsage
- type ResumeQueueResponse
- type RetryDLQRequest
- type RetryDLQResponse
- type RetryDeliveryResponse
- type Schedule
- type ScheduleRun
- type ScheduleRunStatus
- type SchedulesResource
- func (r *SchedulesResource) Create(ctx context.Context, req *CreateScheduleRequest) (*Schedule, error)
- func (r *SchedulesResource) Delete(ctx context.Context, id string) error
- func (r *SchedulesResource) Get(ctx context.Context, id string) (*Schedule, error)
- func (r *SchedulesResource) History(ctx context.Context, id string, limit *int) ([]ScheduleRun, error)
- func (r *SchedulesResource) List(ctx context.Context, params *ListSchedulesParams) ([]Schedule, error)
- func (r *SchedulesResource) Pause(ctx context.Context, id string) (*Schedule, error)
- func (r *SchedulesResource) Resume(ctx context.Context, id string) (*Schedule, error)
- func (r *SchedulesResource) Trigger(ctx context.Context, id string) (*TriggerScheduleResponse, error)
- func (r *SchedulesResource) Update(ctx context.Context, id string, req *UpdateScheduleRequest) (*Schedule, error)
- type StartEmailLoginRequest
- type StartEmailLoginResponse
- type StripeIngestOptionsdeprecated
- type SystemInfo
- type SystemMetrics
- type TestWebhookResponse
- type TriggerScheduleResponse
- type UnsupportedError
- type UpdateAPIKeyRequest
- type UpdateOrganizationRequest
- type UpdateOutgoingWebhookRequest
- type UpdateProgressRequestdeprecated
- type UpdateQueueConfigRequest
- type UpdateScheduleRequest
- type UsageInfo
- type UsageItem
- type UsageWarning
- type ValidateRequest
- type ValidateResponse
- type VerifyEmailRequest
- type VerifyEmailResponse
- type WebhookDeliveryStatus
- type WebhookEvent
- type WebhookFormat
- type WebhookTokenResponse
- type WebhooksResource
- func (r *WebhooksResource) Create(ctx context.Context, req *CreateOutgoingWebhookRequest) (*OutgoingWebhook, error)
- func (r *WebhooksResource) Delete(ctx context.Context, id string) error
- func (r *WebhooksResource) Deliveries(ctx context.Context, id string, params *ListDeliveriesParams) ([]OutgoingWebhookDelivery, error)
- func (r *WebhooksResource) Get(ctx context.Context, id string) (*OutgoingWebhook, error)
- func (r *WebhooksResource) List(ctx context.Context) ([]OutgoingWebhook, error)
- func (r *WebhooksResource) RetryDelivery(ctx context.Context, webhookID, deliveryID string) (*RetryDeliveryResponse, error)
- func (r *WebhooksResource) Test(ctx context.Context, id string) (*TestWebhookResponse, error)
- func (r *WebhooksResource) Update(ctx context.Context, id string, req *UpdateOutgoingWebhookRequest) (*OutgoingWebhook, error)
- type Worker
- type WorkerHeartbeatRequest
- type WorkerMetrics
- type WorkerStatus
- type WorkerSummary
- type WorkerSummaryInfo
- type WorkersResource
- func (r *WorkersResource) Deregister(ctx context.Context, id string) error
- func (r *WorkersResource) Get(ctx context.Context, id string) (*Worker, error)
- func (r *WorkersResource) Heartbeat(ctx context.Context, id string, req *WorkerHeartbeatRequest) error
- func (r *WorkersResource) List(ctx context.Context) ([]Worker, error)deprecated
- func (r *WorkersResource) ListSummaries(ctx context.Context) ([]WorkerSummary, error)
- func (r *WorkersResource) Register(ctx context.Context, req *RegisterWorkerRequest) (*RegisterWorkerResponse, error)
- type Workflow
- type WorkflowJob
- type WorkflowJobDefinition
- type WorkflowJobMapping
- type WorkflowJobStatus
- type WorkflowJobStatusResponse
- type WorkflowJobsResource
- func (r *WorkflowJobsResource) GetJob(ctx context.Context, workflowID, jobID string) (*WorkflowJob, error)
- func (r *WorkflowJobsResource) GetJobsStatus(ctx context.Context, workflowID string) (*WorkflowJobStatusResponse, error)
- func (r *WorkflowJobsResource) ListJobs(ctx context.Context, workflowID string) ([]WorkflowJob, error)
- type WorkflowStatus
- type WorkflowsResource
- func (r *WorkflowsResource) AddJobDependencies(ctx context.Context, jobID string, req *AddDependenciesRequest) (*AddDependenciesResponse, error)
- func (r *WorkflowsResource) Cancel(ctx context.Context, id string) error
- func (r *WorkflowsResource) Create(ctx context.Context, req *CreateWorkflowRequest) (*CreateWorkflowResponse, error)
- func (r *WorkflowsResource) Get(ctx context.Context, id string) (*Workflow, error)
- func (r *WorkflowsResource) GetJobDependencies(ctx context.Context, jobID string) (*JobWithDependencies, error)
- func (r *WorkflowsResource) Jobs() *WorkflowJobsResource
- func (r *WorkflowsResource) List(ctx context.Context, params *ListWorkflowsParams) ([]Workflow, error)
- func (r *WorkflowsResource) Retry(ctx context.Context, id string) (*Workflow, error)
Constants ¶
const DefaultFailureMessage = "Job failed"
DefaultFailureMessage replaces an empty failure message.
const MaxFailureMessageLength = 2048
MaxFailureMessageLength is the longest failure message POST /jobs/{id}/fail accepts, counted in characters.
Variables ¶
var ErrUnsupported = errors.New("not supported by the Spooled API")
ErrUnsupported is matched by errors.Is for every error returned by an SDK method whose operation the Spooled API does not offer.
Those methods are kept so existing code still compiles, but they fail at once and without a network call, with a message that says why. Before they were kept this way each one sent a request the API answered with a bare 404 (or a permanent 422) that looked like a transient server fault.
var ErrWebhookTokenRequired = errors.New("spooled: webhook ingestion needs the organization's webhook token " +
"(set CustomWebhookRequest.WebhookToken, or use CustomWithToken; Organizations().GetWebhookToken returns it)")
ErrWebhookTokenRequired is returned by Ingest().Custom when the request has no webhook token. The API authenticates POST /webhooks/{org_id}/custom with the organization's webhook token (X-Webhook-Token) and answers every call without a valid one with 401, so the call is refused before it reaches the network.
Functions ¶
func AddPaginationParams ¶
AddPaginationParams adds pagination parameters to query values.
func CoerceFailureMessage ¶ added in v1.5.0
CoerceFailureMessage makes a failure message acceptable to the API, which rejects an empty one or one over MaxFailureMessageLength characters with a 400. A rejected /fail leaves the job "processing" until its lease expires, so the real error is lost and the retry is delayed by the whole lease.
An empty (or blank) message becomes "Job failed"; a longer one is cut to 2048 characters on a character boundary, never in the middle of a UTF-8 sequence.
func IsUnsupportedError ¶ added in v1.5.0
IsUnsupportedError returns true if err is (or wraps) an UnsupportedError.
Types ¶
type APIKey ¶
type APIKey struct {
ID string `json:"id"`
OrganizationID *string `json:"organization_id,omitempty"`
Name string `json:"name"`
KeyPrefix *string `json:"key_prefix,omitempty"`
Queues []string `json:"queues,omitempty"`
RateLimit *int `json:"rate_limit,omitempty"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
// LastUsed is coarse: the server records it at most once per key per five
// minutes, not once per request, so it can trail real usage by that much
// and stays nil for a key first used moments ago. Do not treat it as a
// live timestamp or use it to confirm an individual request.
LastUsed *time.Time `json:"last_used,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
APIKey represents an API key.
type APIKeysResource ¶
type APIKeysResource struct {
// contains filtered or unexported fields
}
APIKeysResource provides access to API key operations.
func NewAPIKeysResource ¶
func NewAPIKeysResource(transport *httpx.Transport) *APIKeysResource
NewAPIKeysResource creates a new APIKeysResource.
func (*APIKeysResource) Create ¶
func (r *APIKeysResource) Create(ctx context.Context, req *CreateAPIKeyRequest) (*CreateAPIKeyResponse, error)
Create creates a new API key.
func (*APIKeysResource) Delete ¶
func (r *APIKeysResource) Delete(ctx context.Context, id string) error
Delete deletes an API key.
func (*APIKeysResource) List ¶
func (r *APIKeysResource) List(ctx context.Context) ([]APIKey, error)
List retrieves all API keys.
func (*APIKeysResource) Update ¶
func (r *APIKeysResource) Update(ctx context.Context, id string, req *UpdateAPIKeyRequest) (*APIKey, error)
Update updates an API key.
type AddDependenciesRequest ¶
type AddDependenciesRequest struct {
DependsOn []string `json:"depends_on"`
DependencyMode *DependencyMode `json:"dependency_mode,omitempty"`
}
AddDependenciesRequest is the request to add job dependencies.
type AddDependenciesResponse ¶
type AddDependenciesResponse struct {
DependenciesAdded int `json:"dependencies_added"`
DependenciesMet bool `json:"dependencies_met"`
Success bool `json:"success"`
Dependencies []string `json:"dependencies,omitempty"`
}
AddDependenciesResponse is the response from adding dependencies.
type AdminCreateAPIKeyRequest ¶
type AdminCreateAPIKeyRequest struct {
Name string `json:"name"`
Queues []string `json:"queues,omitempty"`
RateLimit *int `json:"rate_limit,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
CreateAPIKeyRequest is the admin request to create an API key for an org.
type AdminCreateOrganizationRequest ¶
type AdminCreateOrganizationRequest struct {
Name string `json:"name"`
Slug string `json:"slug"`
PlanTier *PlanTier `json:"plan_tier,omitempty"`
BillingEmail *string `json:"billing_email,omitempty"`
CustomLimits map[string]any `json:"custom_limits,omitempty"`
}
CreateOrganizationRequest is the admin request to create an organization.
type AdminJobStats ¶ added in v1.3.0
type AdminJobStats struct {
TotalActive int `json:"total_active"`
Pending int `json:"pending"`
Processing int `json:"processing"`
Completed24h int `json:"completed_24h"`
Failed24h int `json:"failed_24h"`
}
AdminJobStats is job counts from GET /admin/stats.
type AdminOrgStats ¶ added in v1.3.0
type AdminOrgStats struct {
Total int `json:"total"`
ByPlan []AdminPlanCount `json:"by_plan"`
CreatedToday int `json:"created_today"`
CreatedThisWeek int `json:"created_this_week"`
}
AdminOrgStats is organization counts from GET /admin/stats.
type AdminOrganizationList ¶
type AdminOrganizationList struct {
Organizations []Organization `json:"organizations"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
AdminOrganizationList is the paginated response for admin list organizations.
type AdminPlanCount ¶ added in v1.3.0
AdminPlanCount is one plan's organization count from GET /admin/stats.
type AdminResource ¶
type AdminResource struct {
// contains filtered or unexported fields
}
AdminResource provides access to admin operations. All operations require the X-Admin-Key header.
func NewAdminResource ¶
func NewAdminResource(transport *httpx.Transport) *AdminResource
NewAdminResource creates a new AdminResource.
func (*AdminResource) CreateAPIKey ¶
func (r *AdminResource) CreateAPIKey(ctx context.Context, orgID string, req *AdminCreateAPIKeyRequest) (*CreateAPIKeyResponse, error)
CreateAPIKey creates an API key for an organization (admin only).
func (*AdminResource) CreateOrganization ¶
func (r *AdminResource) CreateOrganization(ctx context.Context, req *AdminCreateOrganizationRequest) (*CreateOrganizationResponse, error)
CreateOrganization creates an organization (admin only).
func (*AdminResource) DeleteOrganization ¶
DeleteOrganization deletes an organization (admin only).
func (*AdminResource) GetOrganization ¶
func (r *AdminResource) GetOrganization(ctx context.Context, id string) (*Organization, error)
GetOrganization retrieves a specific organization (admin only).
func (*AdminResource) GetPlans ¶
func (r *AdminResource) GetPlans(ctx context.Context) ([]PlanLimits, error)
GetPlans retrieves all available subscription plans.
GET /admin/plans returns a flat PlanLimits array (tier, display_name, and the limit fields on the same object). It is not wrapped as {limits, price}.
func (*AdminResource) GetStats ¶
func (r *AdminResource) GetStats(ctx context.Context) (*AdminStats, error)
GetStats retrieves platform-wide statistics.
func (*AdminResource) ListOrganizations ¶
func (r *AdminResource) ListOrganizations(ctx context.Context, params *ListOrganizationsParams) (*AdminOrganizationList, error)
ListOrganizations retrieves all organizations (admin only).
func (*AdminResource) ResetUsage ¶
func (r *AdminResource) ResetUsage(ctx context.Context, orgID string) error
ResetUsage resets usage counters for an organization.
func (*AdminResource) UpdateOrganization ¶
func (r *AdminResource) UpdateOrganization(ctx context.Context, id string, req *AdminUpdateOrganizationRequest) (*Organization, error)
UpdateOrganization updates an organization (admin only).
type AdminStats ¶
type AdminStats struct {
Organizations AdminOrgStats `json:"organizations"`
Jobs AdminJobStats `json:"jobs"`
Workers AdminWorkerStats `json:"workers"`
System AdminSystemStats `json:"system"`
}
AdminStats is GET /admin/stats — nested org/job/worker/system counts, not flat totals.
type AdminSystemStats ¶ added in v1.3.0
type AdminSystemStats struct {
APIVersion string `json:"api_version"`
UptimeSeconds int64 `json:"uptime_seconds"`
}
AdminSystemStats is process info from GET /admin/stats.
type AdminUpdateOrganizationRequest ¶
type AdminUpdateOrganizationRequest struct {
Name *string `json:"name,omitempty"`
PlanTier *PlanTier `json:"plan_tier,omitempty"`
BillingEmail *string `json:"billing_email,omitempty"`
CustomLimits map[string]any `json:"custom_limits,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
UpdateOrganizationRequest is the admin request to update an organization.
type AdminWorkerStats ¶ added in v1.3.0
type AdminWorkerStats struct {
Total int `json:"total"`
Healthy int `json:"healthy"`
Degraded int `json:"degraded"`
}
AdminWorkerStats is worker counts from GET /admin/stats.
type AuthResource ¶
type AuthResource struct {
// contains filtered or unexported fields
}
AuthResource provides access to authentication operations.
func NewAuthResource ¶
func NewAuthResource(transport *httpx.Transport) *AuthResource
NewAuthResource creates a new AuthResource.
func (*AuthResource) CheckEmail ¶
func (r *AuthResource) CheckEmail(ctx context.Context, email string) (*CheckEmailResponse, error)
CheckEmail checks whether an email is registered (GET /auth/check-email).
func (*AuthResource) Login ¶
func (r *AuthResource) Login(ctx context.Context, req *LoginRequest) (*LoginResponse, error)
Login authenticates with an API key and returns JWT tokens.
func (*AuthResource) Logout ¶
func (r *AuthResource) Logout(ctx context.Context, refreshToken ...string) error
Logout invalidates the access token and, when available, the refresh token.
POST /auth/logout blacklists the access token from Authorization. Without refresh_token in the body, /auth/refresh still mints a new pair. An explicit token is sent when given; otherwise the client's stored refresh token is used.
func (*AuthResource) Me ¶
func (r *AuthResource) Me(ctx context.Context) (*MeResponse, error)
Me retrieves information about the current authenticated session.
func (*AuthResource) Refresh ¶
func (r *AuthResource) Refresh(ctx context.Context, req *RefreshRequest) (*RefreshResponse, error)
Refresh refreshes an access token using a refresh token.
func (*AuthResource) StartEmailLogin ¶
func (r *AuthResource) StartEmailLogin(ctx context.Context, req *StartEmailLoginRequest) (*StartEmailLoginResponse, error)
StartEmailLogin starts the email login flow by sending a login code.
func (*AuthResource) Validate ¶
func (r *AuthResource) Validate(ctx context.Context, req *ValidateRequest) (*ValidateResponse, error)
Validate validates a token.
func (*AuthResource) VerifyEmail ¶
func (r *AuthResource) VerifyEmail(ctx context.Context, req *VerifyEmailRequest) (*VerifyEmailResponse, error)
VerifyEmail verifies an email login code.
Existing accounts return type "login" with tokens. New emails return type "signup" with signup_token; mapping that onto token fields dropped the token needed for POST /auth/signup/complete.
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base provides common functionality for all resources.
func (*Base) AdminDelete ¶
AdminDelete performs a DELETE request with admin key.
func (*Base) AdminPatch ¶ added in v1.3.0
AdminPatch performs a PATCH request with admin key.
func (*Base) DeleteWithBody ¶
DeleteWithBody performs a DELETE request with a body.
func (*Base) GetWithQuery ¶
GetWithQuery performs a GET request with query parameters.
func (*Base) PostAck ¶ added in v1.5.0
PostAck performs a worker acknowledgement POST (complete, fail, heartbeat).
Acks are lease-fenced, so repeating one is harmless: a duplicate is answered with 409 and never applied twice. They are therefore retried on network errors, timeouts, 408, 429 and 5xx like an idempotent request, and they ignore an open circuit breaker. Losing an ack throws away finished work and leaves the job "processing" until its lease expires.
func (*Base) PostIdempotent ¶
PostIdempotent performs an idempotent POST request (can be retried).
type BatchJobStatus ¶
type BatchJobStatus struct {
ID string `json:"id"`
Status JobStatus `json:"status"`
QueueName string `json:"queue_name"`
RetryCount int `json:"retry_count"`
CreatedAt time.Time `json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
BatchJobStatus is the status of a job in a batch. GET /jobs/status sends retry_count, not attempt, and has no max_retries.
type BillingResource ¶
type BillingResource struct {
// contains filtered or unexported fields
}
BillingResource provides access to billing operations.
func NewBillingResource ¶
func NewBillingResource(transport *httpx.Transport) *BillingResource
NewBillingResource creates a new BillingResource.
func (*BillingResource) CreatePortalSession ¶
func (r *BillingResource) CreatePortalSession(ctx context.Context, req *CreatePortalRequest) (*CreatePortalResponse, error)
CreatePortalSession creates a Stripe billing portal session.
func (*BillingResource) GetStatus ¶
func (r *BillingResource) GetStatus(ctx context.Context) (*BillingStatus, error)
GetStatus retrieves billing status for the current organization.
type BillingStatus ¶
type BillingStatus struct {
PlanTier PlanTier `json:"plan_tier"`
StripeSubscriptionID *string `json:"stripe_subscription_id,omitempty"`
StripeSubscriptionStatus *string `json:"stripe_subscription_status,omitempty"`
StripeCurrentPeriodEnd *time.Time `json:"stripe_current_period_end,omitempty"`
StripeCancelAtPeriodEnd *bool `json:"stripe_cancel_at_period_end,omitempty"`
HasStripeCustomer bool `json:"has_stripe_customer"`
}
BillingStatus represents billing status information.
type BoostPriorityRequest ¶
type BoostPriorityRequest struct {
Priority int `json:"priority"`
}
BoostPriorityRequest is the request to boost a job's priority.
type BoostPriorityResponse ¶
type BoostPriorityResponse struct {
JobID string `json:"job_id"`
OldPriority int `json:"old_priority"`
NewPriority int `json:"new_priority"`
}
BoostPriorityResponse is the response from boosting a job's priority.
type BulkEnqueueRequest ¶
type BulkEnqueueRequest struct {
QueueName string `json:"queue_name"`
Jobs []BulkJobItem `json:"jobs"`
DefaultPriority *int `json:"default_priority,omitempty"`
DefaultMaxRetries *int `json:"default_max_retries,omitempty"`
DefaultTimeoutSeconds *int `json:"default_timeout_seconds,omitempty"`
}
BulkEnqueueRequest is the request to bulk enqueue jobs.
type BulkEnqueueResponse ¶
type BulkEnqueueResponse struct {
Succeeded []BulkJobSuccess `json:"succeeded"`
Failed []BulkJobFailure `json:"failed"`
Total int `json:"total"`
SuccessCount int `json:"success_count"`
FailureCount int `json:"failure_count"`
}
BulkEnqueueResponse is the response from bulk enqueueing jobs.
type BulkJobFailure ¶
BulkJobFailure represents a failed job in bulk enqueue.
type BulkJobItem ¶
type BulkJobItem struct {
Payload any `json:"payload"`
Priority *int `json:"priority,omitempty"`
IdempotencyKey *string `json:"idempotency_key,omitempty"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
}
BulkJobItem is an individual job in a bulk enqueue request.
Payload is `any` for the same reason as CreateJobRequest.Payload: the API field is `serde_json::Value`, not an object.
type BulkJobSuccess ¶
type BulkJobSuccess struct {
Index int `json:"index"`
JobID string `json:"job_id"`
Created bool `json:"created"`
}
BulkJobSuccess represents a successfully enqueued job.
type CheckEmailResponse ¶
type CheckEmailResponse struct {
Available bool `json:"available"`
Exists bool `json:"exists"`
SignupEnabled bool `json:"signup_enabled"`
}
CheckEmailResponse is GET /auth/check-email.
type CheckSlugResponse ¶
type CheckSlugResponse struct {
Available bool `json:"available"`
Valid bool `json:"valid"`
Error *string `json:"error,omitempty"`
Suggestion *string `json:"suggestion,omitempty"`
}
CheckSlugResponse is the response from checking slug availability.
type ClaimJobsRequest ¶
type ClaimJobsRequest struct {
QueueName string `json:"queue_name"`
WorkerID string `json:"worker_id"`
Limit *int `json:"limit,omitempty"`
LeaseDurationSec *int `json:"lease_duration_secs,omitempty"`
}
ClaimJobsRequest is the request to claim jobs.
type ClaimJobsResponse ¶
type ClaimJobsResponse struct {
Jobs []ClaimedJob `json:"jobs"`
}
ClaimJobsResponse is the response from claiming jobs.
type ClaimedJob ¶
type ClaimedJob struct {
ID string `json:"id"`
QueueName string `json:"queue_name"`
Payload any `json:"payload"`
RetryCount int `json:"retry_count"`
MaxRetries int `json:"max_retries"`
TimeoutSeconds int `json:"timeout_seconds"`
LeaseExpiresAt *time.Time `json:"lease_expires_at,omitempty"`
// LeaseID is the lease fencing token issued by the server for this claim.
// Echo it back on Complete, Fail, Heartbeat and RenewLease: the API
// requires it there (422 VALIDATION_ERROR without it) and applies the call
// only to the lease this worker actually holds.
LeaseID *string `json:"lease_id,omitempty"`
}
ClaimedJob is a job that has been claimed by a worker.
type CompleteJobRequest ¶
type CompleteJobRequest struct {
WorkerID string `json:"worker_id"`
Result any `json:"result,omitempty"`
// LeaseID is the lease fencing token from the claimed job
// (ClaimedJob.LeaseID). It is required: the API answers a complete without
// it with 422 VALIDATION_ERROR ("Field `lease_id` is required"), and one
// that does not match the job's current lease with 409. It is a pointer
// only for compatibility; always set it.
LeaseID *string `json:"lease_id,omitempty"`
}
CompleteJobRequest is the request to complete a job.
type CreateAPIKeyRequest ¶
type CreateAPIKeyRequest struct {
Name string `json:"name"`
Queues []string `json:"queues,omitempty"`
RateLimit *int `json:"rate_limit,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
CreateAPIKeyRequest is the request to create an API key.
type CreateAPIKeyResponse ¶
type CreateAPIKeyResponse struct {
ID string `json:"id"`
Key string `json:"key"` // Raw key - only shown once!
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
CreateAPIKeyResponse is the response from creating an API key.
type CreateJobRequest ¶
type CreateJobRequest struct {
QueueName string `json:"queue_name"`
Payload any `json:"payload"`
Priority *int `json:"priority,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
IdempotencyKey *string `json:"idempotency_key,omitempty"`
Tags any `json:"tags,omitempty"`
ParentJobID *string `json:"parent_job_id,omitempty"`
CompletionWebhook *string `json:"completion_webhook,omitempty"`
}
CreateJobRequest is the request to create a new job.
Payload and Tags are `any`, not `map[string]any`: the API stores both as `serde_json::Value`, so a JSON array, string, number or boolean is a valid payload, and a map type could neither send nor round-trip one.
type CreateJobResponse ¶
CreateJobResponse is the response from creating a job.
type CreateOrganizationRequest ¶
type CreateOrganizationRequest struct {
Name string `json:"name"`
Slug string `json:"slug"`
BillingEmail *string `json:"billing_email,omitempty"`
}
CreateOrganizationRequest is the request to create an organization.
type CreateOrganizationResponse ¶
type CreateOrganizationResponse struct {
Organization Organization `json:"organization"`
APIKey CreateAPIKeyResponse `json:"api_key"`
}
CreateOrganizationResponse is the response from creating an organization.
type CreateOutgoingWebhookRequest ¶
type CreateOutgoingWebhookRequest struct {
Name string `json:"name"`
URL string `json:"url"`
Events []WebhookEvent `json:"events"`
Secret *string `json:"secret,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
// Format is the delivery body (json, slack, discord or teams). Nil sends
// nothing and the server uses json. An unknown value is a 400.
Format *WebhookFormat `json:"format,omitempty"`
}
CreateOutgoingWebhookRequest is the request to create an outgoing webhook.
type CreatePortalRequest ¶
type CreatePortalRequest struct {
ReturnURL string `json:"return_url"`
}
CreatePortalRequest is the request to create a billing portal session.
type CreatePortalResponse ¶
type CreatePortalResponse struct {
URL string `json:"url"`
}
CreatePortalResponse is the response from creating a billing portal session.
type CreateScheduleRequest ¶
type CreateScheduleRequest struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
CronExpression string `json:"cron_expression"`
Timezone *string `json:"timezone,omitempty"`
QueueName string `json:"queue_name"`
PayloadTemplate any `json:"payload_template"`
Priority *int `json:"priority,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"`
Tags any `json:"tags,omitempty"`
Metadata any `json:"metadata,omitempty"`
}
CreateScheduleRequest is the request to create a schedule.
type CreateWorkflowRequest ¶
type CreateWorkflowRequest struct {
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Jobs []WorkflowJobDefinition `json:"jobs"`
Metadata map[string]any `json:"metadata,omitempty"`
}
CreateWorkflowRequest is the request to create a workflow.
type CreateWorkflowResponse ¶
type CreateWorkflowResponse struct {
WorkflowID string `json:"workflow_id"`
JobIDs []WorkflowJobMapping `json:"job_ids"`
}
CreateWorkflowResponse is the response from creating a workflow.
JobIDs is the only place the API returns the job keys: workflow details (Get, Jobs().ListJobs, Jobs().GetJob, Jobs().GetJobsStatus) carry job IDs but no keys. Keep this response, or the map from KeyByJobID, to translate.
func (*CreateWorkflowResponse) ApplyKeys ¶ added in v1.5.0
func (r *CreateWorkflowResponse) ApplyKeys(jobs []WorkflowJob)
ApplyKeys fills in Key on jobs from this create response, matching by job ID. Jobs it does not know keep their Key.
func (*CreateWorkflowResponse) JobID ¶ added in v1.5.0
func (r *CreateWorkflowResponse) JobID(key string) (string, bool)
JobID returns the ID of the job created for key.
func (*CreateWorkflowResponse) KeyByJobID ¶ added in v1.5.0
func (r *CreateWorkflowResponse) KeyByJobID() map[string]string
KeyByJobID maps each created job's ID to the key it was defined with.
type CustomWebhookRequest ¶
type CustomWebhookRequest struct {
QueueName string `json:"queue_name"`
EventType *string `json:"event_type,omitempty"`
Payload map[string]any `json:"payload"`
IdempotencyKey *string `json:"idempotency_key,omitempty"`
Priority *int `json:"priority,omitempty"`
// WebhookToken is the organization's webhook token, sent as the
// X-Webhook-Token header (never in the body). Ingest().Custom requires it;
// CustomWithToken takes the token as an argument instead.
WebhookToken string `json:"-"`
}
CustomWebhookRequest is the request to ingest a custom webhook.
type CustomWebhookResponse ¶
type CustomWebhookResponse struct {
JobID string `json:"job_id"`
QueueName string `json:"queue_name"`
Status string `json:"status"`
}
CustomWebhookResponse is POST /webhooks/{org_id}/custom (OpenAPI WebhookResponse).
type DLQResource ¶
type DLQResource struct {
// contains filtered or unexported fields
}
DLQResource provides access to Dead Letter Queue operations.
func (*DLQResource) List ¶
func (r *DLQResource) List(ctx context.Context, params *ListDLQParams) ([]Job, error)
List retrieves dead letter queue jobs. ListPage also reports whether more follow.
func (*DLQResource) ListPage ¶ added in v1.5.0
func (r *DLQResource) ListPage(ctx context.Context, params *ListDLQParams) (*JobsPage, error)
ListPage retrieves one page of dead-lettered jobs together with the X-Has-More hint.
func (*DLQResource) Purge ¶
func (r *DLQResource) Purge(ctx context.Context, req *PurgeDLQRequest) (*PurgeDLQResponse, error)
Purge removes jobs from the dead letter queue.
func (*DLQResource) Retry ¶
func (r *DLQResource) Retry(ctx context.Context, req *RetryDLQRequest) (*RetryDLQResponse, error)
Retry retries jobs in the dead letter queue.
type DashboardData ¶
type DashboardData struct {
System SystemInfo `json:"system"`
Jobs JobSummaryStats `json:"jobs"`
Queues []QueueSummary `json:"queues"`
Workers WorkerSummaryInfo `json:"workers"`
RecentActivity RecentActivity `json:"recent_activity"`
}
DashboardData represents aggregated dashboard data.
type DashboardResource ¶
type DashboardResource struct {
// contains filtered or unexported fields
}
DashboardResource provides access to dashboard operations.
func NewDashboardResource ¶
func NewDashboardResource(transport *httpx.Transport) *DashboardResource
NewDashboardResource creates a new DashboardResource.
func (*DashboardResource) Get ¶
func (r *DashboardResource) Get(ctx context.Context) (*DashboardData, error)
Get retrieves the dashboard data.
type DependencyInfo ¶ added in v1.3.0
type DependencyInfo struct {
JobID string `json:"job_id"`
QueueName string `json:"queue_name"`
Status string `json:"status"`
}
DependencyInfo is one edge on GET /jobs/{id}/dependencies.
type DependencyMode ¶
type DependencyMode string
DependencyMode specifies how job dependencies are evaluated.
const ( DependencyModeAll DependencyMode = "all" DependencyModeAny DependencyMode = "any" )
type FailJobRequest ¶
type FailJobRequest struct {
WorkerID string `json:"worker_id"`
Error string `json:"error"`
// LeaseID is the lease fencing token from the claimed job
// (ClaimedJob.LeaseID). It is required: the API answers a fail without it
// with 422 VALIDATION_ERROR ("Field `lease_id` is required"), and one that
// does not match the job's current lease with 409. It is a pointer only for
// compatibility; always set it.
LeaseID *string `json:"lease_id,omitempty"`
}
FailJobRequest is the request to fail a job.
type FailJobResponse ¶ added in v1.0.20
type FailJobResponse struct {
Success bool `json:"success"`
// WillRetry and NextRetryDelaySec are filled only when the API sends them.
// POST /jobs/{id}/fail on Spooled Cloud currently answers {"success":true}
// alone, so both are nil there: decide from the claimed job instead (it is
// retried while RetryCount < MaxRetries), or fail over gRPC, whose
// FailWithResponse returns the server's decision.
WillRetry *bool `json:"will_retry,omitempty"`
NextRetryDelaySec *int `json:"next_retry_delay_secs,omitempty"`
}
FailJobResponse is returned after the backend accepts a job failure.
type GenerateSlugResponse ¶
type GenerateSlugResponse struct {
Slug string `json:"slug"`
}
GenerateSlugResponse is the response from generating a slug.
type GitHubIngestOptions
deprecated
type GitHubIngestOptions struct {
// GitHubEvent is the GitHub event name, e.g. "push".
GitHubEvent string
// Signature is the X-Hub-Signature-256 value.
Signature string
// Secret was used to compute the signature.
Secret string
// WebhookToken is sent as X-Webhook-Token.
WebhookToken string
// ForwardedProto is sent as X-Forwarded-Proto.
ForwardedProto string
}
GitHubIngestOptions configures GitHub webhook ingestion.
Deprecated: the Spooled API has no GitHub ingestion route.
type HealthResource ¶
type HealthResource struct {
// contains filtered or unexported fields
}
HealthResource provides access to health check operations.
func NewHealthResource ¶
func NewHealthResource(transport *httpx.Transport) *HealthResource
NewHealthResource creates a new HealthResource.
func (*HealthResource) Get ¶
func (r *HealthResource) Get(ctx context.Context) (*HealthResponse, error)
Get performs a full health check.
func (*HealthResource) Liveness ¶
func (r *HealthResource) Liveness(ctx context.Context) (*HealthResponse, error)
Liveness checks if the service is alive. The API answers 200 with an empty body, so the response carries Status "alive" and nothing else; a failing probe is an error.
func (*HealthResource) Readiness ¶
func (r *HealthResource) Readiness(ctx context.Context) (*HealthResponse, error)
Readiness checks if the service is ready to serve requests. The API answers 200 with an empty body, so the response carries Status "ready" and nothing else; a failing probe (503) is an error.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Database bool `json:"database"`
Cache bool `json:"cache"`
Timestamp string `json:"timestamp,omitempty"`
}
HealthResponse represents the health check response.
type HeartbeatRequest ¶
type HeartbeatRequest struct {
WorkerID string `json:"worker_id"`
LeaseDurationSec *int `json:"lease_duration_secs,omitempty"`
// LeaseID is the lease fencing token from the claimed job
// (ClaimedJob.LeaseID). It is required: the API answers a heartbeat without
// it with 422 VALIDATION_ERROR, and one that does not match the job's
// current lease with 409. It is a pointer only for compatibility; always
// set it.
LeaseID *string `json:"lease_id,omitempty"`
}
HeartbeatRequest is the request for a job heartbeat.
type InboundDeliveryStatus ¶ added in v1.5.0
type InboundDeliveryStatus string
InboundDeliveryStatus says what an accepted inbound webhook request did.
It is a string type: a status the API adds later decodes as its name.
const ( // InboundDeliveryCreated: the request created a new job. InboundDeliveryCreated InboundDeliveryStatus = "created" // InboundDeliveryDuplicate: the request's idempotency key matched an // existing job, so no job was created. InboundDeliveryDuplicate InboundDeliveryStatus = "duplicate" )
type InboundWebhookDelivery ¶ added in v1.5.0
type InboundWebhookDelivery struct {
ID string `json:"id"`
Provider string `json:"provider"`
EventType string `json:"event_type"`
// MatchedQueue is the queue the job went to.
MatchedQueue *string `json:"matched_queue,omitempty"`
// JobID is the job the request created or matched. Nil for entries
// recorded before API 0.1.122.
JobID *string `json:"job_id,omitempty"`
// Status is InboundDeliveryCreated or InboundDeliveryDuplicate. Nil for
// entries recorded before API 0.1.122.
Status *InboundDeliveryStatus `json:"status,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
InboundWebhookDelivery is one accepted request to POST /webhooks/{org_id}/custom, as the inbound webhook log lists it. The log keeps neither the request payload nor any signature.
type IngestResource ¶
type IngestResource struct {
// contains filtered or unexported fields
}
IngestResource provides access to webhook ingestion operations.
func NewIngestResource ¶
func NewIngestResource(transport *httpx.Transport) *IngestResource
NewIngestResource creates a new IngestResource.
func (*IngestResource) Custom ¶
func (r *IngestResource) Custom(ctx context.Context, orgID string, req *CustomWebhookRequest) (*CustomWebhookResponse, error)
Custom ingests a custom webhook for an organization, authenticating with req.WebhookToken (the X-Webhook-Token header).
POST /webhooks/{org_id}/custom returns {job_id, queue_name, status}. An older empty 200 maps to a zero response rather than an error. Without a token it returns ErrWebhookTokenRequired and makes no request: the API rejects an unauthenticated ingest with 401 unconditionally.
func (*IngestResource) CustomWithToken ¶
func (r *IngestResource) CustomWithToken(ctx context.Context, orgID, webhookToken string, req *CustomWebhookRequest) (*CustomWebhookResponse, error)
CustomWithToken ingests a custom webhook using a webhook token via the X-Webhook-Token header.
func (*IngestResource) GitHub
deprecated
func (r *IngestResource) GitHub(_ context.Context, _ string, _ []byte, _ *GitHubIngestOptions) error
GitHub always returns an UnsupportedError and makes no request.
Deprecated: the API serves only POST /webhooks/{org_id}/custom. Its GitHub and Stripe handlers were removed server side, so this call used to get a 404 every time. Forward GitHub events to Custom/CustomWithToken (the JSON body goes in Payload), or enqueue the job yourself with Jobs().Create.
func (*IngestResource) ListDeliveries ¶ added in v1.5.0
func (r *IngestResource) ListDeliveries(ctx context.Context, params *ListInboundDeliveriesParams) ([]InboundWebhookDelivery, error)
ListDeliveries returns the inbound webhook log (GET /webhooks/deliveries): the requests to POST /webhooks/{org_id}/custom the API accepted, newest first. The log is organization-wide, so an API key restricted to some queues is refused (403).
func (*IngestResource) Stripe
deprecated
func (r *IngestResource) Stripe(_ context.Context, _ string, _ []byte, _ *StripeIngestOptions) error
Stripe always returns an UnsupportedError and makes no request.
Deprecated: the API serves only POST /webhooks/{org_id}/custom (Stripe billing events are handled internally at /billing/webhook). Forward the event to Custom/CustomWithToken or enqueue the job yourself with Jobs().Create.
type Job ¶
type Job struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
QueueName string `json:"queue_name"`
Status JobStatus `json:"status"`
// Payload/Result/Tags are JSON values (object, array, string, bool, …).
Payload any `json:"payload"`
Result any `json:"result,omitempty"`
// JobType is payload.job_type on list summaries; GET /jobs/{id} has no
// column and UnmarshalJSON copies it from payload when present.
JobType string `json:"job_type,omitempty"`
RetryCount int `json:"retry_count"`
MaxRetries int `json:"max_retries"`
LastError *string `json:"last_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
Priority int `json:"priority"`
Tags any `json:"tags,omitempty"`
TimeoutSeconds int `json:"timeout_seconds"`
ParentJobID *string `json:"parent_job_id,omitempty"`
CompletionWebhook *string `json:"completion_webhook,omitempty"`
AssignedWorkerID *string `json:"assigned_worker_id,omitempty"`
LeaseID *string `json:"lease_id,omitempty"`
LeaseExpiresAt *time.Time `json:"lease_expires_at,omitempty"`
IdempotencyKey *string `json:"idempotency_key,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
WorkflowID *string `json:"workflow_id,omitempty"`
DependencyMode *string `json:"dependency_mode,omitempty"`
DependenciesMet *bool `json:"dependencies_met,omitempty"`
}
Job represents a full job object.
func (*Job) UnmarshalJSON ¶ added in v1.3.0
UnmarshalJSON maps list/DLQ summaries that send "attempt" onto RetryCount. GET /jobs/{id} still sends "retry_count".
type JobHistoryEvent ¶ added in v1.5.0
type JobHistoryEvent struct {
ID string `json:"id"`
JobID string `json:"job_id"`
// EventType names the event, such as "created", "claimed", "completed" or
// "failed". Compare it as a string: the API can add event types.
EventType string `json:"event_type"`
// WorkerID is the worker involved, when there was one.
WorkerID *string `json:"worker_id,omitempty"`
// Details is the event's JSON details (any JSON value).
Details any `json:"details,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
JobHistoryEvent is one recorded lifecycle event of a job.
type JobHistoryPage ¶ added in v1.5.0
type JobHistoryPage struct {
Events []JobHistoryEvent
// HasMore is the API's X-Has-More header: true when more events follow.
HasMore bool
}
JobHistoryPage is one page of a job's history.
type JobHistoryParams ¶ added in v1.5.0
type JobHistoryParams struct {
// Order is "asc" (default, oldest event first) or "desc" (newest first).
Order *string `json:"order_dir,omitempty"`
// Limit is the page size, 1-500 (API default 100).
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
JobHistoryParams are parameters for reading a job's history.
type JobMetrics ¶
type JobMetrics struct {
TotalCreated int64 `json:"total_created"`
TotalCompleted int64 `json:"total_completed"`
TotalFailed int64 `json:"total_failed"`
AvgWaitTimeMs float64 `json:"avg_wait_time_ms"`
AvgProcessingMs float64 `json:"avg_processing_ms"`
}
JobMetrics contains job-related metrics.
type JobStats ¶
type JobStats struct {
Pending int `json:"pending"`
Scheduled int `json:"scheduled"`
Processing int `json:"processing"`
Completed int `json:"completed"`
Failed int `json:"failed"`
Deadletter int `json:"deadletter"`
Cancelled int `json:"cancelled"`
Total int `json:"total"`
}
JobStats represents job statistics.
type JobStatus ¶
type JobStatus string
JobStatus represents the status of a job.
const ( JobStatusPending JobStatus = "pending" JobStatusScheduled JobStatus = "scheduled" JobStatusProcessing JobStatus = "processing" JobStatusCompleted JobStatus = "completed" JobStatusFailed JobStatus = "failed" JobStatusDeadletter JobStatus = "deadletter" JobStatusCancelled JobStatus = "cancelled" )
type JobSummaryStats ¶
type JobSummaryStats struct {
Total int `json:"total"`
Pending int `json:"pending"`
Processing int `json:"processing"`
Completed24h int `json:"completed_24h"`
Failed24h int `json:"failed_24h"`
Deadletter int `json:"deadletter"`
AvgWaitTimeMs *float64 `json:"avg_wait_time_ms,omitempty"`
AvgProcessingTimeMs *float64 `json:"avg_processing_time_ms,omitempty"`
}
JobSummaryStats contains job statistics for the dashboard.
type JobWithDependencies ¶
type JobWithDependencies struct {
JobID string `json:"job_id"`
Dependencies []DependencyInfo `json:"dependencies"`
Dependents []DependencyInfo `json:"dependents"`
DependenciesMet bool `json:"dependencies_met"`
}
JobWithDependencies is GET /jobs/{id}/dependencies.
type JobsPage ¶ added in v1.5.0
type JobsPage struct {
Jobs []Job
// HasMore is the API's X-Has-More header: true when this page is full and
// at least one more job matches. Ask for the next page with Offset
// advanced by len(Jobs).
HasMore bool
}
JobsPage is one page of a job list.
type JobsResource ¶
type JobsResource struct {
// contains filtered or unexported fields
}
JobsResource provides access to job operations.
func NewJobsResource ¶
func NewJobsResource(transport *httpx.Transport) *JobsResource
NewJobsResource creates a new JobsResource.
func (*JobsResource) BatchStatus ¶
func (r *JobsResource) BatchStatus(ctx context.Context, ids []string) ([]BatchJobStatus, error)
BatchStatus retrieves the status of multiple jobs.
func (*JobsResource) BoostPriority ¶
func (r *JobsResource) BoostPriority(ctx context.Context, id string, req *BoostPriorityRequest) (*BoostPriorityResponse, error)
BoostPriority boosts a job's priority.
func (*JobsResource) BulkEnqueue ¶
func (r *JobsResource) BulkEnqueue(ctx context.Context, req *BulkEnqueueRequest) (*BulkEnqueueResponse, error)
BulkEnqueue bulk enqueues multiple jobs.
func (*JobsResource) Cancel ¶
func (r *JobsResource) Cancel(ctx context.Context, id string) error
Cancel cancels a job.
func (*JobsResource) Claim ¶
func (r *JobsResource) Claim(ctx context.Context, req *ClaimJobsRequest) (*ClaimJobsResponse, error)
Claim claims jobs for a worker.
func (*JobsResource) Complete ¶
func (r *JobsResource) Complete(ctx context.Context, id string, req *CompleteJobRequest) error
Complete marks a job as completed. The call is retried on transient failures (see Base.PostAck): it is lease-fenced, so a repeat cannot complete twice.
func (*JobsResource) Create ¶
func (r *JobsResource) Create(ctx context.Context, req *CreateJobRequest) (*CreateJobResponse, error)
Create creates a new job.
func (*JobsResource) CreateAndGet ¶
func (r *JobsResource) CreateAndGet(ctx context.Context, req *CreateJobRequest) (*Job, error)
CreateAndGet creates a new job and returns the full job object.
func (*JobsResource) DLQ ¶
func (r *JobsResource) DLQ() *DLQResource
DLQ returns the Dead Letter Queue resource.
func (*JobsResource) Fail ¶
func (r *JobsResource) Fail(ctx context.Context, id string, req *FailJobRequest) error
Fail marks a job as failed.
func (*JobsResource) FailWithResponse ¶ added in v1.0.20
func (r *JobsResource) FailWithResponse(ctx context.Context, id string, req *FailJobRequest) (*FailJobResponse, error)
FailWithResponse marks a job as failed and returns the backend's retry disposition when available.
The error text is passed through CoerceFailureMessage so the API cannot reject it, and the call is retried on transient failures like Complete.
func (*JobsResource) GetStats ¶
func (r *JobsResource) GetStats(ctx context.Context) (*JobStats, error)
GetStats retrieves job statistics.
func (*JobsResource) Heartbeat ¶
func (r *JobsResource) Heartbeat(ctx context.Context, id string, req *HeartbeatRequest) error
Heartbeat sends a heartbeat for a job to extend its lease. It is retried on transient failures (see Base.PostAck).
func (*JobsResource) History ¶ added in v1.5.0
func (r *JobsResource) History(ctx context.Context, id string, params *JobHistoryParams) (*JobHistoryPage, error)
History returns a job's recorded lifecycle events (GET /jobs/{id}/history), oldest first unless params.Order is "desc". Another organization's job, or one outside an API key's queue scope, is a NotFoundError.
func (*JobsResource) List ¶
func (r *JobsResource) List(ctx context.Context, params *ListJobsParams) ([]Job, error)
List retrieves a list of jobs. ListPage also reports whether more follow.
func (*JobsResource) ListPage ¶ added in v1.5.0
func (r *JobsResource) ListPage(ctx context.Context, params *ListJobsParams) (*JobsPage, error)
ListPage retrieves one page of jobs together with the X-Has-More hint.
func (*JobsResource) RenewLease ¶
func (r *JobsResource) RenewLease(ctx context.Context, id string, req *RenewLeaseRequest) (*RenewLeaseResponse, error)
RenewLease extends the lease on a job.
func (*JobsResource) UpdateProgress
deprecated
func (r *JobsResource) UpdateProgress(_ context.Context, _ string, _ *UpdateProgressRequest) error
UpdateProgress always returns an UnsupportedError and makes no request.
Deprecated: the Spooled API has no job progress route (POST /jobs/{id}/progress was answered with 404 every time). Put progress in the job result, or log it from the handler with JobContext.Log.
type ListDLQParams ¶
type ListDLQParams struct {
QueueName *string `json:"queue_name,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
// Tag keeps jobs with this tag.
Tag *string `json:"tag,omitempty"`
// Q is the same search as ListJobsParams.Q.
Q *string `json:"q,omitempty"`
// JobType keeps jobs whose payload job_type is exactly this value.
JobType *string `json:"job_type,omitempty"`
// CreatedAfter keeps jobs created at or after this instant.
CreatedAfter *time.Time `json:"created_after,omitempty"`
// CreatedBefore keeps jobs created before this instant.
CreatedBefore *time.Time `json:"created_before,omitempty"`
}
ListDLQParams are parameters for listing DLQ jobs. The filters work as on ListJobsParams.
type ListDeliveriesParams ¶
type ListDeliveriesParams struct {
Status *WebhookDeliveryStatus `json:"status,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
ListDeliveriesParams are parameters for listing webhook deliveries.
GET /outgoing-webhooks/{id}/deliveries takes no query parameters: it always returns the newest 100 deliveries. Status, Offset and Limit are applied client-side to that list (they used to be sent and ignored).
type ListInboundDeliveriesParams ¶ added in v1.5.0
type ListInboundDeliveriesParams struct {
// Status keeps entries with this status. An unknown value is a 400.
Status *InboundDeliveryStatus `json:"status,omitempty"`
// Since keeps entries received at or after this instant.
Since *time.Time `json:"since,omitempty"`
// QueueName keeps entries whose job went to this queue.
QueueName *string `json:"queue_name,omitempty"`
// Limit is the page size, 1-100 (API default 50).
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
ListInboundDeliveriesParams are parameters for Ingest().ListDeliveries.
type ListJobsParams ¶
type ListJobsParams struct {
QueueName *string `json:"queue_name,omitempty"`
// Status filters by one status. Statuses filters by several; when both are
// set the job may have any of them.
Status *JobStatus `json:"status,omitempty"`
Tag *string `json:"tag,omitempty"` // Filter by a single tag
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
// Statuses keeps jobs in any of these statuses. It is sent as one
// comma-separated status parameter (status=failed,deadletter).
Statuses []JobStatus `json:"statuses,omitempty"`
// Q is a case-insensitive search: a job matches when its ID starts with
// it, or its queue name or payload job_type contains it. Payloads are not
// searched.
Q *string `json:"q,omitempty"`
// JobType keeps jobs whose payload job_type is exactly this value.
JobType *string `json:"job_type,omitempty"`
// CreatedAfter keeps jobs created at or after this instant.
CreatedAfter *time.Time `json:"created_after,omitempty"`
// CreatedBefore keeps jobs created before this instant.
CreatedBefore *time.Time `json:"created_before,omitempty"`
// OrderBy is the sort column: created_at (default), updated_at,
// scheduled_at, completed_at, priority, status, queue_name or retry_count.
OrderBy *string `json:"order_by,omitempty"`
// OrderDir is "desc" (default) or "asc".
OrderDir *string `json:"order_dir,omitempty"`
}
ListJobsParams are parameters for listing jobs.
Filters combine with AND. The API answers an invalid filter (an unknown status, OrderBy or OrderDir, or CreatedAfter not earlier than CreatedBefore) with a 400 ValidationError rather than ignoring it.
type ListOrganizationsParams ¶
type ListOrganizationsParams struct {
PlanTier *PlanTier `json:"plan_tier,omitempty"`
Search *string `json:"search,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
ListOrganizationsParams are parameters for admin listing organizations.
type ListSchedulesParams ¶
type ListSchedulesParams struct {
QueueName *string `json:"queue_name,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
ListSchedulesParams are parameters for listing schedules.
GET /schedules honors only `limit` (default 100, max 500) and returns the newest schedules first. It ignores queue_name, is_active and offset, which this SDK used to send anyway, so a filtered or paged call silently returned every schedule (an Offset loop read the same first page forever). QueueName, IsActive and Offset are therefore applied client-side, to the newest 500 schedules the API returns.
type ListWorkflowsParams ¶
type ListWorkflowsParams struct {
Status *WorkflowStatus `json:"status,omitempty"`
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
}
ListWorkflowsParams are parameters for listing workflows.
type LoginRequest ¶
type LoginRequest struct {
APIKey string `json:"api_key"`
}
LoginRequest is the request to login with an API key.
type LoginResponse ¶
type LoginResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshExpiresIn int `json:"refresh_expires_in"`
}
LoginResponse is the response from logging in.
type LogoutRequest ¶ added in v1.3.0
type LogoutRequest struct {
RefreshToken string `json:"refresh_token,omitempty"`
}
LogoutRequest is POST /auth/logout. refresh_token must be in the body or /auth/refresh still mints a new pair after the access token is blacklisted.
type MeResponse ¶
type MeResponse struct {
OrganizationID string `json:"organization_id"`
APIKeyID string `json:"api_key_id"`
Queues []string `json:"queues"`
IssuedAt time.Time `json:"issued_at"`
ExpiresAt time.Time `json:"expires_at"`
}
MeResponse is the response from the /auth/me endpoint.
type Metrics ¶
type Metrics struct {
Jobs JobMetrics `json:"jobs"`
Workers WorkerMetrics `json:"workers"`
Queues QueueMetrics `json:"queues"`
System SystemMetrics `json:"system"`
}
Metrics represents system metrics.
type MetricsResource ¶
type MetricsResource struct {
// contains filtered or unexported fields
}
MetricsResource provides access to metrics operations.
func NewMetricsResource ¶
func NewMetricsResource(transport *httpx.Transport) *MetricsResource
NewMetricsResource creates a new MetricsResource.
func (*MetricsResource) Get ¶
func (r *MetricsResource) Get(ctx context.Context) (string, error)
Get retrieves Prometheus text from GET /metrics (not under /api/v1).
func (*MetricsResource) Prometheus ¶
func (r *MetricsResource) Prometheus(ctx context.Context) (string, error)
Prometheus is GET /metrics. There is no /api/v1/metrics/prometheus route.
type Organization ¶
type Organization struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
PlanTier PlanTier `json:"plan_tier"`
BillingEmail *string `json:"billing_email,omitempty"`
Settings map[string]any `json:"settings"`
CustomLimits map[string]any `json:"custom_limits,omitempty"`
StripeCustomerID *string `json:"stripe_customer_id,omitempty"`
StripeSubscriptionID *string `json:"stripe_subscription_id,omitempty"`
StripeSubscriptionStatus *string `json:"stripe_subscription_status,omitempty"`
StripeCurrentPeriodEnd *time.Time `json:"stripe_current_period_end,omitempty"`
StripeCancelAtPeriodEnd *bool `json:"stripe_cancel_at_period_end,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Organization represents an organization.
type OrganizationMember ¶
type OrganizationMember struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Email string `json:"email"`
Name string `json:"name"`
Role string `json:"role"`
JoinedAt time.Time `json:"joined_at"`
InvitedBy *string `json:"invited_by,omitempty"`
}
OrganizationMember represents a member of an organization.
type OrganizationsResource ¶
type OrganizationsResource struct {
// contains filtered or unexported fields
}
OrganizationsResource provides access to organization operations.
func NewOrganizationsResource ¶
func NewOrganizationsResource(transport *httpx.Transport) *OrganizationsResource
NewOrganizationsResource creates a new OrganizationsResource.
func (*OrganizationsResource) CheckSlug ¶
func (r *OrganizationsResource) CheckSlug(ctx context.Context, slug string) (*CheckSlugResponse, error)
CheckSlug checks if a slug is available (GET /organizations/check-slug?slug=).
func (*OrganizationsResource) ClearWebhookToken
deprecated
func (r *OrganizationsResource) ClearWebhookToken(_ context.Context, _ string) error
ClearWebhookToken always returns an UnsupportedError and makes no request.
Deprecated: the API refuses to clear the webhook token (POST /organizations/webhook-token/clear answers 422 every time) because an unauthenticated ingestion endpoint is unsafe in a multi-tenant service. Use RegenerateWebhookToken to rotate it. id is unused.
func (*OrganizationsResource) Create ¶
func (r *OrganizationsResource) Create(ctx context.Context, req *CreateOrganizationRequest) (*CreateOrganizationResponse, error)
Create creates a new organization.
func (*OrganizationsResource) Delete ¶
func (r *OrganizationsResource) Delete(ctx context.Context, id string) error
Delete deletes an organization.
func (*OrganizationsResource) GenerateSlug ¶
func (r *OrganizationsResource) GenerateSlug(ctx context.Context, name string) (*GenerateSlugResponse, error)
GenerateSlug generates a slug from a name.
func (*OrganizationsResource) Get ¶
func (r *OrganizationsResource) Get(ctx context.Context, id string) (*Organization, error)
Get retrieves a specific organization.
func (*OrganizationsResource) GetWebhookToken ¶
func (r *OrganizationsResource) GetWebhookToken(ctx context.Context, id string) (*WebhookTokenResponse, error)
GetWebhookToken retrieves the webhook token for the authenticated organization. id is unused; the backend route is GET /organizations/webhook-token (org from the API key), not /organizations/{id}/webhook-token.
func (*OrganizationsResource) List ¶
func (r *OrganizationsResource) List(ctx context.Context) ([]Organization, error)
List retrieves all organizations for the current user.
func (*OrganizationsResource) Members ¶
func (r *OrganizationsResource) Members(ctx context.Context, id string) ([]OrganizationMember, error)
Members retrieves members of an organization.
func (*OrganizationsResource) RegenerateWebhookToken ¶
func (r *OrganizationsResource) RegenerateWebhookToken(ctx context.Context, id string) (*WebhookTokenResponse, error)
RegenerateWebhookToken regenerates the webhook token for the authenticated organization. id is unused; the backend route is POST /organizations/webhook-token/regenerate.
func (*OrganizationsResource) Update ¶
func (r *OrganizationsResource) Update(ctx context.Context, id string, req *UpdateOrganizationRequest) (*Organization, error)
Update updates an organization.
type OutgoingWebhook ¶
type OutgoingWebhook struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
URL string `json:"url"`
Events []WebhookEvent `json:"events"`
// Format is the delivery body: json (the default), slack, discord or
// teams. Empty from servers older than 0.1.122, which only send JSON.
Format WebhookFormat `json:"format,omitempty"`
// Enabled turns false on its own after 20 consecutive failed deliveries:
// the server auto-disables the webhook and it stops receiving events.
// Re-enable it with Update and Enabled set to true - that counts against
// the plan webhook cap, so it can fail with 429 QUOTA_EXCEEDED.
Enabled bool `json:"enabled"`
// FailureCount counts consecutive failed deliveries, one per delivery
// rather than one per retry attempt, so it is roughly five times smaller
// than a per-attempt count for the same real-world failures. A successful
// delivery resets it to 0, including a successful manual RetryDelivery.
FailureCount int `json:"failure_count"`
LastTriggeredAt *time.Time `json:"last_triggered_at,omitempty"`
// LastStatus is "success", "failed" or "auto_disabled". The last of those
// means the webhook hit 20 consecutive failed deliveries and was disabled.
LastStatus *string `json:"last_status,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
OutgoingWebhook represents an outgoing webhook configuration.
type OutgoingWebhookDelivery ¶
type OutgoingWebhookDelivery struct {
ID string `json:"id"`
WebhookID string `json:"webhook_id"`
Event WebhookEvent `json:"event"`
Payload map[string]any `json:"payload"`
Status WebhookDeliveryStatus `json:"status"`
StatusCode *int `json:"status_code,omitempty"`
ResponseBody *string `json:"response_body,omitempty"`
Error *string `json:"error,omitempty"`
Attempts int `json:"attempts"`
CreatedAt time.Time `json:"created_at"`
DeliveredAt *time.Time `json:"delivered_at,omitempty"`
}
OutgoingWebhookDelivery represents a webhook delivery attempt.
type PauseQueueRequest ¶
type PauseQueueRequest struct {
Reason *string `json:"reason,omitempty"`
}
PauseQueueRequest is the request to pause a queue.
type PauseQueueResponse ¶
type PauseQueueResponse struct {
QueueName string `json:"queue_name"`
Paused bool `json:"paused"`
PausedAt time.Time `json:"paused_at"`
Reason *string `json:"reason,omitempty"`
}
PauseQueueResponse is the response from pausing a queue.
type PlanInfo ¶
type PlanInfo struct {
Tier PlanTier `json:"tier"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Limits PlanLimits `json:"limits"`
Price *PlanPrice `json:"price,omitempty"`
}
PlanInfo contains information about a subscription plan.
type PlanLimits ¶
type PlanLimits struct {
Tier string `json:"tier"`
DisplayName string `json:"display_name"`
MaxJobsPerDay *int `json:"max_jobs_per_day,omitempty"`
MaxActiveJobs *int `json:"max_active_jobs,omitempty"`
MaxQueues *int `json:"max_queues,omitempty"`
MaxWorkers *int `json:"max_workers,omitempty"`
MaxAPIKeys *int `json:"max_api_keys,omitempty"`
MaxSchedules *int `json:"max_schedules,omitempty"`
MaxWorkflows *int `json:"max_workflows,omitempty"`
MaxWebhooks *int `json:"max_webhooks,omitempty"`
MaxPayloadSizeBytes int `json:"max_payload_size_bytes"`
RateLimitRequestsPerSecond int `json:"rate_limit_requests_per_second"`
RateLimitBurst int `json:"rate_limit_burst"`
JobRetentionDays int `json:"job_retention_days"`
HistoryRetentionDays int `json:"history_retention_days"`
}
PlanLimits represents the limits for a plan.
type PlanPrice ¶
type PlanPrice struct {
MonthlyUSD int `json:"monthly_usd"`
YearlyUSD int `json:"yearly_usd"`
Currency string `json:"currency"`
}
PlanPrice represents pricing information for a plan.
type PurgeDLQRequest ¶
type PurgeDLQRequest struct {
QueueName *string `json:"queue_name,omitempty"`
// OlderThan purges only jobs created before this time.
OlderThan *time.Time `json:"older_than,omitempty"`
// Limit caps how many jobs one call purges (API default and max: 10000).
Limit *int `json:"limit,omitempty"`
// Confirm must be true: the API rejects a purge without it. Purge sets it,
// since calling Purge is the confirmation.
Confirm bool `json:"confirm"`
}
PurgeDLQRequest is the request to purge DLQ jobs.
type PurgeDLQResponse ¶
type PurgeDLQResponse struct {
PurgedCount int `json:"purged_count"`
}
PurgeDLQResponse is the response from purging DLQ jobs.
type QueueConfig ¶
type QueueConfig struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
QueueName string `json:"queue_name"`
MaxRetries int `json:"max_retries"`
DefaultTimeout int `json:"default_timeout"`
RateLimit *int `json:"rate_limit,omitempty"`
Enabled bool `json:"enabled"`
Settings map[string]any `json:"settings"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
QueueConfig represents full queue configuration (from Get).
type QueueListItem ¶
type QueueListItem struct {
QueueName string `json:"queue_name"`
MaxRetries int `json:"max_retries"`
DefaultTimeout int `json:"default_timeout"`
RateLimit *int `json:"rate_limit,omitempty"`
Enabled bool `json:"enabled"`
}
QueueListItem represents a queue in list responses (simplified).
type QueueMetrics ¶
type QueueMetrics struct {
TotalQueues int `json:"total_queues"`
TotalPaused int `json:"total_paused"`
TotalPending int `json:"total_pending"`
TotalProcessing int `json:"total_processing"`
}
QueueMetrics contains queue-related metrics.
type QueueStats ¶
type QueueStats struct {
QueueName string `json:"queue_name"`
PendingJobs int `json:"pending_jobs"`
ProcessingJobs int `json:"processing_jobs"`
CompletedJobs24h int `json:"completed_jobs_24h"`
FailedJobs24h int `json:"failed_jobs_24h"`
// AvgProcessingTimeMs is fractional (the API averages in floating point,
// e.g. 1523.456); decoding it into an int failed the whole response.
AvgProcessingTimeMs *float64 `json:"avg_processing_time_ms,omitempty"`
MaxJobAgeSeconds *int `json:"max_job_age_seconds,omitempty"`
ActiveWorkers int `json:"active_workers"`
}
QueueStats represents queue statistics.
type QueueSummary ¶
type QueueSummary struct {
Name string `json:"name"`
Pending int `json:"pending"`
Processing int `json:"processing"`
Paused bool `json:"paused"`
}
QueueSummary is a queue summary for the dashboard.
type QueuesResource ¶
type QueuesResource struct {
// contains filtered or unexported fields
}
QueuesResource provides access to queue operations.
func NewQueuesResource ¶
func NewQueuesResource(transport *httpx.Transport) *QueuesResource
NewQueuesResource creates a new QueuesResource.
func (*QueuesResource) Delete ¶
func (r *QueuesResource) Delete(ctx context.Context, name string) error
Delete deletes a queue configuration.
func (*QueuesResource) Get ¶
func (r *QueuesResource) Get(ctx context.Context, name string) (*QueueConfig, error)
Get retrieves a specific queue configuration.
func (*QueuesResource) GetStats ¶
func (r *QueuesResource) GetStats(ctx context.Context, name string) (*QueueStats, error)
GetStats retrieves statistics for a queue.
func (*QueuesResource) List ¶
func (r *QueuesResource) List(ctx context.Context) ([]QueueListItem, error)
List retrieves all queue configurations.
func (*QueuesResource) Pause ¶
func (r *QueuesResource) Pause(ctx context.Context, name string, req *PauseQueueRequest) (*PauseQueueResponse, error)
Pause pauses a queue.
func (*QueuesResource) Resume ¶
func (r *QueuesResource) Resume(ctx context.Context, name string) (*ResumeQueueResponse, error)
Resume resumes a paused queue.
func (*QueuesResource) UpdateConfig ¶
func (r *QueuesResource) UpdateConfig(ctx context.Context, name string, req *UpdateQueueConfigRequest) (*QueueConfig, error)
UpdateConfig updates a queue's configuration.
PUT /queues/{name}/config — PUT /queues/{name} is 405 (that path is GET/DELETE only).
type RecentActivity ¶
type RecentActivity struct {
JobsCreated1h int `json:"jobs_created_1h"`
JobsCompleted1h int `json:"jobs_completed_1h"`
JobsFailed1h int `json:"jobs_failed_1h"`
}
RecentActivity contains recent activity information.
type RefreshRequest ¶
type RefreshRequest struct {
RefreshToken string `json:"refresh_token"`
}
RefreshRequest is the request to refresh a token.
type RefreshResponse ¶
type RefreshResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
}
RefreshResponse is the response from refreshing a token.
type RegisterWorkerRequest ¶
type RegisterWorkerRequest struct {
// WorkerID is an optional stable worker identity: 1-128 characters from
// [A-Za-z0-9._-]. Supplying the same value across restarts makes
// registration an upsert, so the process reuses one worker row. Leave it
// nil and the server mints a UUID instead, which means every restart
// leaves the previous row counting against the plan worker cap until the
// stale-worker reaper clears it (roughly two minutes) - enough for a
// crash-looping worker on a tight plan to 429 itself out of registering.
// Re-registering an ID this organization already owns is not charged
// against the cap; an ID owned by a different organization returns 409.
WorkerID *string `json:"worker_id,omitempty"`
QueueName string `json:"queue_name"`
Hostname string `json:"hostname"`
WorkerType *string `json:"worker_type,omitempty"`
MaxConcurrency *int `json:"max_concurrency,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Version *string `json:"version,omitempty"`
}
RegisterWorkerRequest is the request to register a worker.
type RegisterWorkerResponse ¶
type RegisterWorkerResponse struct {
ID string `json:"id"`
QueueName string `json:"queue_name"`
LeaseDurationSecs int `json:"lease_duration_secs"`
HeartbeatIntervalSec int `json:"heartbeat_interval_secs"`
}
RegisterWorkerResponse is the response from registering a worker.
type RenewLeaseRequest ¶
type RenewLeaseRequest struct {
WorkerID string `json:"worker_id"`
LeaseDurationSec int `json:"lease_duration_secs,omitempty"`
// LeaseID is the lease fencing token from the claimed job
// (ClaimedJob.LeaseID). It is required: RenewLease sends a job heartbeat,
// which the API answers with 422 VALIDATION_ERROR without it. It is a
// pointer only for compatibility; always set it.
LeaseID *string `json:"lease_id,omitempty"`
}
RenewLeaseRequest is the request to renew a job's lease.
type RenewLeaseResponse ¶
type RenewLeaseResponse struct {
Success bool `json:"success"`
LeaseExpiresAt *time.Time `json:"lease_expires_at,omitempty"`
}
RenewLeaseResponse is the response from renewing a lease.
type ResourceUsage ¶
type ResourceUsage struct {
JobsToday UsageItem `json:"jobs_today"`
ActiveJobs UsageItem `json:"active_jobs"`
Queues UsageItem `json:"queues"`
Workers UsageItem `json:"workers"`
APIKeys UsageItem `json:"api_keys"`
Schedules UsageItem `json:"schedules"`
Workflows UsageItem `json:"workflows"`
Webhooks UsageItem `json:"webhooks"`
}
ResourceUsage represents current resource usage.
type ResumeQueueResponse ¶
type ResumeQueueResponse struct {
QueueName string `json:"queue_name"`
Resumed bool `json:"resumed"`
PausedDurationSecs int `json:"paused_duration_secs"`
}
ResumeQueueResponse is the response from resuming a queue.
type RetryDLQRequest ¶
type RetryDLQRequest struct {
QueueName *string `json:"queue_name,omitempty"`
JobIDs []string `json:"job_ids,omitempty"`
}
RetryDLQRequest is the request to retry DLQ jobs.
type RetryDLQResponse ¶
type RetryDLQResponse struct {
RetriedCount int `json:"retried_count"`
RetriedJobs []string `json:"retried_jobs,omitempty"`
}
RetryDLQResponse is the response from retrying DLQ jobs.
type RetryDeliveryResponse ¶
type RetryDeliveryResponse struct {
Success bool `json:"success"`
Message *string `json:"message,omitempty"`
Error *string `json:"error,omitempty"`
}
RetryDeliveryResponse is the response from retrying a webhook delivery.
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
CronExpression string `json:"cron_expression"`
Timezone string `json:"timezone"`
QueueName string `json:"queue_name"`
PayloadTemplate any `json:"payload_template"`
Priority int `json:"priority"`
MaxRetries int `json:"max_retries"`
TimeoutSeconds int `json:"timeout_seconds"`
IsActive bool `json:"is_active"`
LastRunAt *time.Time `json:"last_run_at,omitempty"`
NextRunAt *time.Time `json:"next_run_at,omitempty"`
RunCount int `json:"run_count"`
Tags any `json:"tags,omitempty"`
Metadata any `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Schedule represents a scheduled job.
type ScheduleRun ¶
type ScheduleRun struct {
ID string `json:"id"`
ScheduleID string `json:"schedule_id"`
JobID *string `json:"job_id,omitempty"`
Status ScheduleRunStatus `json:"status"`
ErrorMessage *string `json:"error_message,omitempty"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
ScheduleRun represents a schedule execution run.
type ScheduleRunStatus ¶
type ScheduleRunStatus string
ScheduleRunStatus represents the status of a schedule run.
const ( ScheduleRunStatusPending ScheduleRunStatus = "pending" ScheduleRunStatusRunning ScheduleRunStatus = "running" ScheduleRunStatusCompleted ScheduleRunStatus = "completed" ScheduleRunStatusFailed ScheduleRunStatus = "failed" )
type SchedulesResource ¶
type SchedulesResource struct {
// contains filtered or unexported fields
}
SchedulesResource provides access to schedule operations.
func NewSchedulesResource ¶
func NewSchedulesResource(transport *httpx.Transport) *SchedulesResource
NewSchedulesResource creates a new SchedulesResource.
func (*SchedulesResource) Create ¶
func (r *SchedulesResource) Create(ctx context.Context, req *CreateScheduleRequest) (*Schedule, error)
Create creates a new schedule.
func (*SchedulesResource) Delete ¶
func (r *SchedulesResource) Delete(ctx context.Context, id string) error
Delete deletes a schedule.
func (*SchedulesResource) History ¶
func (r *SchedulesResource) History(ctx context.Context, id string, limit *int) ([]ScheduleRun, error)
History retrieves the run history for a schedule.
func (*SchedulesResource) List ¶
func (r *SchedulesResource) List(ctx context.Context, params *ListSchedulesParams) ([]Schedule, error)
List retrieves schedules, newest first.
With no filter, Limit is sent to the API as is. With QueueName, IsActive or Offset the SDK fetches the largest page the API allows (500) and filters it locally, then applies Offset and Limit to the filtered list.
func (*SchedulesResource) Trigger ¶
func (r *SchedulesResource) Trigger(ctx context.Context, id string) (*TriggerScheduleResponse, error)
Trigger manually triggers a schedule.
func (*SchedulesResource) Update ¶
func (r *SchedulesResource) Update(ctx context.Context, id string, req *UpdateScheduleRequest) (*Schedule, error)
Update updates a schedule.
type StartEmailLoginRequest ¶
type StartEmailLoginRequest struct {
Email string `json:"email"`
}
StartEmailLoginRequest is the request to start email login.
type StartEmailLoginResponse ¶
type StartEmailLoginResponse struct {
Message string `json:"message"`
EmailSentTo string `json:"email_sent_to"`
}
StartEmailLoginResponse is POST /auth/email/start.
type StripeIngestOptions
deprecated
type StripeIngestOptions struct {
// Timestamp used for the signature payload.
Timestamp int64
// Signature is the Stripe-Signature header value.
Signature string
// Secret was used to compute the signature.
Secret string
// WebhookToken is sent as X-Webhook-Token.
WebhookToken string
// ForwardedProto is sent as X-Forwarded-Proto.
ForwardedProto string
}
StripeIngestOptions configures Stripe webhook ingestion.
Deprecated: the Spooled API has no Stripe ingestion route.
type SystemInfo ¶
type SystemInfo struct {
Version string `json:"version"`
UptimeSeconds int64 `json:"uptime_seconds"`
StartedAt string `json:"started_at"`
DatabaseStatus string `json:"database_status"`
CacheStatus string `json:"cache_status"`
Environment string `json:"environment"`
}
SystemInfo contains system information.
type SystemMetrics ¶
type SystemMetrics struct {
UptimeSeconds int64 `json:"uptime_seconds"`
RequestsPerSec float64 `json:"requests_per_sec"`
ErrorRate float64 `json:"error_rate"`
AvgLatencyMs float64 `json:"avg_latency_ms"`
}
SystemMetrics contains system-level metrics.
type TestWebhookResponse ¶
type TestWebhookResponse struct {
Success bool `json:"success"`
StatusCode *int `json:"status_code,omitempty"`
ResponseTimeMs int `json:"response_time_ms"`
Error *string `json:"error,omitempty"`
}
TestWebhookResponse is the response from testing a webhook.
type TriggerScheduleResponse ¶
type TriggerScheduleResponse struct {
JobID string `json:"job_id"`
TriggeredAt time.Time `json:"triggered_at"`
}
TriggerScheduleResponse is the response from triggering a schedule.
type UnsupportedError ¶ added in v1.5.0
type UnsupportedError struct {
// Operation names the SDK call, e.g. "Jobs.UpdateProgress".
Operation string
// Reason says what to do instead.
Reason string
}
UnsupportedError is returned by a deprecated SDK method that has no API route behind it. It matches ErrUnsupported with errors.Is.
func (*UnsupportedError) Error ¶ added in v1.5.0
func (e *UnsupportedError) Error() string
Error implements the error interface.
func (*UnsupportedError) Is ¶ added in v1.5.0
func (e *UnsupportedError) Is(target error) bool
Is reports a match for ErrUnsupported.
type UpdateAPIKeyRequest ¶
type UpdateAPIKeyRequest struct {
Name *string `json:"name,omitempty"`
Queues []string `json:"queues,omitempty"`
RateLimit *int `json:"rate_limit,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
UpdateAPIKeyRequest is the request to update an API key.
type UpdateOrganizationRequest ¶
type UpdateOrganizationRequest struct {
Name *string `json:"name,omitempty"`
BillingEmail *string `json:"billing_email,omitempty"`
Settings map[string]any `json:"settings,omitempty"`
}
UpdateOrganizationRequest is the request to update an organization.
type UpdateOutgoingWebhookRequest ¶
type UpdateOutgoingWebhookRequest struct {
Name *string `json:"name,omitempty"`
URL *string `json:"url,omitempty"`
Events *[]WebhookEvent `json:"events,omitempty"`
// Secret replaces the HMAC signing secret. Leave it nil to keep whatever
// secret the webhook already has.
Secret *string `json:"secret,omitempty"`
// ClearSecret sends an explicit null secret, which DELETES the signing
// secret: deliveries then go out unsigned, with no X-Spooled-Signature
// header for the receiver to verify. Nothing restores the old value, so
// set a new Secret to sign again. Setting Secret and ClearSecret together
// is an error.
ClearSecret bool `json:"-"`
// Enabled is how an auto-disabled webhook is brought back: send true after
// the server disabled it for 20 consecutive failed deliveries. The
// re-enable counts against the plan webhook cap and can fail with 429
// QUOTA_EXCEEDED.
Enabled *bool `json:"enabled,omitempty"`
// Format changes the delivery body (json, slack, discord or teams). Nil
// keeps the current format.
Format *WebhookFormat `json:"format,omitempty"`
}
UpdateOutgoingWebhookRequest is the request to update an outgoing webhook.
A nil field is left out of the request body and the server keeps the current value. The signing secret is the exception: it is three-state, so leaving Secret nil keeps it, setting Secret replaces it, and setting ClearSecret removes it.
func (UpdateOutgoingWebhookRequest) MarshalJSON ¶ added in v1.2.0
func (r UpdateOutgoingWebhookRequest) MarshalJSON() ([]byte, error)
MarshalJSON encodes the update request, turning ClearSecret into the explicit JSON null that removes the signing secret. Without it the secret field is omitted entirely, which is what keeps the current secret - a nil *string alone can never express "clear this".
type UpdateProgressRequest
deprecated
type UpdateQueueConfigRequest ¶
type UpdateQueueConfigRequest struct {
MaxRetries *int `json:"max_retries,omitempty"`
DefaultTimeout *int `json:"default_timeout,omitempty"`
RateLimit *int `json:"rate_limit,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
UpdateQueueConfigRequest is the request to update queue configuration.
type UpdateScheduleRequest ¶
type UpdateScheduleRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
CronExpression *string `json:"cron_expression,omitempty"`
Timezone *string `json:"timezone,omitempty"`
// QueueName is not part of the API's update request, so the server ignores
// it: a schedule's queue cannot be changed. Delete and recreate the schedule
// to move it to another queue.
//
// Deprecated: has no effect.
QueueName *string `json:"queue_name,omitempty"`
PayloadTemplate any `json:"payload_template,omitempty"`
Priority *int `json:"priority,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
Tags any `json:"tags,omitempty"`
Metadata any `json:"metadata,omitempty"`
}
UpdateScheduleRequest is the request to update a schedule.
type UsageInfo ¶
type UsageInfo struct {
Plan string `json:"plan"`
PlanDisplayName string `json:"plan_display_name"`
Limits PlanLimits `json:"limits"`
Usage ResourceUsage `json:"usage"`
Warnings []UsageWarning `json:"warnings,omitempty"`
}
UsageInfo represents organization usage information.
type UsageItem ¶
type UsageItem struct {
Current int `json:"current"`
Limit *int `json:"limit,omitempty"`
Percentage *float64 `json:"percentage,omitempty"`
IsDisabled bool `json:"is_disabled"`
}
UsageItem represents usage for a single resource type.
type UsageWarning ¶
type UsageWarning struct {
Resource string `json:"resource"`
Message string `json:"message"`
Severity string `json:"severity"`
}
UsageWarning represents a usage warning.
type ValidateRequest ¶
type ValidateRequest struct {
Token string `json:"token"`
}
ValidateRequest is the request to validate a token.
type ValidateResponse ¶
type ValidateResponse struct {
Valid bool `json:"valid"`
Error *string `json:"error,omitempty"`
OrganizationID *string `json:"organization_id,omitempty"`
APIKeyID *string `json:"api_key_id,omitempty"`
Queues []string `json:"queues,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
ValidateResponse is POST /auth/validate — `{ valid, error?, claims? }`.
Claims carry org_id, api_key_id, queues, exp. The API never sends top-level organization_id / expires_at.
func (*ValidateResponse) UnmarshalJSON ¶ added in v1.3.0
func (v *ValidateResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON maps claims.org_id / api_key_id / queues / exp onto the exported fields. A valid token otherwise unmarshals as empty IDs.
type VerifyEmailRequest ¶
VerifyEmailRequest is the request to verify an email login code.
type VerifyEmailResponse ¶
type VerifyEmailResponse struct {
Type string `json:"type"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
RefreshExpiresIn int `json:"refresh_expires_in,omitempty"`
SignupToken string `json:"signup_token,omitempty"`
Email string `json:"email,omitempty"`
}
VerifyEmailResponse is POST /auth/email/verify — tagged `{type: login|signup, ...}`.
Login sends access/refresh tokens. Signup (no account yet) sends signup_token and never access_token.
type WebhookDeliveryStatus ¶
type WebhookDeliveryStatus string
WebhookDeliveryStatus represents the status of a webhook delivery.
const ( WebhookDeliveryStatusPending WebhookDeliveryStatus = "pending" WebhookDeliveryStatusSuccess WebhookDeliveryStatus = "success" WebhookDeliveryStatusFailed WebhookDeliveryStatus = "failed" )
type WebhookEvent ¶
type WebhookEvent string
WebhookEvent represents a webhook event type.
It is a string type: an event the API adds later decodes as its name, so compare against the constants rather than switching exhaustively.
const ( WebhookEventJobCreated WebhookEvent = "job.created" WebhookEventJobStarted WebhookEvent = "job.started" WebhookEventJobCompleted WebhookEvent = "job.completed" WebhookEventJobFailed WebhookEvent = "job.failed" WebhookEventJobCancelled WebhookEvent = "job.cancelled" WebhookEventQueuePaused WebhookEvent = "queue.paused" WebhookEventQueueResumed WebhookEvent = "queue.resumed" WebhookEventWorkerRegistered WebhookEvent = "worker.registered" WebhookEventWorkerDeregistered WebhookEvent = "worker.deregistered" WebhookEventScheduleTriggered WebhookEvent = "schedule.triggered" // WebhookEventJobDeadlettered fires when a job moves to the dead-letter // queue (retries used up, or failed without retry). WebhookEventJobDeadlettered WebhookEvent = "job.deadlettered" // WebhookEventJobRetried fires when a failed, dead-lettered or cancelled // job is put back to pending by Jobs().Retry, a DLQ retry or a workflow // retry. WebhookEventJobRetried WebhookEvent = "job.retried" // WebhookEventWorkflowCompleted fires when every job of a workflow completed. WebhookEventWorkflowCompleted WebhookEvent = "workflow.completed" // WebhookEventWorkflowFailed fires when a workflow fails. WebhookEventWorkflowFailed WebhookEvent = "workflow.failed" )
type WebhookFormat ¶ added in v1.5.0
type WebhookFormat string
WebhookFormat is the body an outgoing webhook is delivered as.
It is a string type: a format the API adds later decodes as its name.
const ( // WebhookFormatJSON is the signed JSON envelope (id, event, created_at, // data). It is the default. WebhookFormatJSON WebhookFormat = "json" // WebhookFormatSlack posts {"text": ...} for a Slack incoming webhook URL. WebhookFormatSlack WebhookFormat = "slack" // WebhookFormatDiscord posts {"content": ...} for a Discord webhook URL. WebhookFormatDiscord WebhookFormat = "discord" // WebhookFormatTeams posts a MessageCard for a Microsoft Teams incoming // webhook URL. WebhookFormatTeams WebhookFormat = "teams" )
type WebhookTokenResponse ¶
type WebhookTokenResponse struct {
WebhookToken *string `json:"webhook_token,omitempty"`
WebhookURL *string `json:"webhook_url,omitempty"`
}
WebhookTokenResponse is the response for webhook token operations.
type WebhooksResource ¶
type WebhooksResource struct {
// contains filtered or unexported fields
}
WebhooksResource provides access to outgoing webhook operations.
func NewWebhooksResource ¶
func NewWebhooksResource(transport *httpx.Transport) *WebhooksResource
NewWebhooksResource creates a new WebhooksResource.
func (*WebhooksResource) Create ¶
func (r *WebhooksResource) Create(ctx context.Context, req *CreateOutgoingWebhookRequest) (*OutgoingWebhook, error)
Create creates a new outgoing webhook.
func (*WebhooksResource) Delete ¶
func (r *WebhooksResource) Delete(ctx context.Context, id string) error
Delete deletes an outgoing webhook.
func (*WebhooksResource) Deliveries ¶
func (r *WebhooksResource) Deliveries(ctx context.Context, id string, params *ListDeliveriesParams) ([]OutgoingWebhookDelivery, error)
Deliveries retrieves delivery attempts for a webhook, newest first.
This is not a durable audit log. Only the newest 100 deliveries per webhook are readable, and rows are removed by the per-organization retention sweep once they pass the plan's history retention window: 1 day on free, 7 on starter, 30 on pro, 90 on enterprise. Copy anything you need to keep longer.
func (*WebhooksResource) Get ¶
func (r *WebhooksResource) Get(ctx context.Context, id string) (*OutgoingWebhook, error)
Get retrieves a specific outgoing webhook.
func (*WebhooksResource) List ¶
func (r *WebhooksResource) List(ctx context.Context) ([]OutgoingWebhook, error)
List retrieves all outgoing webhooks.
func (*WebhooksResource) RetryDelivery ¶
func (r *WebhooksResource) RetryDelivery(ctx context.Context, webhookID, deliveryID string) (*RetryDeliveryResponse, error)
RetryDelivery retries a failed webhook delivery. A retry that succeeds resets the webhook's FailureCount to 0.
func (*WebhooksResource) Test ¶
func (r *WebhooksResource) Test(ctx context.Context, id string) (*TestWebhookResponse, error)
Test sends a test request to a webhook.
func (*WebhooksResource) Update ¶
func (r *WebhooksResource) Update(ctx context.Context, id string, req *UpdateOutgoingWebhookRequest) (*OutgoingWebhook, error)
Update updates an outgoing webhook.
Re-enabling an auto-disabled webhook (Enabled set to true) is charged against the plan webhook cap and can fail with 429 QUOTA_EXCEEDED.
type Worker ¶
type Worker struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
QueueName string `json:"queue_name"`
QueueNames []string `json:"queue_names,omitempty"`
Hostname string `json:"hostname"`
WorkerType *string `json:"worker_type,omitempty"`
MaxConcurrency int `json:"max_concurrency"`
CurrentJobs int `json:"current_jobs"`
Status WorkerStatus `json:"status"`
LastHeartbeat time.Time `json:"last_heartbeat"`
Metadata map[string]any `json:"metadata"`
Version *string `json:"version,omitempty"`
RegisteredAt time.Time `json:"registered_at"`
UpdatedAt time.Time `json:"updated_at"`
// JobsProcessed counts the jobs this worker completed (API 0.1.122 or
// later; 0 from older servers).
JobsProcessed int64 `json:"jobs_processed"`
// JobsFailed counts the failures this worker reported, each retry it
// scheduled or dead-letter it caused. Jobs released because a lease
// expired or the worker went offline are not counted.
JobsFailed int64 `json:"jobs_failed"`
}
Worker represents a worker.
type WorkerHeartbeatRequest ¶
type WorkerHeartbeatRequest struct {
CurrentJobs int `json:"current_jobs"`
Status *string `json:"status,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
WorkerHeartbeatRequest is the request for a worker heartbeat.
type WorkerMetrics ¶
type WorkerMetrics struct {
TotalRegistered int `json:"total_registered"`
TotalActive int `json:"total_active"`
TotalIdle int `json:"total_idle"`
}
WorkerMetrics contains worker-related metrics.
type WorkerStatus ¶
type WorkerStatus string
WorkerStatus represents the status of a worker.
const ( WorkerStatusHealthy WorkerStatus = "healthy" WorkerStatusDegraded WorkerStatus = "degraded" WorkerStatusOffline WorkerStatus = "offline" WorkerStatusDraining WorkerStatus = "draining" )
type WorkerSummary ¶ added in v1.1.0
type WorkerSummary struct {
ID string `json:"id"`
QueueName string `json:"queue_name"`
Hostname string `json:"hostname"`
Status WorkerStatus `json:"status"`
CurrentJobs int `json:"current_jobs"`
MaxConcurrency int `json:"max_concurrency"`
LastHeartbeat time.Time `json:"last_heartbeat"`
// JobsProcessed counts the jobs this worker completed (see Worker).
JobsProcessed int64 `json:"jobs_processed"`
// JobsFailed counts the failures this worker reported (see Worker).
JobsFailed int64 `json:"jobs_failed"`
}
WorkerSummary represents the summary payload returned by the worker list endpoint.
type WorkerSummaryInfo ¶
type WorkerSummaryInfo struct {
Total int `json:"total"`
Healthy int `json:"healthy"`
Unhealthy int `json:"unhealthy"`
}
WorkerSummaryInfo contains worker summary information.
type WorkersResource ¶
type WorkersResource struct {
// contains filtered or unexported fields
}
WorkersResource provides access to worker operations.
func NewWorkersResource ¶
func NewWorkersResource(transport *httpx.Transport) *WorkersResource
NewWorkersResource creates a new WorkersResource.
func (*WorkersResource) Deregister ¶
func (r *WorkersResource) Deregister(ctx context.Context, id string) error
Deregister removes a worker registration.
func (*WorkersResource) Heartbeat ¶
func (r *WorkersResource) Heartbeat(ctx context.Context, id string, req *WorkerHeartbeatRequest) error
Heartbeat sends a heartbeat for a worker. It is retried on transient failures (see Base.PostAck): a worker that misses heartbeats for two minutes is marked offline and its jobs are released.
func (*WorkersResource) ListSummaries ¶ added in v1.1.0
func (r *WorkersResource) ListSummaries(ctx context.Context) ([]WorkerSummary, error)
ListSummaries retrieves worker summaries.
func (*WorkersResource) Register ¶
func (r *WorkersResource) Register(ctx context.Context, req *RegisterWorkerRequest) (*RegisterWorkerResponse, error)
Register registers a new worker.
type Workflow ¶
type Workflow struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
Status WorkflowStatus `json:"status"`
TotalJobs int `json:"total_jobs"`
CompletedJobs int `json:"completed_jobs"`
FailedJobs int `json:"failed_jobs"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Workflow represents a workflow.
func (*Workflow) UnmarshalJSON ¶ added in v1.3.0
UnmarshalJSON maps GET /workflows/{id} progress counts onto TotalJobs. List/cancel/retry send top-level total_jobs; GET detail does not.
type WorkflowJob ¶
type WorkflowJob struct {
ID string `json:"id"`
// Key is the key the job was defined with. The API does not return it on
// workflow details, so it is empty when read through Jobs().ListJobs or
// Jobs().GetJob; fill it from the create response with
// CreateWorkflowResponse.ApplyKeys (or KeyByJobID).
Key string `json:"key,omitempty"`
QueueName string `json:"queue_name"`
Status JobStatus `json:"status"`
DependsOn []string `json:"depends_on,omitempty"`
DependencyMode *string `json:"dependency_mode,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
}
WorkflowJob represents a job within a workflow with dependencies info.
type WorkflowJobDefinition ¶
type WorkflowJobDefinition struct {
Key string `json:"key"`
QueueName string `json:"queue_name"`
Payload any `json:"payload"`
DependsOn []string `json:"depends_on,omitempty"`
DependencyMode *DependencyMode `json:"dependency_mode,omitempty"`
Priority *int `json:"priority,omitempty"`
MaxRetries *int `json:"max_retries,omitempty"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"`
}
WorkflowJobDefinition defines a job within a workflow.
Payload is `any`: `WorkflowJobDefinition.payload` on the API is `serde_json::Value`, so an array or scalar is a valid job payload.
type WorkflowJobMapping ¶
WorkflowJobMapping maps a workflow job key to its job ID.
type WorkflowJobStatus ¶
type WorkflowJobStatus struct {
// Key is empty unless the API returns job keys, which it currently does
// not; map JobID back to a key with CreateWorkflowResponse.KeyByJobID.
Key string `json:"key,omitempty"`
JobID string `json:"job_id"`
Status JobStatus `json:"status"`
DependsOn []string `json:"depends_on,omitempty"`
}
WorkflowJobStatus represents a job's status in a workflow.
type WorkflowJobStatusResponse ¶
type WorkflowJobStatusResponse struct {
Jobs []WorkflowJobStatus `json:"jobs"`
}
WorkflowJobStatus represents the status of jobs in a workflow.
type WorkflowJobsResource ¶
type WorkflowJobsResource struct {
// contains filtered or unexported fields
}
WorkflowJobsResource provides access to workflow job operations.
func (*WorkflowJobsResource) GetJob ¶
func (r *WorkflowJobsResource) GetJob(ctx context.Context, workflowID, jobID string) (*WorkflowJob, error)
GetJob retrieves a specific job in a workflow.
func (*WorkflowJobsResource) GetJobsStatus ¶
func (r *WorkflowJobsResource) GetJobsStatus(ctx context.Context, workflowID string) (*WorkflowJobStatusResponse, error)
GetJobsStatus retrieves the status of all jobs in a workflow.
func (*WorkflowJobsResource) ListJobs ¶
func (r *WorkflowJobsResource) ListJobs(ctx context.Context, workflowID string) ([]WorkflowJob, error)
ListJobs retrieves all jobs in a workflow.
The backend has no /workflows/{id}/jobs route; job rows live on GET /workflows/{id}. Those rows carry no job key, so Key is empty: see CreateWorkflowResponse.ApplyKeys.
type WorkflowStatus ¶
type WorkflowStatus string
WorkflowStatus represents the status of a workflow.
const ( WorkflowStatusPending WorkflowStatus = "pending" WorkflowStatusRunning WorkflowStatus = "running" WorkflowStatusCompleted WorkflowStatus = "completed" WorkflowStatusFailed WorkflowStatus = "failed" WorkflowStatusCancelled WorkflowStatus = "cancelled" )
type WorkflowsResource ¶
type WorkflowsResource struct {
// contains filtered or unexported fields
}
WorkflowsResource provides access to workflow operations.
func NewWorkflowsResource ¶
func NewWorkflowsResource(transport *httpx.Transport) *WorkflowsResource
NewWorkflowsResource creates a new WorkflowsResource.
func (*WorkflowsResource) AddJobDependencies ¶
func (r *WorkflowsResource) AddJobDependencies(ctx context.Context, jobID string, req *AddDependenciesRequest) (*AddDependenciesResponse, error)
AddJobDependencies adds dependencies to a job.
func (*WorkflowsResource) Cancel ¶
func (r *WorkflowsResource) Cancel(ctx context.Context, id string) error
Cancel cancels a workflow.
func (*WorkflowsResource) Create ¶
func (r *WorkflowsResource) Create(ctx context.Context, req *CreateWorkflowRequest) (*CreateWorkflowResponse, error)
Create creates a new workflow.
func (*WorkflowsResource) GetJobDependencies ¶
func (r *WorkflowsResource) GetJobDependencies(ctx context.Context, jobID string) (*JobWithDependencies, error)
GetJobDependencies retrieves dependencies for a job.
func (*WorkflowsResource) Jobs ¶
func (r *WorkflowsResource) Jobs() *WorkflowJobsResource
Jobs returns the workflow jobs sub-resource.
func (*WorkflowsResource) List ¶
func (r *WorkflowsResource) List(ctx context.Context, params *ListWorkflowsParams) ([]Workflow, error)
List retrieves all workflows.