strip session-added comments
Some checks failed
CI / Check / Test (push) Has been cancelled
CI / Check / Test (pull_request) Has been cancelled

This commit is contained in:
2026-10-26 10:32:38 +01:00
parent a270632e87
commit f020108024
138 changed files with 0 additions and 719 deletions

View File

@@ -11,7 +11,6 @@ pub struct NatsConfig {
pub subject_prefix: String,
pub stream_name: String,
pub consumer_name: String,
/// JetStream redelivery bound, same as the DB queue's attempt limit.
pub max_deliver: i64,
}

View File

@@ -25,11 +25,8 @@ struct NatsJetStreamAckHandle {
max_deliver: i64,
}
/// How to nak a failed delivery: the same backoff schedule as the SQLite
/// queue, keyed by JetStream's delivery count (1 on first delivery).
struct NakPlan {
delay: std::time::Duration,
/// This was the last delivery `max_deliver` allows.
exhausted: bool,
}
@@ -82,9 +79,6 @@ impl AckHandle for NatsJetStreamAckHandle {
.map_err(|e| DomainError::InfrastructureError(e.to_string()))
}
/// JetStream counts every redelivery toward `max_deliver`, deferrals
/// included. The delay is at least the remaining claim lease, so the
/// deliveries allowed by `max_deliver` still span more than one lease.
async fn defer(&self, delay: std::time::Duration) -> Result<(), DomainError> {
self.message
.ack_with(AckKind::Nak(Some(delay)))
@@ -159,20 +153,10 @@ fn consume_from_rx(rx: EnvelopeRx) -> BoxStream<'static, Result<EventEnvelope, D
}))
}
/// How long JetStream remembers `Nats-Msg-Id`s. A row re-relayed within this
/// window (crash between publish and mark-done, or a lease reclaim) is dropped
/// by the broker; a duplicate arriving later is caught by the processed-event
/// ledger, which keeps its rows for 30 days. Set explicitly so it does not
/// silently follow the server default.
const DEDUP_WINDOW: std::time::Duration = std::time::Duration::from_secs(60 * 60);
const ACK_WAIT: std::time::Duration = std::time::Duration::from_secs(600);
/// `Some(updated)` when an existing stream's config differs from what this
/// build needs. `get_or_create_stream` only applies config on creation, so a
/// stream created by an older build would otherwise keep the server default
/// duplicate window (2 minutes). Only the fields this code owns are changed;
/// everything else the operator set is preserved.
fn stream_config_update(existing: &StreamConfig) -> Option<StreamConfig> {
(existing.duplicate_window != DEDUP_WINDOW).then(|| StreamConfig {
duplicate_window: DEDUP_WINDOW,
@@ -180,10 +164,6 @@ fn stream_config_update(existing: &StreamConfig) -> Option<StreamConfig> {
})
}
/// `Some(updated)` when an existing durable consumer disagrees on `max_deliver`
/// or `ack_wait`. The update is a clone of the existing config with only those
/// two fields changed, so operator-set fields survive and immutable ones
/// (durable name, filter subject, deliver policy) cannot mismatch.
fn consumer_config_update(
existing: &jetstream::consumer::Config,
desired_max_deliver: i64,

View File

@@ -12,8 +12,6 @@ use std::sync::Arc;
use domain::ports::{EventConsumer, EventRelaySink};
/// The worker's NATS side: where handlers read events from, and where the
/// outbox relay writes them to.
pub async fn create_bus(
cfg: NatsConfig,
) -> anyhow::Result<(Arc<dyn EventConsumer>, Arc<dyn EventRelaySink>)> {
@@ -29,7 +27,6 @@ pub async fn create_bus(
Arc::new(NatsRelaySink::new_core(client, cfg.subject_prefix)),
)
}
// The consumer creates the stream the relay publishes into.
NatsMode::JetStream => (
Arc::new(NatsJetStreamConsumer::create(&cfg, client.clone()).await?),
Arc::new(NatsRelaySink::new_jetstream(client, cfg.subject_prefix)),

View File

@@ -9,13 +9,9 @@ use event_payload::EventPayload;
use crate::{payload::NatsEventMessage, subject::event_to_subject};
/// What goes on the wire for one outbox row. Built purely from the row, so
/// relaying it again (after a crash between publish and mark-done) yields the
/// same `Nats-Msg-Id` and JetStream drops the duplicate.
pub(crate) struct RelayMessage {
pub subject: String,
pub payload: Vec<u8>,
/// `None` for rows queued before identities existed: those get no dedup.
pub msg_id: Option<String>,
}
@@ -42,8 +38,6 @@ enum Transport {
JetStream(jetstream::Context),
}
/// Publishes outbox rows to NATS. JetStream mode waits for the broker ack and
/// sets `Nats-Msg-Id`; core mode is fire-and-forget with no broker-side dedup.
pub struct NatsRelaySink {
transport: Transport,
subject_prefix: String,