Expand description
§razor-stream
This crate provides a low-level streaming interface for razor-rpc.
It is used for stream processing and is part of the modular design of razor-rpc.
If you are looking for a high-level remote API call interface, use razor-rpc instead.
§Components
razor-rpc is designed to be modular and pluggable. It is a collection of crates that provide different functionalities:
razor-rpc-codec: Provides codecs for serialization, such asmsgpack.- Async runtime support by
orb: - Transports can be implemented with a raw socket, without the overhead of the HTTP protocol:
razor-rpc-tcp: A TCP transport implementation.
For Rpc tasks, we choose Debug instead of Display when logging, recommend use
format-attr to customized your message format.
§The Design
Our implementation is designed to optimize throughput and lower CPU consumption for high-performance services.
Each connection is a full-duplex, multiplexed stream.
There’s a seq ID assigned to a packet to track
a request and response. The timeout of a packet is checked in batches every second.
We utilize the crossfire channel for parallelizing the work with
coroutines.
With an ClientStream, the request packets sent in sequence, and wait with a sliding window throttler controlling the number of in-flight packets. An internal timer then registers the request through a channel, and when the response is received, it can optionally notify the user through a user-defined channel or another mechanism.
ConnPool and FailoverPool are provided on top of ClientStream for user.
In an RpcServer, for each connection, there is one coroutine to read requests and one coroutine to write responses. Requests can be dispatched with a user-defined Dispatch trait implementation.
Responses are received through a channel wrapped in RespNoti.
§Protocol
The details are described in crate::proto.
Also see the error module for details on built-in error types and custom error type examples.
§Usage
You can refer to the test case for example.
Modules§
- buffer
- client
- The module contains traits defined for the client-side
- error
- Error handling for razor-stream RPC framework.
- proto
- The protocol
- server
- This module contains traits defined for the server-side
Traits§
- Codec
- The codec is immutable, if need changing (like setting up cipher), should have inner mutablilty