headgate-proto 0.1.4

A policy-aware distributed job queue with PostgreSQL, MySQL, and Redis backends.
Documentation
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Envelope {
    /// ULID: lexicographically sortable, no coordination
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// task type name; the dispatch key
    #[prost(string, tag = "2")]
    pub kind: ::prost::alloc::string::String,
    /// payload versioning payload versioning — free now, impossible later
    #[prost(uint32, tag = "3")]
    pub schema_version: u32,
    /// opaque to headgate; codec is the caller's choice
    #[prost(bytes = "vec", tag = "4")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
    #[prost(string, tag = "5")]
    pub queue: ::prost::alloc::string::String,
    /// tenant fairness fair queuing (tenant/customer). "" = default partition
    #[prost(string, tag = "6")]
    pub partition_key: ::prost::alloc::string::String,
    /// admission policy fleet-wide limiter bucket. "" = unlimited
    #[prost(string, tag = "7")]
    pub rate_class: ::prost::alloc::string::String,
    /// crash quarantine quarantine key: hash(kind, payload)
    #[prost(string, tag = "8")]
    pub fingerprint: ::prost::alloc::string::String,
    /// failures the handler RETURNED
    #[prost(uint32, tag = "9")]
    pub attempt: u32,
    /// crash quarantine failures where the worker DIED. counted separately.
    #[prost(uint32, tag = "10")]
    pub crash_attempt: u32,
    #[prost(uint32, tag = "11")]
    pub max_attempts: u32,
    /// higher runs first within a queue
    #[prost(int32, tag = "12")]
    pub priority: i32,
    /// wire-time contract every duration and instant is milliseconds
    #[prost(int64, tag = "13")]
    pub enqueued_at_ms: i64,
    #[prost(int64, tag = "14")]
    pub scheduled_at_ms: i64,
    /// per attempt
    #[prost(int64, tag = "15")]
    pub timeout_ms: i64,
    /// absolute, across all attempts. 0 = none
    #[prost(int64, tag = "16")]
    pub deadline_ms: i64,
    #[prost(int64, tag = "17")]
    pub retention_ms: i64,
    /// job uniqueness null = not unique
    #[prost(bytes = "vec", tag = "18")]
    pub unique_key: ::prost::alloc::vec::Vec<u8>,
    /// bitmask of States uniqueness applies in
    #[prost(uint32, tag = "19")]
    pub unique_states: u32,
    #[prost(map = "string, string", tag = "20")]
    pub headers: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::string::String,
    >,
    #[prost(message, repeated, tag = "21")]
    pub errors: ::prost::alloc::vec::Vec<AttemptError>,
    /// job uniqueness uniqueness mode. 0 = LIFECYCLE (one live job per key, released by terminal
    /// state). > 0 = THROTTLE (at most one per this many ms, released by the clock).
    #[prost(int64, tag = "22")]
    pub unique_window_ms: i64,
    /// step replay step replay
    #[prost(message, optional, tag = "23")]
    pub checkpoint: ::core::option::Option<Checkpoint>,
    /// surveyed policy behavior estimated rate-budget cost. This is NOT queue-selection weight. Proto3's
    /// omitted zero is normalized to the default 1 by every store; an ack may report an
    /// actual value (including zero) and atomically reconcile the estimate.
    #[prost(uint32, tag = "24")]
    pub weight: u32,
    /// Typed durable periodic origin. Empty/zero means an ordinary enqueue; both fields
    /// are set together so clients never parse ids or opaque headers.
    #[prost(string, tag = "25")]
    pub periodic_schedule_id: ::prost::alloc::string::String,
    #[prost(int64, tag = "26")]
    pub periodic_tick_ms: i64,
    /// Request-only bitmask for atomic replacement on a unique-key conflict. Allowed
    /// fields are defined by the language SDK constants; unknown bits are rejected.
    #[prost(uint32, tag = "27")]
    pub unique_replace: u32,
    /// Trailing-edge debounce. Requires unique_key and a positive millisecond window.
    /// The store schedules the holder at store-now + this window on both the first insert
    /// and every conflict; it never trusts a producer clock.
    #[prost(int64, tag = "28")]
    pub unique_debounce_ms: i64,
    /// River-compatible uniqueness scope. false includes kind in the effective key;
    /// true deliberately coalesces equal keys across task kinds.
    #[prost(bool, tag = "29")]
    pub unique_exclude_kind: bool,
    /// Operator-indexed labels. Canonicalized by SDKs; never smuggled through headers.
    #[prost(string, repeated, tag = "30")]
    pub tags: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Insert durably without becoming admission-eligible until explicitly promoted.
    #[prost(bool, tag = "31")]
    pub pending: bool,
    /// Exact stable worker identity allowed to claim this job. Empty means any worker.
    /// Enforced atomically by the store and retained across retry/reclaim transitions.
    #[prost(string, tag = "32")]
    pub sticky_worker: ::prost::alloc::string::String,
}
/// step replay Step replay. River persists this only after the worker returns, which loses it in
/// exactly the mid-step crash the feature exists for; Sidekiq autosaves every 5s. Here the
/// checkpoint rides the lease renewal that is already happening, so step boundaries are
/// exact and cursor updates are bounded by the renewal interval.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Checkpoint {
    #[prost(string, tag = "1")]
    pub last_completed_step: ::prost::alloc::string::String,
    /// the step a cursor belongs to, if any
    #[prost(string, tag = "2")]
    pub cursor_step: ::prost::alloc::string::String,
    /// opaque, caller-serialized
    #[prost(bytes = "vec", tag = "3")]
    pub cursor: ::prost::alloc::vec::Vec<u8>,
    #[prost(int64, tag = "4")]
    pub updated_at_ms: i64,
    /// payload versioning × step replay: what the step set looked like when this was written. A resumed job whose
    /// step set no longer matches goes to UNDECODABLE rather than silently restarting from
    /// step one and re-running completed side effects. No other queue has to answer this,
    /// because no other queue has both step replay and payload versioning.
    #[prost(uint32, tag = "5")]
    pub schema_version: u32,
    #[prost(string, tag = "6")]
    pub step_set_hash: ::prost::alloc::string::String,
    /// crash quarantine step-level crash attribution
    #[prost(map = "string, uint32", tag = "7")]
    pub crashes_by_step: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        u32,
    >,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttemptError {
    #[prost(uint32, tag = "1")]
    pub attempt: u32,
    #[prost(int64, tag = "2")]
    pub at_ms: i64,
    #[prost(string, tag = "3")]
    pub message: ::prost::alloc::string::String,
    #[prost(enumeration = "Outcome", tag = "4")]
    pub outcome: i32,
    #[prost(bool, tag = "5")]
    pub was_panic: bool,
    #[prost(string, tag = "6")]
    pub worker: ::prost::alloc::string::String,
    /// step replay which step failed, when the job has steps
    #[prost(string, tag = "7")]
    pub step: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Claim {
    #[prost(message, optional, tag = "1")]
    pub envelope: ::core::option::Option<Envelope>,
    /// lease fencing created atomically with the claim, never separately
    #[prost(string, tag = "2")]
    pub lease_id: ::prost::alloc::string::String,
    #[prost(int64, tag = "3")]
    pub lease_expires_at_ms: i64,
    /// monotonic per job; rejects writes from a superseded holder
    #[prost(uint64, tag = "4")]
    pub fence: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WorkerInfo {
    #[prost(string, tag = "1")]
    pub worker_id: ::prost::alloc::string::String,
    #[prost(string, tag = "2")]
    pub host: ::prost::alloc::string::String,
    #[prost(int32, tag = "3")]
    pub pid: i32,
    #[prost(string, tag = "4")]
    pub version: ::prost::alloc::string::String,
    #[prost(string, repeated, tag = "5")]
    pub queues: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    #[prost(uint32, tag = "6")]
    pub concurrency: u32,
    #[prost(int64, tag = "7")]
    pub started_at_ms: i64,
    #[prost(int64, tag = "8")]
    pub heartbeat_at_ms: i64,
    #[prost(uint32, tag = "9")]
    pub inflight: u32,
    #[prost(string, tag = "10")]
    pub status: ::prost::alloc::string::String,
    #[prost(bool, tag = "11")]
    pub duties_active: bool,
    #[prost(string, tag = "12")]
    pub pending_command: ::prost::alloc::string::String,
}
/// admission policy Admission policy, evaluated store-side inside the claim.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RateClass {
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// tokens per window
    #[prost(uint64, tag = "2")]
    pub limit: u64,
    #[prost(int64, tag = "3")]
    pub window_ms: i64,
    #[prost(uint64, tag = "4")]
    pub burst: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConcurrencyLimit {
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// "" = global, else an envelope field name
    #[prost(string, tag = "2")]
    pub partition_by: ::prost::alloc::string::String,
    #[prost(uint64, tag = "3")]
    pub max_concurrent: u64,
    #[prost(string, tag = "4")]
    pub queue: ::prost::alloc::string::String,
    /// queue|discard|cancel_running|cancel_incoming
    #[prost(string, tag = "5")]
    pub on_saturated: ::prost::alloc::string::String,
}
/// backlog metrics Backlog derivatives — a read, not a Prometheus recording rule.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueueStats {
    #[prost(string, tag = "1")]
    pub queue: ::prost::alloc::string::String,
    #[prost(map = "string, uint64", tag = "2")]
    pub by_state: ::std::collections::HashMap<::prost::alloc::string::String, u64>,
    /// jobs/sec, 1m window
    #[prost(double, tag = "3")]
    pub arrival_rate: f64,
    /// jobs/sec, 1m window
    #[prost(double, tag = "4")]
    pub drain_rate: f64,
    /// -1 when arrival >= drain: the alert condition
    #[prost(int64, tag = "5")]
    pub time_to_drain_ms: i64,
    #[prost(bool, tag = "6")]
    pub paused: bool,
    /// bounded live-control contract true when a bound was hit
    #[prost(bool, tag = "7")]
    pub count_is_approximate: bool,
    /// -1 when no job is currently available
    #[prost(int64, tag = "8")]
    pub oldest_available_ms: i64,
    #[prost(message, optional, tag = "9")]
    pub quiet_groups: ::core::option::Option<QuietGroupMetrics>,
    /// queue-selection weight; unrelated to Envelope.weight
    #[prost(uint32, tag = "10")]
    pub weight: u32,
    /// exact producer-depth counter, never approximate
    #[prost(uint64, tag = "11")]
    pub unfinished_jobs: u64,
    /// absent = enqueue backpressure disabled
    #[prost(uint64, optional, tag = "12")]
    pub max_unfinished_jobs: ::core::option::Option<u64>,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct QuietGroupMetrics {
    #[prost(double, tag = "1")]
    pub arrival_rate: f64,
    #[prost(double, tag = "2")]
    pub drain_rate: f64,
    /// -1 when arrival >= drain
    #[prost(int64, tag = "3")]
    pub time_to_drain_ms: i64,
    /// -1 when no quiet job is available
    #[prost(int64, tag = "4")]
    pub oldest_available_ms: i64,
    #[prost(uint32, tag = "5")]
    pub noisy_partitions: u32,
    #[prost(bool, tag = "6")]
    pub approximate: bool,
}
/// lifecycle state machine The state machine is a declared table, not a match with holes.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum State {
    Unspecified = 0,
    /// scheduled_at in the future
    Scheduled = 1,
    /// ready to be admitted
    Available = 2,
    /// claimed, lease held
    Running = 3,
    /// failed, will return to AVAILABLE
    Retryable = 4,
    /// terminal, retained per policy
    Completed = 5,
    /// terminal, inspectable, re-runnable (the DLQ)
    Archived = 6,
    /// terminal, operator action
    Cancelled = 7,
    /// crash quarantine terminal, fingerprint blocked
    Quarantined = 8,
    /// payload versioning terminal, no upcast path for this schema_version
    Undecodable = 9,
    /// durable but ineligible until explicit promotion
    Pending = 10,
}
impl State {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "STATE_UNSPECIFIED",
            Self::Scheduled => "STATE_SCHEDULED",
            Self::Available => "STATE_AVAILABLE",
            Self::Running => "STATE_RUNNING",
            Self::Retryable => "STATE_RETRYABLE",
            Self::Completed => "STATE_COMPLETED",
            Self::Archived => "STATE_ARCHIVED",
            Self::Cancelled => "STATE_CANCELLED",
            Self::Quarantined => "STATE_QUARANTINED",
            Self::Undecodable => "STATE_UNDECODABLE",
            Self::Pending => "STATE_PENDING",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "STATE_UNSPECIFIED" => Some(Self::Unspecified),
            "STATE_SCHEDULED" => Some(Self::Scheduled),
            "STATE_AVAILABLE" => Some(Self::Available),
            "STATE_RUNNING" => Some(Self::Running),
            "STATE_RETRYABLE" => Some(Self::Retryable),
            "STATE_COMPLETED" => Some(Self::Completed),
            "STATE_ARCHIVED" => Some(Self::Archived),
            "STATE_CANCELLED" => Some(Self::Cancelled),
            "STATE_QUARANTINED" => Some(Self::Quarantined),
            "STATE_UNDECODABLE" => Some(Self::Undecodable),
            "STATE_PENDING" => Some(Self::Pending),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Outcome {
    Unspecified = 0,
    Success = 1,
    /// handler returned an error
    Retry = 2,
    /// handler said: stop retrying, archive
    Skip = 3,
    /// handler said: drop entirely
    Revoke = 4,
    /// reschedule without consuming an attempt
    Snooze = 5,
    /// crash quarantine crash-attributed: worker died, never acked
    LeaseLost = 6,
    /// payload versioning payload could not be decoded
    Undecodable = 7,
    /// surveyed policy behavior NOT a failure: re-queue without consuming an attempt
    RateLimited = 8,
}
impl Outcome {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "OUTCOME_UNSPECIFIED",
            Self::Success => "OUTCOME_SUCCESS",
            Self::Retry => "OUTCOME_RETRY",
            Self::Skip => "OUTCOME_SKIP",
            Self::Revoke => "OUTCOME_REVOKE",
            Self::Snooze => "OUTCOME_SNOOZE",
            Self::LeaseLost => "OUTCOME_LEASE_LOST",
            Self::Undecodable => "OUTCOME_UNDECODABLE",
            Self::RateLimited => "OUTCOME_RATE_LIMITED",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "OUTCOME_UNSPECIFIED" => Some(Self::Unspecified),
            "OUTCOME_SUCCESS" => Some(Self::Success),
            "OUTCOME_RETRY" => Some(Self::Retry),
            "OUTCOME_SKIP" => Some(Self::Skip),
            "OUTCOME_REVOKE" => Some(Self::Revoke),
            "OUTCOME_SNOOZE" => Some(Self::Snooze),
            "OUTCOME_LEASE_LOST" => Some(Self::LeaseLost),
            "OUTCOME_UNDECODABLE" => Some(Self::Undecodable),
            "OUTCOME_RATE_LIMITED" => Some(Self::RateLimited),
            _ => None,
        }
    }
}