use aion_core::{ActivityEvent, ActivityId, RunId, WorkflowId};
use serde_json::Value;
use uuid::Uuid;
use super::wire;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub(super) struct StreamSlot {
workflow_id: WorkflowId,
run_id: RunId,
activity_id: ActivityId,
attempt: u32,
agent_id: Uuid,
}
impl StreamSlot {
pub(super) fn of(event: &ActivityEvent) -> Self {
Self {
workflow_id: event.workflow_id.clone(),
run_id: event.run_id.clone(),
activity_id: event.activity_id.clone(),
attempt: event.attempt,
agent_id: event.agent_id,
}
}
}
#[derive(Clone, Debug)]
pub(super) struct RecordedBase {
pub(super) response_id: String,
pub(super) worker_seq: u64,
pub(super) value: Value,
pub(super) digest: String,
}
impl RecordedBase {
pub(super) fn record_parts(response_id: &str, worker_seq: u64, value: &Value) -> Option<Self> {
Some(Self {
response_id: response_id.to_owned(),
worker_seq,
value: value.clone(),
digest: wire::value_digest(value)?,
})
}
}