#service #async #io #rpc

edelcrantz

async peer-to-peer rpc-and-messaging service

9 releases (5 breaking)

0.6.1 Dec 29, 2020
0.6.0 Dec 26, 2020
0.5.0 Dec 13, 2020
0.4.2 Dec 9, 2020
0.1.0 Jul 18, 2020

#227 in #rpc


Used in 2 crates (via clepsydra)

MIT/Apache

25KB
419 lines

Edelcrantz

This is a small crate for writing network services, with the following particular features:

  • Asynchronous communication of serde-serializable types.
  • Symmetric / peer-to-peer: no distinguished clients or servers.
  • Pipelined: many requests allowed in flight at once.
  • Support for "one-way" requests with no paired responses.
  • Async-ecosystem agnostic: doesn't drag in async_std or tokio (except as dev-dependencies for testing).

There is no integrated event loop nor task spawning: you are expected to call methods on this crate's main Connection type from your own tasks or async functions.

Name

Abraham Niclas Edelcrantz (1754-1821) developed the Swedish optical telegraph system, which operated from 1795-1881.


lib.rs:

This is a small crate for writing network services, with the following particular features:

  • Asynchronous communication of serde-serializable types.
  • Symmetric / peer-to-peer: no distinguished clients or servers.
  • Pipelined: many requests allowed in flight at once.
  • Support for "one-way" requests with no paired responses.
  • Async-ecosystem agnostic: doesn't drag in async_std or tokio (except as dev-dependencies for testing).

There is no integrated event loop nor task spawning: you are expected to call methods on this crate's main [Connection] type from your own tasks or async functions.

Usage

This crate expects callers to take three main steps:

  • Enqueueing a message to send, either a one-way message via Connection::enqueue_oneway which generates no corresponding future, or via Connection::enqueue_request which generates a future that will be filled in when a paired response arrives.
  • Calling Connection::advance and awaiting its returned future (typically in a loop) to advance the peer through internal steps of dequeueing, sending, receiveing, serving, responding, and fulfilling response futures. This requires the caller to provide callbacks.
  • Optionally awaiting the response future generated in the first step.

Sequencing these steps and integrating them into a set of async tasks or event loops is left to the caller. Some examples are present in the test module.

Name

Abraham Niclas Edelcrantz (1754-1821) developed the Swedish optical telegraph system, which operated from 1795-1881.

Dependencies

~1.8–2.7MB
~51K SLoC