pub struct CollaborationEvent {
pub correlation_id: String,
pub topic: String,
pub producer: String,
pub consumer: Option<String>,
pub kind: CollaborationEventKind,
pub payload: Value,
pub timestamp: u64,
}Expand description
A typed collaboration event for cross-agent coordination in a shared workspace.
Collaboration events carry correlation IDs, topic names, producer/consumer
identities, and structured payloads. They support the wait/resume pattern:
an agent can publish a CollaborationEventKind::NeedWork event and resume
only when a matching CollaborationEventKind::WorkPublished event arrives.
§Example
use adk_code::{CollaborationEvent, CollaborationEventKind};
let event = CollaborationEvent::new(
"corr-42",
"api-routes",
"backend_engineer",
CollaborationEventKind::WorkPublished,
)
.consumer("frontend_engineer")
.payload(serde_json::json!({ "routes": ["/api/users"] }));
assert_eq!(event.correlation_id, "corr-42");
assert_eq!(event.consumer.as_deref(), Some("frontend_engineer"));Fields§
§correlation_id: StringCorrelation ID linking related events (e.g., request and response).
topic: StringTopic or work item name this event relates to.
producer: StringIdentity of the agent that produced this event.
consumer: Option<String>Identity of the intended consumer, if targeted.
kind: CollaborationEventKindThe kind of collaboration event.
payload: ValueStructured payload carrying event-specific data.
timestamp: u64Timestamp when the event was created (Unix epoch milliseconds).
Implementations§
Source§impl CollaborationEvent
impl CollaborationEvent
Sourcepub fn new(
correlation_id: impl Into<String>,
topic: impl Into<String>,
producer: impl Into<String>,
kind: CollaborationEventKind,
) -> Self
pub fn new( correlation_id: impl Into<String>, topic: impl Into<String>, producer: impl Into<String>, kind: CollaborationEventKind, ) -> Self
Create a new collaboration event with the given correlation ID, topic, producer, and kind.
The payload defaults to null, consumer defaults to None, and
timestamp defaults to 0 (callers should set it via Self::timestamp).
§Example
use adk_code::{CollaborationEvent, CollaborationEventKind};
let event = CollaborationEvent::new(
"req-1",
"database-schema",
"coordinator",
CollaborationEventKind::NeedWork,
);
assert_eq!(event.kind, CollaborationEventKind::NeedWork);
assert_eq!(event.producer, "coordinator");Trait Implementations§
Source§impl Clone for CollaborationEvent
impl Clone for CollaborationEvent
Source§fn clone(&self) -> CollaborationEvent
fn clone(&self) -> CollaborationEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more