Crates.io | nats-aflowt |
lib.rs | nats-aflowt |
version | 0.16.105 |
source | src |
created_at | 2022-01-08 22:31:48.573255 |
updated_at | 2022-02-14 17:32:40.484504 |
description | Unofficial port of NATS rust client to pure async |
homepage | https://github.com/stevelr/nats.rs |
repository | https://github.com/stevelr/nats.rs |
max_upload_size | |
id | 510571 |
size | 581,632 |
Don't get blocked by asynk - stay aflowt
The nats::asynk module is an async veneer over blocking io and consumes a thread-per-connection, and, depending on how you use subscriptions, an additional thread per subscription handler. This package uses real async throughout the client. All connections and subscriptions are non-blocking and may safely share the same thread, or, optionally, a thread pool.
This package is not endorsed by the Nats team.
I wrote it as an experiment after running into some limitations with
ratsio
, another nats async client.
:warning: This should only be used in environments where software is expected to hang, consume all CPU, destroy data, and explode at random intervals.
Feature parity with rust nats client (including jetstream, tls, etc.) as of commit d22329c (main branch, jan 7, 2022)
Tested on linux x86_64. All tests pass except for two: (jetstream:kv and jetstream:object_store), which are currently disabled by a feature flag.
apis are subject to change
can run all async tasks in a single thread (subscriptions and connections do not spawn new threads)
in the port to async, many apis have changed:
async
Iterator
now return futures::Stream
iter(..)
method to create an
iterator, it's been replaced with stream(..)
.PagedIterator
replaced with Stream
Subscription.with_async_handler
to take async closure
Subscription.with_handler
still takes sync closure)jetstream kv and object_store functions are enabled in this crate
in the default feature set to support testing.
(In nats.rs
they are behind an "unstable" feature flag
and should be considered unstable here).
some tests have been added
upgraded to rust 2021 edition
This crate currently depends on the tokio runtime. I suspect if the Nats team does develop a pure async rust client, they will attempt to make it runtime agnostic.