pub struct ProtosocketServer<Connector: ServerConnector> { /* private fields */ }
Expand description
A protosocket::Connection
is an IO driver. It directly uses tokio’s io wrapper of mio to poll
the OS’s io primitives, manages read and write buffers, and vends messages to & from connections.
Connections send messages to the ConnectionServer through an mpsc channel, and they receive
inbound messages via a reactor callback.
Protosockets are monomorphic messages: You can only have 1 kind of message per service. The expected way to work with this is to use prost and protocol buffers to encode messages. Of course you can do whatever you want, as the telnet example shows.
Protosocket messages are not opinionated about request & reply. If you are, you will need
to implement such a thing. This allows you freely choose whether you want to send
fire-&-forget messages sometimes; however it requires you to write your protocol’s rules.
You get an inbound iterable of
A ProtosocketServer is a future: You spawn it and it runs forever.
Implementations§
Source§impl<Connector: ServerConnector> ProtosocketServer<Connector>
impl<Connector: ServerConnector> ProtosocketServer<Connector>
Sourcepub async fn new(
address: SocketAddr,
runtime: Handle,
connector: Connector,
) -> Result<Self>
pub async fn new( address: SocketAddr, runtime: Handle, connector: Connector, ) -> Result<Self>
Construct a new ProtosocketServer
listening on the provided address.
The address will be bound and listened upon with SO_REUSEADDR
set.
The server will use the provided runtime to spawn new tcp connections as protosocket::Connection
s.
Sourcepub fn set_max_buffer_length(&mut self, max_buffer_length: usize)
pub fn set_max_buffer_length(&mut self, max_buffer_length: usize)
Set the maximum buffer length for connections created by this server after the setting is applied.
Sourcepub fn set_max_queued_outbound_messages(
&mut self,
max_queued_outbound_messages: usize,
)
pub fn set_max_queued_outbound_messages( &mut self, max_queued_outbound_messages: usize, )
Set the maximum queued outbound messages for connections created by this server after the setting is applied.