Skip to content

Commit

Permalink
Merge pull request #2770 from didier-wenzek/refactor/deprecate-servic…
Browse files Browse the repository at this point in the history
…e-provider-consumer-traits

refactor: Deprecate service provider and consumer traits
  • Loading branch information
didier-wenzek authored Mar 13, 2024
2 parents 8058514 + bf4fac9 commit 111a746
Show file tree
Hide file tree
Showing 43 changed files with 496 additions and 731 deletions.
1 change: 1 addition & 0 deletions crates/common/batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ time = { workspace = true }
tokio = { workspace = true, features = ["time"] }

[dev-dependencies]
tedge_actors = { workspace = true, features = ["test-helpers"] }
tokio = { workspace = true, features = ["rt", "macros"] }

[lints]
Expand Down
3 changes: 1 addition & 2 deletions crates/common/batcher/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ mod tests {
use std::time::Duration;
use tedge_actors::test_helpers::ServiceProviderExt;
use tedge_actors::Builder;
use tedge_actors::NoConfig;
use tedge_actors::SimpleMessageBoxBuilder;
use tokio::time::timeout;

Expand Down Expand Up @@ -256,7 +255,7 @@ mod tests {
.build();
let batcher = Batcher::new(config);
let mut box_builder = SimpleMessageBoxBuilder::new("test", 1);
let test_box = box_builder.new_client_box(NoConfig);
let test_box = box_builder.new_client_box();
let driver_box = box_builder.build();

let driver = BatchDriver::new(batcher, driver_box);
Expand Down
21 changes: 1 addition & 20 deletions crates/common/batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use tedge_actors::MessageSource;
use tedge_actors::NoConfig;
use tedge_actors::RuntimeRequest;
use tedge_actors::RuntimeRequestSink;
use tedge_actors::ServiceProvider;
use tedge_actors::SimpleMessageBoxBuilder;

pub struct BatchingActorBuilder<B: Batchable> {
Expand Down Expand Up @@ -68,25 +67,7 @@ impl<B: Batchable> BatchingActorBuilder<B> {
}
}

// FIXME: This implementation highlights something new to me.
// For some actor it makes little sense to impl ServiceProvider,
// as the consumer of the outputs is likely a *different* actor as the producer of the inputs
impl<B: Batchable> ServiceProvider<BatchDriverInput<B>, BatchDriverOutput<B>, NoConfig>
for BatchingActorBuilder<B>
{
fn connect_consumer(
&mut self,
config: NoConfig,
response_sender: DynSender<BatchDriverOutput<B>>,
) -> DynSender<BatchDriverInput<B>> {
self.message_box.connect_consumer(config, response_sender)
}
}

impl<B: Batchable> MessageSink<BatchDriverInput<B>, NoConfig> for BatchingActorBuilder<B> {
fn get_config(&self) -> NoConfig {
NoConfig
}
impl<B: Batchable> MessageSink<BatchDriverInput<B>> for BatchingActorBuilder<B> {
fn get_sender(&self) -> DynSender<BatchDriverInput<B>> {
self.message_box.get_sender()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_actors/src/actors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub mod tests {
#[tokio::test]
async fn running_an_actor_without_a_runtime() {
let mut box_builder = SimpleMessageBoxBuilder::new("test", 16);
let mut client_message_box = box_builder.new_client_box(NoConfig);
let mut client_message_box = box_builder.new_client_box();
let mut runtime_box = box_builder.get_signal_sender();
let actor_message_box = box_builder.build();
let actor = Echo {
Expand Down
Loading

0 comments on commit 111a746

Please sign in to comment.