Skip to content

Commit

Permalink
Compile socket without stdio backend (#35)
Browse files Browse the repository at this point in the history
* Fix compilation

* Suppress warnings
  • Loading branch information
tyt2y3 authored Aug 21, 2024
1 parent 34e9691 commit 6566d44
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion sea-streamer-socket/src/connect_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ impl ConnectOptions for SeaConnectOptions {
type Error = BackendErr;

fn timeout(&self) -> SeaResult<Duration> {
self.stdio.timeout().map_err(map_err)
#![allow(unreachable_code)]

#[cfg(feature = "backend-kafka")]
return self.kafka.timeout().map_err(map_err);
#[cfg(feature = "backend-redis")]
return self.redis.timeout().map_err(map_err);
#[cfg(feature = "backend-stdio")]
return self.stdio.timeout().map_err(map_err);
#[cfg(feature = "backend-file")]
return self.file.timeout().map_err(map_err);
}

fn set_timeout(&mut self, d: Duration) -> SeaResult<&mut Self> {
Expand Down
22 changes: 20 additions & 2 deletions sea-streamer-socket/src/consumer_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,30 @@ impl ConsumerOptions for SeaConsumerOptions {

/// Get currently set ConsumerMode
fn mode(&self) -> SeaResult<&ConsumerMode> {
self.stdio.mode().map_err(map_err)
#![allow(unreachable_code)]

#[cfg(feature = "backend-kafka")]
return self.kafka.mode().map_err(map_err);
#[cfg(feature = "backend-redis")]
return self.redis.mode().map_err(map_err);
#[cfg(feature = "backend-stdio")]
return self.stdio.mode().map_err(map_err);
#[cfg(feature = "backend-file")]
return self.file.mode().map_err(map_err);
}

/// Get currently set consumer group; may return `StreamErr::ConsumerGroupNotSet`.
fn consumer_group(&self) -> SeaResult<&ConsumerGroup> {
self.stdio.consumer_group().map_err(map_err)
#![allow(unreachable_code)]

#[cfg(feature = "backend-kafka")]
return self.kafka.consumer_group().map_err(map_err);
#[cfg(feature = "backend-redis")]
return self.redis.consumer_group().map_err(map_err);
#[cfg(feature = "backend-stdio")]
return self.stdio.consumer_group().map_err(map_err);
#[cfg(feature = "backend-file")]
return self.file.consumer_group().map_err(map_err);
}

/// Set consumer group for this consumer. Note the semantic is implementation-specific.
Expand Down

0 comments on commit 6566d44

Please sign in to comment.