Skip to content

Commit 1779dbe

Browse files
HCastanotomusdrw
andauthored
Add a subscription manager (#548)
* WIP: Add a subscription manager. The idea is to use the `Subscriptions` struct from Substrate, which is used to drive subscription futures to completion, and modify it for "general" use. * Allow IdProvider::Id and SubscriptionId to work together Adds trait bounds that allow conversion between the two, removing the need for generics in SubscriptionId. * Update SubscriptionId tests * Rustfmt * Use `SubscriptionId` as the key for `active_subscriptions` * Add subscription ID providers. Adds two subscription ID providers which can be used by the SubscriptionManager. One provides a simple numeric ID, while the other provides a random string. * Add some documentation * Clean up comment and naming * Change the NumericIdProvider to use `u64` IDs Instead of providing a guarantee that we can convert between `usize` and `u64` we make the assumptions that it's unlikely that we're running on an architecture larger than 64-bits and we use a `u64` directly. * Add tests for IdProvider and SubscriptionManager Note: There's one test that doesn't pass yet which has to do with the `cancel()` function of the SubscriptionManager. * Restore RandomStringIdProvider as the default provider * Retain receiver.: * Make test executor a lazy static * Rustfmt * Add a comment to test * Remove `matches!` macro Our Windows CI runner isn't up to date and thinks this is still a nightly feature Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
1 parent 0d31c50 commit 1779dbe

File tree

4 files changed

+464
-27
lines changed

4 files changed

+464
-27
lines changed

pubsub/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ log = "0.4"
1515
parking_lot = "0.10.0"
1616
jsonrpc-core = { version = "14.1", path = "../core" }
1717
serde = "1.0"
18+
rand = "0.7"
1819

1920
[dev-dependencies]
2021
jsonrpc-tcp-server = { version = "14.1", path = "../tcp" }
22+
futures = { version = "0.3", features = ["compat", "thread-pool"] }
23+
lazy_static = "1.4"
2124

2225
[badges]
2326
travis-ci = { repository = "paritytech/jsonrpc", branch = "master"}

pubsub/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern crate log;
99

1010
mod delegates;
1111
mod handler;
12+
pub mod manager;
1213
pub mod oneshot;
1314
mod subscription;
1415
pub mod typed;

0 commit comments

Comments
 (0)