Callout Server
This module provides a customizable service callout server with support for header and body transformations.
Class Definition
- class callouts.python.extproc.service.callout_server.CalloutServer(address: tuple[str, int] | None = None, port: int | None = None, health_check_address: tuple[str, int] | None = None, health_check_port: int | None = None, combined_health_check: bool = False, secure_health_check: bool = False, plaintext_address: tuple[str, int] | None = None, plaintext_port: int | None = None, disable_plaintext: bool = False, default_ip: str | None = None, cert_chain: bytes | None = None, cert_chain_path: str | None = './extproc/ssl_creds/chain.pem', private_key: bytes | None = None, private_key_path: str = './extproc/ssl_creds/privatekey.pem', server_thread_count: int = 2)[source]
Bases:
object
Server wrapper for managing callout servers and processing callouts.
- address
Address that the main secure server will attempt to connect to, defaults to default_ip:443.
- port
If specified, overrides the port of address.
- health_check_address
The health check serving address, defaults to default_ip:80.
- health_check_port
If set, overrides the port of health_check_address.
- combined_health_check
If True, does not create a separate health check server.
- secure_health_check
If True, will use HTTPS as the protocol of the health check server. Requires cert_chain_path and private_key_path to be set.
- plaintext_address
The non-authenticated address to listen to, defaults to default_ip:8080.
- plaintext_port
If set, overrides the port of plaintext_address.
- disable_plaintext
If true, disables the plaintext address of the server.
- default_ip
If left None, defaults to ‘0.0.0.0’.
- cert_chain
PEM Certificate chain used to authenticate secure connections, required for secure servers.
- cert_chain_path
Relative file path to the cert_chain.
- private_key
PEM private key of the server.
- private_key_path
Relative file path pointing to a file containing private_key data.
- server_thread_count
Threads allocated to the main grpc service.
CalloutServer Methods
- CalloutServer.run() None [source]
Start all requested servers and listen for new connections; blocking.
- CalloutServer._stop_servers() None [source]
Close the sockets of all servers, and trigger shutdowns.
- CalloutServer._loop_server() None [source]
Loop server forever, calling shutdown will cause the server to stop.
- CalloutServer.process(callout: envoy.service.ext_proc.v3.external_processor_pb2.ProcessingRequest, context: ServicerContext) envoy.service.ext_proc.v3.external_processor_pb2.ProcessingResponse [source]
Process incomming callouts.
- Parameters:
callout – The incomming callout.
context – Stream context on the callout.
- Yields:
ProcessingResponse – A response for the incoming callout.
- CalloutServer.on_request_headers(headers: envoy.service.ext_proc.v3.external_processor_pb2.HttpHeaders, context: ServicerContext) None | envoy.service.ext_proc.v3.external_processor_pb2.HeadersResponse | envoy.service.ext_proc.v3.external_processor_pb2.ImmediateResponse [source]
Process incoming request headers.
- Parameters:
headers – Request headers to process.
context – RPC context of the incoming callout.
- Returns:
Optional header modification object.
- CalloutServer.on_response_headers(headers: envoy.service.ext_proc.v3.external_processor_pb2.HttpHeaders, context: ServicerContext) None | envoy.service.ext_proc.v3.external_processor_pb2.HeadersResponse [source]
Process incoming response headers.
- Parameters:
headers – Response headers to process.
context – RPC context of the incoming callout.
- Returns:
Optional header modification object.
- CalloutServer.on_request_body(body: envoy.service.ext_proc.v3.external_processor_pb2.HttpBody, context: ServicerContext) None | envoy.service.ext_proc.v3.external_processor_pb2.BodyResponse | envoy.service.ext_proc.v3.external_processor_pb2.ImmediateResponse [source]
Process an incoming request body.
- Parameters:
headers – Request body to process.
context – RPC context of the incoming callout.
- Returns:
Optional body modification object.
- CalloutServer.on_response_body(body: envoy.service.ext_proc.v3.external_processor_pb2.HttpBody, context: ServicerContext) None | envoy.service.ext_proc.v3.external_processor_pb2.BodyResponse [source]
Process an incoming response body.
- Parameters:
headers – Response body to process.
context – RPC context of the incoming callout.
- Returns:
Optional body modification object.