Skip to main content

backbone_support/application/service/
support_events.rs

1//! Support domain events (hand-authored, user-owned) — the public extension surface.
2//!
3//! backbone-support posts NO GL and owns no money. Its events are read-side signals: an SLA outcome
4//! (`IssueResolved` carrying whether the resolution deadline was met), a ticket escalated into delivery
5//! work (`IssueEscalated`), and a warranty claim filed (`WarrantyClaimFiled` carrying the under-warranty
6//! verdict). A consuming service supplies the sink (bus, outbox, …).
7
8use serde::{Deserialize, Serialize};
9use uuid::Uuid;
10
11/// A ticket was resolved — `fulfilled` is true iff it was resolved within the (pause-adjusted) SLA
12/// resolution deadline.
13#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
14pub struct IssueResolved {
15    pub issue_id: Uuid,
16    pub fulfilled: bool,
17}
18
19/// A ticket was escalated into a real backbone-project delivery Project.
20#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
21pub struct IssueEscalated {
22    pub issue_id: Uuid,
23    pub project_id: Uuid,
24}
25
26/// A warranty claim was filed — `is_under_warranty` is the coverage verdict at file time.
27#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
28pub struct WarrantyClaimFiled {
29    pub claim_id: Uuid,
30    pub is_under_warranty: bool,
31}
32
33/// The support domain-event union.
34#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
35#[serde(tag = "type")]
36pub enum SupportEvent {
37    IssueResolved(IssueResolved),
38    IssueEscalated(IssueEscalated),
39    WarrantyClaimFiled(WarrantyClaimFiled),
40}
41
42/// Sink the write path publishes to. A consuming service supplies its own (bus, outbox, …).
43pub trait SupportEventSink: Send + Sync {
44    fn publish(&self, event: &SupportEvent);
45}
46
47/// A no-op/logging sink for tests and single-process composition.
48#[derive(Debug, Default, Clone)]
49pub struct LoggingSink;
50
51impl SupportEventSink for LoggingSink {
52    fn publish(&self, event: &SupportEvent) {
53        tracing::info!(?event, "support event");
54    }
55}