@@ -7,8 +7,9 @@ use crate::{
77use async_channel;
88use sift_connect:: SiftChannel ;
99use sift_error:: prelude:: * ;
10- use sift_rs:: ingest:: v1:: {
11- IngestWithConfigDataStreamRequest , ingest_service_client:: IngestServiceClient ,
10+ use sift_rs:: {
11+ CompressionEncoding ,
12+ ingest:: v1:: { IngestWithConfigDataStreamRequest , ingest_service_client:: IngestServiceClient } ,
1213} ;
1314use std:: { path:: PathBuf , pin:: Pin , sync:: Arc , time:: Duration } ;
1415use tokio:: { sync:: broadcast, task:: JoinHandle , time:: Instant } ;
@@ -47,31 +48,32 @@ pub(crate) enum ControlMessage {
4748}
4849
4950#[ derive( Clone ) ]
50- pub struct RecoveryConfig {
51- pub retry_policy : RetryPolicy ,
52- pub backups_enabled : bool ,
53- pub backups_directory : String ,
54- pub backups_prefix : String ,
55- pub backup_policy : DiskBackupPolicy ,
51+ pub ( crate ) struct RecoveryConfig {
52+ pub ( crate ) retry_policy : RetryPolicy ,
53+ pub ( crate ) backups_enabled : bool ,
54+ pub ( crate ) backups_directory : String ,
55+ pub ( crate ) backups_prefix : String ,
56+ pub ( crate ) backup_policy : DiskBackupPolicy ,
5657}
5758
5859/// Configuration for the task-based SiftStream
5960#[ derive( Clone ) ]
60- pub struct TaskConfig {
61- pub sift_stream_id : Uuid ,
62- pub grpc_channel : SiftChannel ,
63- pub metrics : Arc < SiftStreamMetrics > ,
64- pub checkpoint_interval : Duration ,
65- pub recovery_config : RecoveryConfig ,
66- pub control_channel_capacity : usize ,
67- pub data_channel_capacity : usize ,
61+ pub ( crate ) struct TaskConfig {
62+ pub ( crate ) sift_stream_id : Uuid ,
63+ pub ( crate ) grpc_channel : SiftChannel ,
64+ pub ( crate ) metrics : Arc < SiftStreamMetrics > ,
65+ pub ( crate ) checkpoint_interval : Duration ,
66+ pub ( crate ) enable_compression_for_ingestion : bool ,
67+ pub ( crate ) recovery_config : RecoveryConfig ,
68+ pub ( crate ) control_channel_capacity : usize ,
69+ pub ( crate ) data_channel_capacity : usize ,
6870}
6971
7072/// Data message with stream ID for routing
7173#[ derive( Debug , Clone ) ]
72- pub struct DataMessage {
73- pub request : IngestWithConfigDataStreamRequest ,
74- pub dropped_for_ingestion : bool ,
74+ pub ( crate ) struct DataMessage {
75+ pub ( crate ) request : IngestWithConfigDataStreamRequest ,
76+ pub ( crate ) dropped_for_ingestion : bool ,
7577}
7678
7779/// Handles for the three main tasks
@@ -150,6 +152,7 @@ pub(crate) fn start_tasks(config: TaskConfig) -> Result<StreamSystem> {
150152 let reingestion_task = BackupIngestTask :: new (
151153 reingestion_control_tx. subscribe ( ) ,
152154 reingestion_config. grpc_channel ,
155+ reingestion_config. enable_compression_for_ingestion ,
153156 reingest_retry_policy,
154157 reingestion_config
155158 . recovery_config
@@ -233,6 +236,14 @@ impl IngestionTask {
233236 // any race conditions in that task being polled for the first time and other
234237 // events occurring in the system.
235238 let mut client = IngestServiceClient :: new ( self . config . grpc_channel . clone ( ) ) ;
239+
240+ // If compression is enabled, add the compression codecs to the client.
241+ if self . config . enable_compression_for_ingestion {
242+ client = client
243+ . send_compressed ( CompressionEncoding :: Gzip )
244+ . accept_compressed ( CompressionEncoding :: Gzip ) ;
245+ }
246+
236247 let data_stream = DataStream :: new (
237248 self . data_rx . clone ( ) ,
238249 self . control_tx . clone ( ) ,
@@ -485,6 +496,7 @@ mod tests {
485496 grpc_channel,
486497 metrics : metrics. clone ( ) ,
487498 checkpoint_interval,
499+ enable_compression_for_ingestion : false ,
488500 control_channel_capacity : 128 ,
489501 data_channel_capacity : 128 ,
490502 recovery_config : RecoveryConfig {
@@ -543,6 +555,7 @@ mod tests {
543555 grpc_channel,
544556 metrics : metrics. clone ( ) ,
545557 checkpoint_interval,
558+ enable_compression_for_ingestion : false ,
546559 control_channel_capacity : 128 ,
547560 data_channel_capacity : 128 ,
548561 recovery_config : RecoveryConfig {
@@ -595,6 +608,7 @@ mod tests {
595608 grpc_channel,
596609 metrics : metrics. clone ( ) ,
597610 checkpoint_interval,
611+ enable_compression_for_ingestion : false ,
598612 control_channel_capacity : 128 ,
599613 data_channel_capacity : 128 ,
600614 recovery_config : RecoveryConfig {
@@ -657,6 +671,7 @@ mod tests {
657671 grpc_channel,
658672 metrics : metrics. clone ( ) ,
659673 checkpoint_interval : Duration :: from_secs ( 60 ) ,
674+ enable_compression_for_ingestion : false ,
660675 control_channel_capacity : 128 ,
661676 data_channel_capacity : 128 ,
662677 recovery_config : RecoveryConfig {
@@ -733,6 +748,7 @@ mod tests {
733748 grpc_channel,
734749 metrics : metrics. clone ( ) ,
735750 checkpoint_interval,
751+ enable_compression_for_ingestion : false ,
736752 control_channel_capacity : 128 ,
737753 data_channel_capacity : 128 ,
738754 recovery_config : RecoveryConfig {
@@ -825,6 +841,7 @@ mod tests {
825841 grpc_channel,
826842 metrics : metrics. clone ( ) ,
827843 checkpoint_interval,
844+ enable_compression_for_ingestion : false ,
828845 control_channel_capacity : 128 ,
829846 data_channel_capacity : 128 ,
830847 recovery_config : RecoveryConfig {
@@ -895,6 +912,7 @@ mod tests {
895912 grpc_channel,
896913 metrics : metrics. clone ( ) ,
897914 checkpoint_interval,
915+ enable_compression_for_ingestion : false ,
898916 control_channel_capacity : 128 ,
899917 data_channel_capacity : 128 ,
900918 recovery_config : RecoveryConfig {
0 commit comments