First, thanks for the library it looks pretty cool.
I am trying to create a simple health check state machine that pings an external service and then transitions state based on the response from that service.
I am using tokio as the async runtime and the external connection requires an async call.
I start with the below and then crated some impl for each of the states my service could be in
// Struct that holds the family of states that HealthCheck will contain
struct HealthCheckFamily;
impl Family for HealthCheckFamily {
// This is the public interface that will be exposed by the Automaton for all Modes in this Family.
type Base = dyn HealthCheck;
// This is the type that will be stored in the Automaton and passed into the Automaton::next() function.
type Mode = Box<dyn HealthCheck>;
}
// This trait defines a common interface for all Modes in ActivityFamily.
//
#[async_trait]
trait HealthCheck: Mode<Family = HealthCheckFamily> {
async fn update(self: Box<Self>) -> Box<dyn HealthCheck>;
}
However I obviously run into issues when trying to call Automaton::next as it expects a different type than the async function.
I am pretty new to rust so apologies if I am barking up the wrong tree or missing something obvious but is there a way to go about making an async call within my transition function ?
First, thanks for the library it looks pretty cool.
I am trying to create a simple health check state machine that pings an external service and then transitions state based on the response from that service.
I am using tokio as the async runtime and the external connection requires an async call.
I start with the below and then crated some impl for each of the states my service could be in
However I obviously run into issues when trying to call Automaton::next as it expects a different type than the async function.
I am pretty new to rust so apologies if I am barking up the wrong tree or missing something obvious but is there a way to go about making an async call within my transition function ?