infrastructure capa

infrastructure-jobs

Background task queue on PostgreSQL (SKIP LOCKED); Postgres-only per ADR 0022

Background task queue on PostgreSQL (SKIP LOCKED); Postgres-only per ADR 0022

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/jobs
Edition2021
Targetsinfrastructure_jobs, cancellation, failure, fence, lanes, lanes_pg, pg_job_attempts, reattach, resource_lease, schedule, stats, worker_runtime
Public items2 across 0 modules
Tests97

What it is for

Background task queue with pluggable backends.

PostgreSQL-only (ADR 0022 — the SQLite backend was removed): SKIP LOCKED provides reliable, distributed job processing.

# Features

# Example

use infrastructure_jobs::{Job, JobQueue, JobStore};

let store = JobQueue::new(pool);
let job = store.enqueue(tenant_id, "send_email", &payload).await?;

Capabilities

crate root

Background task queue with pluggable backends.

Item
pub const JOBS_SCHEMA_VERSION: u32
async fn ensure_schema(pool : & sqlx::PgPool) -> Result <(), sqlx::Error>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const JOBS_SCHEMA_VERSION: u32Schema version this code expects
async fn ensure_schema(pool : & sqlx::PgPool) -> Result <(), sqlx::Error>Apply ALL of the jobs crate's migrations to pool (creates/updates jobs, job_attempts, resource-lease, backoff/DLQ, fence/lease, etc.)

Re-exports. Exported here, defined elsewhere.

ExportDefined in
JobErrorerror::JobError
JobQueuequeue::JobQueue
JobStorestore::JobStore
{AttemptOutcomeInput,JobAttempt,JobAttemptStatus}attempt::{AttemptOutcomeInput,JobAttempt,JobAttemptStatus}
{ClaimedJob,JobFence}fence::{ClaimedJob,JobFence}
{FailureClass,Job,JobPayload,JobStatus,Schedule}job::{FailureClass,Job,JobPayload,JobStatus,Schedule}
{LaneConfig,TenantLaneError,TenantLaneSupervisor}lanes::{LaneConfig,TenantLaneError,TenantLaneSupervisor}
{LeaseOutcome,RecoveryPolicy,ResourceLease}resource::{LeaseOutcome,RecoveryPolicy,ResourceLease}
{ObserveOutcome,ReattachResult,ShutdownHandle,WakeHandle,WakeMode,Worker,WorkerConfig,}worker::{ObserveOutcome,ReattachResult,ShutdownHandle,WakeHandle,WakeMode,Worker,WorkerConfig,}
{QueueStats,StatCount}stats::{QueueStats,StatCount}

Boundary

Reaches into foundation.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/jobs
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_infrastructure["infrastructure"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
chrono^0.4serdenoalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonyesalways
thiserror^2noalways
tokio^1fullnoalways
tokio-util^0.7noalways
tracing^0.1noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

Build. None.

Depended on by. 5 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_cms["application-cms"] -->|uses| SELF
  n_application_jobs["application-jobs"] -->|uses| SELF
  n_application_tickets["application-tickets"] -->|uses| SELF
  n_infrastructure_cron["infrastructure-cron"] -->|uses| SELF
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  SELF["infrastructure-jobs"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
defaultpostgresyes
postgresdep:sqlxyes
flowchart LR
  n_default["default"] --> n_postgres["postgres"]
  n_postgres["postgres"] --> n_dep_sqlx["dep:sqlx"]

Targets

KindNameSource
libinfrastructure_jobs`src/lib.rs`
testcancellation`tests/cancellation.rs`
testfailure`tests/failure.rs`
testfence`tests/fence.rs`
testlanes`tests/lanes.rs`
testlanes_pg`tests/lanes_pg.rs`
testpg_job_attempts`tests/pg_job_attempts.rs`
testreattach`tests/reattach.rs`
testresource_lease`tests/resource_lease.rs`
testschedule`tests/schedule.rs`
teststats`tests/stats.rs`
testworker_runtime`tests/worker_runtime.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

5 workspace crates depend on this one: application-cms, application-jobs, application-tickets, infrastructure-cron, platform-privacy-scan-api.

Verification

KindCount
Unit tests32
Integration tests65
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root200

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc22
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 2
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files11
Source lines4713
Code lines3074
Public API items2
Public modules0
Tests97
Examples0
Cargo features2
Direct runtime dependencies11
Workspace reverse dependencies5
pie showData
    title Public API by kind
    "constant" : 1
    "function" : 1
pie showData
    title Rust source composition
    "Code" : 3074
    "Blank or comment" : 1639

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las infrastructure · Manual