diff --git a/async-nats/src/jetstream/context.rs b/async-nats/src/jetstream/context.rs index d5f6790d5..a978943ac 100644 --- a/async-nats/src/jetstream/context.rs +++ b/async-nats/src/jetstream/context.rs @@ -42,8 +42,8 @@ use super::is_valid_name; use super::kv::{Store, MAX_HISTORY}; use super::object_store::{is_valid_bucket_name, ObjectStore}; use super::stream::{ - self, Config, ConsumerError, ConsumerErrorKind, DeleteStatus, DiscardPolicy, External, Info, - Stream, + self, Compression, Config, ConsumerError, ConsumerErrorKind, DeleteStatus, DiscardPolicy, + External, Info, Stream, }; /// A context which can perform jetstream scoped requests. @@ -1045,6 +1045,11 @@ impl Context { discard: DiscardPolicy::New, allow_rollup: true, allow_direct: true, + compression: if config.compression { + Some(Compression::S2) + } else { + None + }, ..Default::default() }) .await diff --git a/async-nats/src/jetstream/object_store/mod.rs b/async-nats/src/jetstream/object_store/mod.rs index b7a446a45..8bc5cc0ca 100644 --- a/async-nats/src/jetstream/object_store/mod.rs +++ b/async-nats/src/jetstream/object_store/mod.rs @@ -76,6 +76,8 @@ pub struct Config { pub storage: StorageType, /// How many replicas to keep for each value in a cluster, maximum 5. pub num_replicas: usize, + /// Sets compression of the underlying stream. + pub compression: bool, } /// A blob store capable of storing large objects efficiently in streams.