pub struct Config<C> {
pub stream: Config,
pub consumer: C,
pub heartbeat: Duration,
}Fields§
§stream: Config§consumer: C§heartbeat: DurationImplementations§
Source§impl Config<()>
impl Config<()>
Sourcepub fn new(namespace: &str) -> Self
pub fn new(namespace: &str) -> Self
Create a new JetStream configuration scoped to a namespace.
This initializes the underlying stream with the given namespace as its name.
No consumer type is selected at this stage — you must choose one of
Config::with_pull_consumer, Config::with_push_consumer.
§Arguments
namespace: Logical name used for the stream.
Sourcepub fn with_pull_consumer(self) -> Config<Config>
pub fn with_pull_consumer(self) -> Config<Config>
Configure a pull-based consumer.
In this mode, the client explicitly requests messages using APIs like
fetch or next. This provides strong control over throughput and
natural backpressure.
§Characteristics
- Client-driven (you decide when/how many messages to receive)
- Supports acknowledgements and redelivery
- Durable and fault-tolerant
§Use cases
- Job queues
- Worker systems
- Batch processing
§Notes
- Does not support features like
idle_heartbeat - Recommended default for most backend processing systems
Sourcepub fn with_ordered_pull_consumer(self) -> Config<OrderedConfig>
pub fn with_ordered_pull_consumer(self) -> Config<OrderedConfig>
Configure an ordered pull-based consumer.
This is a simplified pull consumer that guarantees strict message ordering, but disables reliability features such as acknowledgements and redelivery.
§Characteristics
- Strict ordering guaranteed
- No acknowledgements
- No redelivery on failure
- Ephemeral (non-durable)
§Behavior
If a message is missed or a sequence gap is detected, the consumer is transparently reset to a new position.
§Use cases
- Stream inspection
- Debugging
- Replay / analytics pipelines where occasional loss is acceptable
§⚠️ Warning
Do not use for job processing or systems requiring reliability.
Sourcepub fn with_push_consumer(self) -> Config<Config>
pub fn with_push_consumer(self) -> Config<Config>
Configure a push-based consumer.
In this mode, JetStream delivers messages to a subject (deliver_subject)
and the client subscribes to that subject.
§Characteristics
- Server-driven (messages are pushed to the client)
- Supports acknowledgements and redelivery
- Can be combined with queue groups for load balancing
§Use cases
- Event-driven systems
- Real-time pipelines
- Reactive services
§Notes
- Supports features like
idle_heartbeatand flow control - Requires configuring a
deliver_subjectdefaults toapalis-worker-group
Sourcepub fn with_ordered_push_consumer(self) -> Config<OrderedConfig>
pub fn with_ordered_push_consumer(self) -> Config<OrderedConfig>
Configure an ordered push-based consumer.
This is a push consumer that guarantees strict ordering, but removes reliability guarantees such as acknowledgements and redelivery.
§Characteristics
- Strict ordering guaranteed
- No acknowledgements
- No redelivery
- Ephemeral (non-durable)
§Behavior
If message delivery order is disrupted, the consumer is automatically recreated and resumes from a new position.
§Use cases
- Observability pipelines
- Real-time stream inspection
- Monitoring and debugging
§⚠️ Warning
Not suitable for production job processing or any system that requires guaranteed delivery.