Crate quic_rpc_utils

Source
Expand description

§RPC 工具和结构体

这个模块包含了一些用于处理RPC(远程过程调用)的实用工具和结构体。 它使用了多个库,包括anyhowflumefutures-litefutures-utilquic_rpctokiotracing

§主要组件和功能

  • 导入和重导出:使用pub use语句重导出了一些库中的类型和函数,以便在其他模块中直接使用。
  • GetServiceHandler trait:定义了一个trait,用于获取特定服务的处理程序。
  • ServiceHandler trait:定义了一个trait,用于服务的处理程序。
  • run_server 函数:用于运行一个RPC服务器。
  • ClientStreamingResponse 结构体:用于处理客户端流式RPC响应。
  • ServerStreamingResponse 结构体:用于处理服务器流式RPC响应。

§注意事项

  • 异步处理:代码中大量使用了异步处理,包括async/await关键字和Future trait。
  • 错误处理:代码中使用了ResultError类型进行错误处理。
  • 并发:代码中使用了ArcLazyLock来处理并发访问和延迟初始化。
  • 类型安全:通过trait和泛型,代码确保了类型安全。

§用途

这个模块给微服务框架导出了一些工具函数和结构体,可以处理不同类型的RPC请求,包括客户端流式和服务器流式请求。 它提供了基本的错误处理和并发支持,使得开发者可以更容易地构建高性能的RPC服务。

Macros§

pin
Pins a value on the stack.

Structs§

BidiStreaming
Bidirectional streaming interaction pattern
ClientStreaming
Client streaming interaction pattern
ClientStreamingResponse
Error
The Error type, a wrapper around a dynamic error type.
RpcChannel
A channel for requests and responses for a specific service.
RpcClient
A client for a specific service
RpcServer
A server for a specific service.
Runtime
The Tokio runtime.
ServerStreaming
Server streaming interaction pattern
ServerStreamingResponse
UpdateSink
Sink that can be used to send updates to the server for the two interaction patterns that support it, crate::message::ClientStreaming and crate::message::BidiStreaming.

Enums§

BidiStreamingError
Server error when accepting a bidi request
BidiStreamingItemError
Server error when receiving an item for a bidi request
ClientStreamingError
Server error when accepting a client streaming request
ClientStreamingItemError
Server error when receiving an item for a client streaming request
RpcError
Client error. All client DSL methods return a Result with this error type.
ServerStreamingError
Server error when accepting a server streaming request
ServerStreamingItemError
Client error when handling responses from a server streaming request

Statics§

TIME

Traits§

BidiStreamingMsg
Defines update type and response type for a bidi streaming message.
ChannelTypes
Stream types on the server side
ClientStreamingMsg
Defines update type and response type for a client streaming message.
ConnectionErrors
Errors that can happen when creating and using a Connector or Listener.
Connector
A connector to a specific service
GetServiceHandler
获取特定服务的处理程序
Listener
A listener for a specific service
Msg
Declares the interaction pattern for a message and a service.
RpcMessage
Requirements for a RPC message
RpcMsg
Defines the response type for a rpc message.
ServerStreamingMsg
Defines response type for a server streaming message.
Service
A service
ServiceHandler
服务的处理程序
Stream
A stream of values produced asynchronously.
StreamExt
Extension trait for Stream.

Functions§

flume_bounded
Create a channel with a maximum capacity.
oneshot_channel
Creates a new one-shot channel for sending single values across asynchronous tasks.
run_server

Type Aliases§

BoxStreamSync
Sync version of future::stream::BoxStream.
BoxedChannelTypes
Type alias for when you want to require a boxed channel
BoxedConnector
A boxed connector for the given Service
BoxedListener
A boxed listener for the given Service
Result
Result<T, Error>