sentinel_proxy/agents/
context.rs

1//! Agent call context.
2
3use sentinel_agent_protocol::RequestMetadata;
4use sentinel_common::CorrelationId;
5
6/// Agent call context.
7///
8/// Contains all information needed for an agent to process a request,
9/// including correlation ID, request metadata, and optional body data.
10pub struct AgentCallContext {
11    /// Correlation ID for request tracing
12    pub correlation_id: CorrelationId,
13    /// Request metadata
14    pub metadata: RequestMetadata,
15    /// Route ID
16    pub route_id: Option<String>,
17    /// Upstream ID
18    pub upstream_id: Option<String>,
19    /// Request body buffer (if body inspection enabled)
20    pub request_body: Option<Vec<u8>>,
21    /// Response body buffer (if body inspection enabled)
22    pub response_body: Option<Vec<u8>>,
23}
24
25impl AgentCallContext {
26    /// Create a new agent call context.
27    pub fn new(correlation_id: CorrelationId, metadata: RequestMetadata) -> Self {
28        Self {
29            correlation_id,
30            metadata,
31            route_id: None,
32            upstream_id: None,
33            request_body: None,
34            response_body: None,
35        }
36    }
37
38    /// Set the route ID.
39    pub fn with_route_id(mut self, route_id: impl Into<String>) -> Self {
40        self.route_id = Some(route_id.into());
41        self
42    }
43
44    /// Set the upstream ID.
45    pub fn with_upstream_id(mut self, upstream_id: impl Into<String>) -> Self {
46        self.upstream_id = Some(upstream_id.into());
47        self
48    }
49}