Skip to main content

Crate envoy_grpc_ext_proc

Crate envoy_grpc_ext_proc 

Source
Expand description

§Envoy External Processor gRPC Stubs

Pre-compiled gRPC client and server stubs for Envoy’s external processor (ext_proc) protocol. Includes all necessary protobuf definitions and generated Rust code for building external processors that intercept and modify HTTP requests and responses in Envoy.

§Server Example

Here’s a complete example of implementing an external processor server:

use std::pin;
use futures::Stream;
use envoy_grpc_ext_proc::envoy::service::ext_proc::v3;
use tonic::{Request, Response, Status, Streaming, async_trait, transport,};

struct MyExternalProcessor;

#[async_trait]
impl v3::external_processor_server::ExternalProcessor for MyExternalProcessor {
    type ProcessStream = pin::Pin<
        Box<dyn Stream<Item = Result<v3::ProcessingResponse, Status>> + Send + 'static>,
    >;

    async fn process(
        &self,
        request: Request<Streaming<v3::ProcessingRequest>>,
    ) -> Result<Response<Self::ProcessStream>, Status> {
        todo!()
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let addr = "[::1]:50051".parse()?;
    let processor = MyExternalProcessor;

    transport::Server::builder()
        .add_service(v3::external_processor_server::ExternalProcessorServer::new(processor))
        .serve(addr);
    //  .await?;  // to avoid server running on doc tests

    Ok(())
}

Modules§

envoy
Envoy API definitions and services
udpa
Universal Data Plane API (UDPA) definitions
validate
Protocol buffer validation rules and constraints
xds
xDS (configuration discovery service) API definitions