Skip to content

Commit

Permalink
[refactor] Simplifying Operation state transtion and exec of req msg
Browse files Browse the repository at this point in the history
Signed-off-by: dd di cesare <[email protected]>
  • Loading branch information
didierofrivia committed Oct 1, 2024
1 parent 944a4a9 commit 5434eb9
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/operation_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,17 @@ impl Operation {
}

fn trigger(&self) -> Result<u32, Status> {
match self.get_state() {
State::Pending => {
if let Some(message) =
(self.grpc_message_build_fn)(self.get_extension_type(), &self.action)
{
let res =
self.service
.send(self.get_map_values_bytes_fn, self.grpc_call_fn, message);
self.set_result(res);
self.next_state();
res
} else {
//todo: we need to move to and start the next action
self.done();
self.get_result()
}
}
State::Waiting => {
self.next_state();
self.get_result()
}
State::Done => self.get_result(),
if let Some(message) = (self.grpc_message_build_fn)(self.get_extension_type(), &self.action)
{
let res = self
.service
.send(self.get_map_values_bytes_fn, self.grpc_call_fn, message);
self.set_result(res);
self.next_state();
res
} else {
self.done();
self.get_result()
}
}

Expand Down Expand Up @@ -195,7 +184,7 @@ impl OperationDispatcher {
}
}
State::Waiting => {
let _ = operation.trigger();
operation.next_state();
Some(operation.clone())
}
State::Done => {
Expand Down

0 comments on commit 5434eb9

Please sign in to comment.