pub struct EventEnvelope {
pub event_id: EventId,
pub event_type: String,
pub repository: Repository,
pub entity_type: EntityType,
pub entity_id: Option<String>,
pub session_id: Option<String>,
pub payload: EventPayload,
pub metadata: EventMetadata,
pub trace_context: Option<TraceContext>,
}Expand description
Primary event container that wraps all GitHub events in a normalized format.
The EventEnvelope provides a consistent structure for all webhook events, regardless of their source event type. It includes metadata for routing, correlation, and session-based ordering.
§Examples
use github_bot_sdk::events::{EventEnvelope, EventPayload, EntityType};
use github_bot_sdk::client::{Repository, RepositoryOwner, OwnerType};
use serde_json::json;
use chrono::Utc;
let payload = EventPayload::new(json!({"action": "opened"}));
let envelope = EventEnvelope::new(
"pull_request".to_string(),
repository,
payload,
);
assert_eq!(envelope.event_type, "pull_request");
assert_eq!(envelope.entity_type, EntityType::PullRequest);Fields§
§event_id: EventIdUnique identifier for this event
event_type: StringGitHub event type (e.g., “pull_request”, “issues”, “push”)
repository: RepositoryRepository where the event occurred
entity_type: EntityTypePrimary entity type involved in the event
entity_id: Option<String>Identifier of the primary entity (e.g., PR number, issue number)
session_id: Option<String>Session ID for ordered processing of related events
payload: EventPayloadRaw event payload from GitHub
metadata: EventMetadataProcessing and routing metadata
trace_context: Option<TraceContext>Distributed tracing context
Implementations§
Source§impl EventEnvelope
impl EventEnvelope
Sourcepub fn new(
event_type: String,
repository: Repository,
payload: EventPayload,
) -> Self
pub fn new( event_type: String, repository: Repository, payload: EventPayload, ) -> Self
Create a new event envelope.
§Examples
let payload = EventPayload::new(json!({"action": "opened"}));
let envelope = EventEnvelope::new("pull_request".to_string(), repository, payload);Sourcepub fn with_session_id(self, session_id: String) -> Self
pub fn with_session_id(self, session_id: String) -> Self
Add a session ID for ordered processing.
Sourcepub fn with_trace_context(self, context: TraceContext) -> Self
pub fn with_trace_context(self, context: TraceContext) -> Self
Add trace context for distributed tracing.
Sourcepub fn entity_key(&self) -> String
pub fn entity_key(&self) -> String
Get a unique key for the primary entity.
Returns a string in the format “repo:owner/name:entity_type:entity_id” for entities with IDs, or “repo:owner/name” for repository-level events.
Sourcepub fn correlation_id(&self) -> &str
pub fn correlation_id(&self) -> &str
Get the correlation ID for this event.
Returns the event ID as a string for correlation across system boundaries.
Trait Implementations§
Source§impl Clone for EventEnvelope
impl Clone for EventEnvelope
Source§fn clone(&self) -> EventEnvelope
fn clone(&self) -> EventEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more