Struct TAsyncServer

Source
pub struct TAsyncServer<P: TProcessor + Send + Sync + 'static> { /* private fields */ }

Implementations§

Source§

impl<P: TProcessor + Send + Sync + 'static> TAsyncServer<P>

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

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>

Source§

fn clone(&self) -> TAsyncServer<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug + TProcessor + Send + Sync + 'static> Debug for TAsyncServer<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Freeze for TAsyncServer<P>

§

impl<P> RefUnwindSafe for TAsyncServer<P>
where P: RefUnwindSafe,

§

impl<P> Send for TAsyncServer<P>

§

impl<P> Sync for TAsyncServer<P>

§

impl<P> Unpin for TAsyncServer<P>

§

impl<P> UnwindSafe for TAsyncServer<P>
where P: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Err = <U as TryFrom<T>>::Err

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>