pub struct DynamicGrpcService { /* private fields */ }
Expand description
A dynamically generated gRPC service
Implementations§
Source§impl DynamicGrpcService
impl DynamicGrpcService
Sourcepub fn new(
service: ProtoService,
latency_injector: Option<LatencyInjector>,
) -> Self
pub fn new( service: ProtoService, latency_injector: Option<LatencyInjector>, ) -> Self
Create a new dynamic gRPC service
Sourcepub fn new_enhanced(
service: ProtoService,
latency_injector: Option<LatencyInjector>,
proto_parser: Option<ProtoParser>,
smart_config: SmartMockConfig,
) -> Self
pub fn new_enhanced( service: ProtoService, latency_injector: Option<LatencyInjector>, proto_parser: Option<ProtoParser>, smart_config: SmartMockConfig, ) -> Self
Create a new enhanced dynamic gRPC service with proto parser and smart generator
Sourcepub fn descriptor_pool(&self) -> Option<&DescriptorPool>
pub fn descriptor_pool(&self) -> Option<&DescriptorPool>
Get the descriptor pool if available
Sourcepub fn smart_generator(&self) -> &Arc<Mutex<SmartMockGenerator>>
pub fn smart_generator(&self) -> &Arc<Mutex<SmartMockGenerator>>
Get the smart generator for external use
Sourcepub fn service(&self) -> &ProtoService
pub fn service(&self) -> &ProtoService
Get the service definition
Sourcepub async fn handle_unary(
&self,
method_name: &str,
_request: Request<Any>,
) -> Result<Response<Any>, Status>
pub async fn handle_unary( &self, method_name: &str, _request: Request<Any>, ) -> Result<Response<Any>, Status>
Handle a unary request
Sourcepub async fn handle_server_streaming(
&self,
method_name: &str,
request: Request<Any>,
) -> Result<Response<ReceiverStream<Result<Any, Status>>>, Status>
pub async fn handle_server_streaming( &self, method_name: &str, request: Request<Any>, ) -> Result<Response<ReceiverStream<Result<Any, Status>>>, Status>
Handle a server streaming request
Sourcepub async fn handle_client_streaming(
&self,
method_name: &str,
request: Request<Streaming<Any>>,
) -> Result<Response<Any>, Status>
pub async fn handle_client_streaming( &self, method_name: &str, request: Request<Streaming<Any>>, ) -> Result<Response<Any>, Status>
Handle a client streaming request
Sourcepub async fn handle_bidirectional_streaming(
&self,
method_name: &str,
request: Request<Streaming<Any>>,
) -> Result<Response<ReceiverStream<Result<Any, Status>>>, Status>
pub async fn handle_bidirectional_streaming( &self, method_name: &str, request: Request<Streaming<Any>>, ) -> Result<Response<ReceiverStream<Result<Any, Status>>>, Status>
Handle a bidirectional streaming request
Sourcepub fn service_name(&self) -> &str
pub fn service_name(&self) -> &str
Get the service name
Sourcepub fn set_mock_response(&mut self, method_name: &str, response: MockResponse)
pub fn set_mock_response(&mut self, method_name: &str, response: MockResponse)
Set a custom mock response for a method
Sourcepub fn set_error_simulation(
&mut self,
method_name: &str,
error_message: &str,
error_code: i32,
)
pub fn set_error_simulation( &mut self, method_name: &str, error_message: &str, error_code: i32, )
Set error simulation for a method
Sourcepub fn methods(&self) -> &Vec<ProtoMethod>
pub fn methods(&self) -> &Vec<ProtoMethod>
Get the service methods
Auto Trait Implementations§
impl Freeze for DynamicGrpcService
impl RefUnwindSafe for DynamicGrpcService
impl Send for DynamicGrpcService
impl Sync for DynamicGrpcService
impl Unpin for DynamicGrpcService
impl UnwindSafe for DynamicGrpcService
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
Wrap the input message
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>
Wrap the input message
T
in a tonic::Request