envoy_grpc_ext_proc/lib.rs
1#![deny(warnings)]
2
3//! # Envoy External Processor gRPC Stubs
4//!
5//! Pre-compiled gRPC client and server stubs for Envoy's external processor (`ext_proc`) protocol.
6//! Includes all necessary protobuf definitions and generated Rust code for building external
7//! processors that intercept and modify HTTP requests and responses in Envoy.
8//!
9//! ## Server Example
10//!
11//! Here's a complete example of implementing an external processor server:
12//!
13//! ```rust
14//! use std::pin;
15//! use futures::Stream;
16//! use envoy_grpc_ext_proc::envoy::service::ext_proc::v3;
17//! use tonic::{Request, Response, Status, Streaming, async_trait, transport,};
18//!
19//! struct MyExternalProcessor;
20//!
21//! #[async_trait]
22//! impl v3::external_processor_server::ExternalProcessor for MyExternalProcessor {
23//! type ProcessStream = pin::Pin<
24//! Box<dyn Stream<Item = Result<v3::ProcessingResponse, Status>> + Send + 'static>,
25//! >;
26//!
27//! async fn process(
28//! &self,
29//! request: Request<Streaming<v3::ProcessingRequest>>,
30//! ) -> Result<Response<Self::ProcessStream>, Status> {
31//! todo!()
32//! }
33//! }
34//!
35//! #[tokio::main]
36//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
37//! let addr = "[::1]:50051".parse()?;
38//! let processor = MyExternalProcessor;
39//!
40//! transport::Server::builder()
41//! .add_service(v3::external_processor_server::ExternalProcessorServer::new(processor))
42//! .serve(addr);
43//! // .await?; // to avoid server running on doc tests
44//!
45//! Ok(())
46//! }
47//! ```
48//!
49
50/// Envoy API definitions and services
51pub mod envoy {
52 /// Configuration-related types and structures
53 pub mod config {
54 /// Core configuration types used throughout Envoy
55 pub mod core {
56 /// Version 3 of the core configuration API
57 pub mod v3 {
58 include!(concat!(env!("OUT_DIR"), "/envoy.config.core.v3.rs"));
59 }
60 }
61 }
62 /// Envoy extensions and filters
63 pub mod extensions {
64 /// HTTP filters for request/response processing
65 pub mod filters {
66 /// HTTP-specific filters
67 pub mod http {
68 /// External processor HTTP filter
69 pub mod ext_proc {
70 /// Version 3 of the ext_proc filter API
71 pub mod v3 {
72 include!(concat!(
73 env!("OUT_DIR"),
74 "/envoy.extensions.filters.http.ext_proc.v3.rs"
75 ));
76 }
77 }
78 }
79 }
80 }
81 /// Common type definitions used across Envoy
82 pub mod r#type {
83 /// Version 3 of the type definitions
84 pub mod v3 {
85 include!(concat!(env!("OUT_DIR"), "/envoy.r#type.v3.rs"));
86 }
87 }
88 /// Envoy service definitions
89 pub mod service {
90 /// External processor service
91 pub mod ext_proc {
92 /// Version 3 of the external processor service API
93 pub mod v3 {
94 include!(concat!(env!("OUT_DIR"), "/envoy.service.ext_proc.v3.rs"));
95 }
96 }
97 }
98}
99
100/// Protocol buffer validation rules and constraints
101pub mod validate {
102 include!(concat!(env!("OUT_DIR"), "/validate.rs"));
103}
104
105/// Universal Data Plane API (UDPA) definitions
106pub mod udpa {
107 /// UDPA annotations for metadata and configuration
108 pub mod annotations {
109 include!(concat!(env!("OUT_DIR"), "/udpa.annotations.rs"));
110 }
111}
112
113/// xDS (configuration discovery service) API definitions
114pub mod xds {
115 /// xDS annotations for configuration metadata
116 pub mod annotations {
117 /// Version 3 of xDS annotations
118 pub mod v3 {
119 include!(concat!(env!("OUT_DIR"), "/xds.annotations.v3.rs"));
120 }
121 }
122 /// Core xDS types and structures
123 pub mod core {
124 /// Version 3 of xDS core API
125 pub mod v3 {
126 include!(concat!(env!("OUT_DIR"), "/xds.core.v3.rs"));
127 }
128 }
129}