pub struct TAsyncServer<P: TProcessor + Send + Sync + 'static> { /* private fields */ }
Implementations§
Source§impl<P: TProcessor + Send + Sync + 'static> TAsyncServer<P>
impl<P: TProcessor + Send + Sync + 'static> TAsyncServer<P>
Sourcepub fn new(processor: P) -> TAsyncServer<P>
pub fn new(processor: P) -> TAsyncServer<P>
Create a new almost-asynchronous server, from a synchronous request TProcessor
.
Input/Output transports must be framed. Input/Output protocol must be binary.
The server accepts incoming connections, keeping two frame buffers: for reading and writing
to the connection socket. All read/write operations happen asynchronously (leveraging
tokio
).
Once a frame is fully read, processing happen synchronously within tokio’s runtime.
NOTE this crate is compatible with code generation from the thrift
crate (fully
synchronous), hence the almost-asynchronous (or half async, half sync) model.
Sourcepub fn max_frame_size(&mut self, max_frame_size: u32) -> &mut Self
pub fn max_frame_size(&mut self, max_frame_size: u32) -> &mut Self
The maximum read frame size allowed per client for this server.
Non-framed messages can be interpreted as a huge frame size and can put a big hit on the server memory footprint. Limiting the maximum frame size can prevent ill-formed data from having too much effect.
Default: 256 MB
Sourcepub fn core_read_frame_size(&mut self, core_read_frame_size: u32) -> &mut Self
pub fn core_read_frame_size(&mut self, core_read_frame_size: u32) -> &mut Self
The read frame size at which the server is happy to run with.
Frame buffer size can temporarily grow higher than this limit (but never higher than
max_frame_size
), but the size will periodically be checked.
If the frame buffer size is higher than this limit during the check, the buffer will be
rebuilt, to reduce memory footprint.
Default: 2 MB
Sourcepub fn core_write_frame_size(&mut self, core_write_frame_size: u32) -> &mut Self
pub fn core_write_frame_size(&mut self, core_write_frame_size: u32) -> &mut Self
The write frame size at which the server is happy to run with. Frame buffer size can temporarily grow higher than this limit, but the size will periodically be checked. If the frame buffer size is higher than this limit during the check, the buffer will be rebuilt, to reduce memory footprint.
Default: 2 MB
Sourcepub fn core_resize_frequency(&mut self, core_resize_frequency: u64) -> &mut Self
pub fn core_resize_frequency(&mut self, core_resize_frequency: u64) -> &mut Self
The frequency at which frame buffers size will be checked against their core size.
Frequency represents the number of frames processed per client connection.
e.g: check every 512 received requests per client.
Default: 512
Sourcepub fn listen(&mut self, address: &str) -> Result<(), Error>
pub fn listen(&mut self, address: &str) -> Result<(), Error>
Listen for incoming connections on address
.
address
should be in the form host:port
.
e.g: 127.0.0.1:8080
.
Returns an error if the address cannot be parsed, or cannot be bound.
Sourcepub fn listen_address(&mut self, address: SocketAddr) -> Result<(), Error>
pub fn listen_address(&mut self, address: SocketAddr) -> Result<(), Error>
Listen for incoming connections on address
.
Returns an error if the address cannot not be bound.
Trait Implementations§
Source§impl<P: Clone + TProcessor + Send + Sync + 'static> Clone for TAsyncServer<P>
impl<P: Clone + TProcessor + Send + Sync + 'static> Clone for TAsyncServer<P>
Source§fn clone(&self) -> TAsyncServer<P>
fn clone(&self) -> TAsyncServer<P>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more