#reactor #networking #patterns #poll

io-reactor

Concurrent I/O resource management using reactor pattern

7 releases (4 breaking)

new 0.5.0 Feb 21, 2024
0.4.0 Feb 12, 2024
0.3.0 Jan 10, 2024
0.2.1 May 26, 2023
0.1.0 Jan 23, 2023

#167 in Concurrency

Download history 72/week @ 2023-10-31 61/week @ 2023-11-07 56/week @ 2023-11-14 72/week @ 2023-11-21 66/week @ 2023-11-28 38/week @ 2023-12-05 52/week @ 2023-12-12 58/week @ 2023-12-19 52/week @ 2023-12-26 55/week @ 2024-01-02 161/week @ 2024-01-09 70/week @ 2024-01-16 38/week @ 2024-01-23 75/week @ 2024-01-30 160/week @ 2024-02-06 98/week @ 2024-02-13

384 downloads per month
Used in netservices

Apache-2.0

72KB
1K SLoC

I/O reactor

Build Tests Lints codecov

crates.io Docs Apache-2 licensed

Concurrent I/O without rust async problems

This repository provides a set of libraries for concurrent access to I/O resources (file, network, devices etc) which uses reactor pattern with pluggable poll syscall engines. This allows to handle situations like multiple network connections within the scope of a single thread (see C10k problem).

The crate can be used for building concurrent microservice architectures without polling all APIs with asyncs.

The reactor design pattern is an event handling pattern for handling service requests delivered concurrently to a service handler by one or more inputs. The service handler then demultiplexes the incoming requests and dispatches them synchronously to the associated service[^1].

Core concepts:

  • Resource: any resource that can provide input to or consume output from the system.
  • Runtime: runs an event loop to block on all resources. Sends the resource service when it is possible to start a synchronous operation on a resource without blocking (Example: a synchronous call to read() will block if there is no data to read.
  • Service: custom business logic provided by the application for a given set of resources. Service exposes a Handler API for the reactor runtime. It is also rsponsible for the creation and destruction of the resources.

Documentation

API reference documentation for the library can be accessed at https://docs.rs/io-reactor/.

Licensing

The libraries are distributed on the terms of Apache 2.0 opensource license. See LICENCE file for the license details.

[^1]: Schmidt, Douglas et al. Pattern-Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects. Volume 2. Wiley, 2000.

Dependencies

~0.8–9.5MB
~74K SLoC