From 6842be7de0a35b460754894df5191d4dff32c82b Mon Sep 17 00:00:00 2001 From: Sean Lawlor Date: Tue, 17 Dec 2024 22:58:51 -0500 Subject: [PATCH] Fix broken build for non async-trait builds (#302) --- .github/workflows/ci.yaml | 3 +++ ractor/Cargo.toml | 2 +- ractor/src/factory/worker.rs | 17 ++++++++++------- ractor_cluster/Cargo.toml | 2 +- ractor_cluster_derive/Cargo.toml | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 34c1018..e61929f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,6 +17,9 @@ jobs: - name: Run the default tests package: ractor # flags: + - name: Test ractor without async-trait + package: ractor + flags: --no-default-features -F tokio_runtime,message_span_propogation - name: Test ractor without span propogation package: ractor flags: --no-default-features -F tokio_runtime,async-trait diff --git a/ractor/Cargo.toml b/ractor/Cargo.toml index 8e3d9e1..6d484eb 100644 --- a/ractor/Cargo.toml +++ b/ractor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor" -version = "0.14.0" +version = "0.14.1" authors = ["Sean Lawlor", "Evan Au", "Dillon George"] description = "A actor framework for Rust" documentation = "https://docs.rs/ractor" diff --git a/ractor/src/factory/worker.rs b/ractor/src/factory/worker.rs index 6d68ed8..2d58cd1 100644 --- a/ractor/src/factory/worker.rs +++ b/ractor/src/factory/worker.rs @@ -7,6 +7,8 @@ use std::collections::{HashMap, VecDeque}; use std::fmt::Debug; +#[cfg(not(feature = "async-trait"))] +use std::future::Future; use std::sync::Arc; use bon::Builder; @@ -336,8 +338,9 @@ where custom_start, }: Self::Arguments, ) -> impl Future> + Send { - let inner_state = ::pre_start(&self, wid, &factory, custom_start).await?; - async { + async move { + let inner_state = + ::pre_start(&self, wid, &factory, custom_start).await?; Ok(Self::State { wid, factory, @@ -352,7 +355,7 @@ where _: ActorRef, state: &mut Self::State, ) -> impl Future> + Send { - async { + async move { ::post_start(&self, state.wid, &state.factory, &mut state.state).await } } @@ -372,7 +375,7 @@ where _: ActorRef, state: &mut Self::State, ) -> impl Future> + Send { - async { + async move { ::post_stop(&self, state.wid, &state.factory, &mut state.state).await } } @@ -393,7 +396,7 @@ where message: Self::Msg, state: &mut Self::State, ) -> impl Future> + Send { - async { + async move { match message { WorkerMessage::FactoryPing(time) => { tracing::trace!("Worker {} - ping", state.wid); @@ -403,7 +406,7 @@ where .cast(FactoryMessage::WorkerPong(state.wid, time.elapsed()))?; } WorkerMessage::Dispatch(mut job) => { - let key = if let Some(span) = job.options.span.take() { + let key = if let Some(span) = job.options.take_span() { ::handle( &self, state.wid, @@ -426,9 +429,9 @@ where state .factory .cast(FactoryMessage::Finished(state.wid, key))?; - Ok(()) } } + Ok(()) } } diff --git a/ractor_cluster/Cargo.toml b/ractor_cluster/Cargo.toml index 51938f2..c727b3b 100644 --- a/ractor_cluster/Cargo.toml +++ b/ractor_cluster/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor_cluster" -version = "0.14.0" +version = "0.14.1" authors = ["Sean Lawlor "] description = "Distributed cluster environment of Ractor actors" documentation = "https://docs.rs/ractor" diff --git a/ractor_cluster_derive/Cargo.toml b/ractor_cluster_derive/Cargo.toml index cf0cccb..ea0775e 100644 --- a/ractor_cluster_derive/Cargo.toml +++ b/ractor_cluster_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ractor_cluster_derive" -version = "0.14.0" +version = "0.14.1" authors = ["Sean Lawlor "] description = "Derives for ractor_cluster" license = "MIT"