pub struct MockReflectionProxy { /* private fields */ }
Expand description
A mock-enabled reflection proxy that serves mock responses
Implementations§
Source§impl MockReflectionProxy
impl MockReflectionProxy
Sourcepub async fn handle_unary_request(
&self,
request: Request<DynamicMessage>,
) -> Result<Response<DynamicMessage>, Status>
pub async fn handle_unary_request( &self, request: Request<DynamicMessage>, ) -> Result<Response<DynamicMessage>, Status>
Handle a unary gRPC request
Sourcepub async fn handle_server_streaming_request(
&self,
request: Request<DynamicMessage>,
) -> Result<Response<ReceiverStream<Result<DynamicMessage, Status>>>, Status>
pub async fn handle_server_streaming_request( &self, request: Request<DynamicMessage>, ) -> Result<Response<ReceiverStream<Result<DynamicMessage, Status>>>, Status>
Handle a server streaming gRPC request
Sourcepub async fn handle_client_streaming_request(
&self,
request: Request<Streaming<DynamicMessage>>,
) -> Result<Response<DynamicMessage>, Status>
pub async fn handle_client_streaming_request( &self, request: Request<Streaming<DynamicMessage>>, ) -> Result<Response<DynamicMessage>, Status>
Handle a client streaming gRPC request
Sourcepub async fn handle_bidirectional_streaming_request(
&self,
request: Request<Streaming<DynamicMessage>>,
) -> Result<Response<ReceiverStream<Result<DynamicMessage, Status>>>, Status>
pub async fn handle_bidirectional_streaming_request( &self, request: Request<Streaming<DynamicMessage>>, ) -> Result<Response<ReceiverStream<Result<DynamicMessage, Status>>>, Status>
Handle a bidirectional streaming gRPC request
Source§impl MockReflectionProxy
impl MockReflectionProxy
Sourcepub async fn preprocess_request<T>(
&self,
request: &mut Request<T>,
) -> Result<(), Status>where
T: ReflectMessage,
pub async fn preprocess_request<T>(
&self,
request: &mut Request<T>,
) -> Result<(), Status>where
T: ReflectMessage,
Apply request preprocessing middleware
Sourcepub async fn log_request<T>(
&self,
request: &Request<T>,
service_name: &str,
method_name: &str,
)where
T: ReflectMessage,
pub async fn log_request<T>(
&self,
request: &Request<T>,
service_name: &str,
method_name: &str,
)where
T: ReflectMessage,
Apply request logging middleware
Sourcepub async fn postprocess_response<T>(
&self,
response: &mut Response<T>,
service_name: &str,
method_name: &str,
) -> Result<(), Status>
pub async fn postprocess_response<T>( &self, response: &mut Response<T>, service_name: &str, method_name: &str, ) -> Result<(), Status>
Apply response postprocessing middleware
Sourcepub async fn postprocess_dynamic_response(
&self,
response: &mut Response<DynamicMessage>,
service_name: &str,
method_name: &str,
) -> Result<(), Status>
pub async fn postprocess_dynamic_response( &self, response: &mut Response<DynamicMessage>, service_name: &str, method_name: &str, ) -> Result<(), Status>
Apply response postprocessing with body transformations for DynamicMessage responses
Sourcepub async fn postprocess_streaming_dynamic_response(
&self,
response: &mut Response<ReceiverStream<Result<DynamicMessage, Status>>>,
service_name: &str,
method_name: &str,
) -> Result<(), Status>
pub async fn postprocess_streaming_dynamic_response( &self, response: &mut Response<ReceiverStream<Result<DynamicMessage, Status>>>, service_name: &str, method_name: &str, ) -> Result<(), Status>
Apply response postprocessing for streaming DynamicMessage responses
Source§impl MockReflectionProxy
impl MockReflectionProxy
Sourcepub async fn new(
config: ProxyConfig,
service_registry: Arc<ServiceRegistry>,
) -> Result<Self, Status>
pub async fn new( config: ProxyConfig, service_registry: Arc<ServiceRegistry>, ) -> Result<Self, Status>
Create a new mock reflection proxy
Sourcepub fn config(&self) -> &ProxyConfig
pub fn config(&self) -> &ProxyConfig
Get the proxy configuration
Sourcepub fn cache(&self) -> &DescriptorCache
pub fn cache(&self) -> &DescriptorCache
Get the descriptor cache
Sourcepub fn service_registry(&self) -> &Arc<ServiceRegistry>
pub fn service_registry(&self) -> &Arc<ServiceRegistry>
Get the service registry
Sourcepub fn service_names(&self) -> Vec<String>
pub fn service_names(&self) -> Vec<String>
Get the list of service names
Sourcepub fn smart_generator(&self) -> &Arc<Mutex<SmartMockGenerator>>
pub fn smart_generator(&self) -> &Arc<Mutex<SmartMockGenerator>>
Get the smart mock generator
Sourcepub fn should_mock_service_method(
&self,
service_name: &str,
_method_name: &str,
) -> bool
pub fn should_mock_service_method( &self, service_name: &str, _method_name: &str, ) -> bool
Check if a service method should be mocked
Sourcepub fn timeout_duration(&self) -> Duration
pub fn timeout_duration(&self) -> Duration
Get the timeout duration for requests
Sourcepub fn update_config(&mut self, config: ProxyConfig)
pub fn update_config(&mut self, config: ProxyConfig)
Update the proxy configuration
Sourcepub fn track_connection(&self) -> ConnectionGuard
pub fn track_connection(&self) -> ConnectionGuard
Create a connection guard that tracks active connections
Sourcepub async fn get_stats(&self) -> ProxyStats
pub async fn get_stats(&self) -> ProxyStats
Get statistics about the proxy
Source§impl MockReflectionProxy
impl MockReflectionProxy
Sourcepub async fn validate_request(
&self,
request: &Request<DynamicMessage>,
service_name: &str,
method_name: &str,
) -> Result<(), Status>
pub async fn validate_request( &self, request: &Request<DynamicMessage>, service_name: &str, method_name: &str, ) -> Result<(), Status>
Validate a request against the service method schema
Sourcepub async fn validate_response(
&self,
response: &DynamicMessage,
service_name: &str,
method_name: &str,
) -> Result<(), Status>
pub async fn validate_response( &self, response: &DynamicMessage, service_name: &str, method_name: &str, ) -> Result<(), Status>
Validate response data against the method’s response schema
Sourcepub async fn route_request<T>(
&self,
request: Request<T>,
) -> Result<(String, String, Request<T>), Status>
pub async fn route_request<T>( &self, request: Request<T>, ) -> Result<(String, String, Request<T>), Status>
Route a request to the appropriate handler
Sourcepub async fn can_handle_service_method(
&self,
service_name: &str,
method_name: &str,
) -> bool
pub async fn can_handle_service_method( &self, service_name: &str, method_name: &str, ) -> bool
Check if a service method should be processed by this proxy
Sourcepub async fn validate_service_method_signature(
&self,
service_name: &str,
method_name: &str,
input_descriptor: MessageDescriptor,
output_descriptor: MessageDescriptor,
) -> Result<(), Status>
pub async fn validate_service_method_signature( &self, service_name: &str, method_name: &str, input_descriptor: MessageDescriptor, output_descriptor: MessageDescriptor, ) -> Result<(), Status>
Validate service method signature compatibility
Sourcepub fn value_matches_kind(value: &Value, kind: Kind) -> bool
pub fn value_matches_kind(value: &Value, kind: Kind) -> bool
Check if a Value matches a Kind
Sourcepub async fn validate_request_size<T>(
&self,
request: &Request<T>,
max_size: usize,
) -> Result<(), Status>where
T: Message,
pub async fn validate_request_size<T>(
&self,
request: &Request<T>,
max_size: usize,
) -> Result<(), Status>where
T: Message,
Validate request size limits
Sourcepub async fn validate_response_size(
&self,
response: &DynamicMessage,
max_size: usize,
) -> Result<(), Status>
pub async fn validate_response_size( &self, response: &DynamicMessage, max_size: usize, ) -> Result<(), Status>
Validate response size limits
Sourcepub fn should_skip_validation(
&self,
service_name: &str,
method_name: &str,
) -> bool
pub fn should_skip_validation( &self, service_name: &str, method_name: &str, ) -> bool
Check if request should be skipped for validation (admin endpoints, etc.)
Sourcepub fn get_validation_mode_for_method(
&self,
service_name: &str,
method_name: &str,
) -> ValidationMode
pub fn get_validation_mode_for_method( &self, service_name: &str, method_name: &str, ) -> ValidationMode
Apply validation mode for a service method
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MockReflectionProxy
impl !RefUnwindSafe for MockReflectionProxy
impl Send for MockReflectionProxy
impl Sync for MockReflectionProxy
impl Unpin for MockReflectionProxy
impl !UnwindSafe for MockReflectionProxy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request