1 unstable release
0.1.0 | Apr 18, 2021 |
---|
#906 in Asynchronous
46KB
652 lines
Netty-rs
Netty-rs allows exposes a simple-to-use API used to create stateful application level network protocols as both a client or server.
Motivation
When implementing p2p applications I found myself implementing the same TCP constructs over and over again in order to be able to implement a custom message passing protocol that allowed for multiplexing different peers and replying to messages. This crate is an attempt to generalize the solution to this problem.
API
Netty-rs allows requires consumers specify how to handle messages in different
circumstances. Whenever specifying this the same API is used by using Connection
.
This very simple API allows consumers to specify restful protocols of varying complexity.
Each message-and-reply chain is in their own channel which does not and is not impacted by
messages sent or received in other message-and-reply chains.
The situations where how to handle messages need to be specified are:
- When a consumer sends a message it can choose to wait for a reply and handle it in a custom way.
- When acting as a server consumers need to specify how to handshake with new connections, which allows custom authentication of clients among any other handshake related action.
- When acting as a server consumers need to specify how to handle non-reply messages from connections that have already been authenticated.
The main API is accessed through the Networker struct.
Netty-rs uses the DirectoryService
trait in order to allow consumers to either implement
their own directory service for example a DNS or use the SimpleDirectoryService
struct that
implements this trait.
See the docs for further documentation and an example.
Dependencies
~4–14MB
~155K SLoC