aion_server/worker/
outbox_delivery.rs1use std::sync::Arc;
11
12use aion::Engine;
13use aion_core::{ActivityId, RunId, WorkflowId};
14
15use super::bridge::OutboxDeliveryCallback;
16use crate::error::ServerError;
17
18pub struct ServerOutboxDeliveryCallback {
20 engine: Arc<Engine>,
21}
22
23impl ServerOutboxDeliveryCallback {
24 #[must_use]
26 pub fn new(engine: Arc<Engine>) -> Self {
27 Self { engine }
28 }
29}
30
31impl OutboxDeliveryCallback for ServerOutboxDeliveryCallback {
32 fn deliver_completion(
33 &self,
34 workflow_id: &WorkflowId,
35 activity_id: &ActivityId,
36 run_id: Option<&RunId>,
37 result: String,
38 ) -> Result<bool, ServerError> {
39 self.engine
40 .runtime()
41 .deliver_outbox_completion(
42 self.engine.registry(),
43 workflow_id,
44 activity_id,
45 run_id,
46 result,
47 )
48 .map_err(ServerError::from)
49 }
50
51 fn deliver_failure(
52 &self,
53 workflow_id: &WorkflowId,
54 activity_id: &ActivityId,
55 run_id: Option<&RunId>,
56 reason: String,
57 ) -> Result<bool, ServerError> {
58 self.engine
59 .runtime()
60 .deliver_outbox_failure(
61 self.engine.registry(),
62 workflow_id,
63 activity_id,
64 run_id,
65 reason,
66 )
67 .map_err(ServerError::from)
68 }
69}