You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! Coalescion service to group, caching and queue duplicate actions.
4
+
//! useful for deduplicating web requests, database lookups and other similar resource
5
+
//! intensive or rate-limited actions.
6
+
//!
7
+
//! ## Features
8
+
//! - `tokio`: Uses tokio for the async backend, this is currently the only backend.
9
+
//! - `queue`: Whether to support queueing requests to only allow X amount of actions running at once.
10
+
//! - `cache`: Whether to cache the actions results for future actions with the same id, uses an LRU cache internally.
11
+
//!
12
+
//! [`CoalescionService`] uses both [`Arc`] and [`RwLock`] internally and can be cheaply cloned to
13
+
//! use in your codebase.
14
+
//!
15
+
//! It is common practice to wrap the service and in your own which delegates the executions to ensure all ids are tracked in one location across your codebase.
16
+
//!
17
+
//! All values are stored using [`Any`] and must be [`'static`] + [`Send`] + [`Sync`], if there is an id mismatch
18
+
//! and a type is wrong the library will return an error, values returned from the service are also
19
+
//! wrapped in an [`Arc`] as they are shared to each duplicate action.
20
+
//!
21
+
//! ## Example:
22
+
//! ```rs
23
+
//! use revolt_coalesced::CoalescionService;
24
+
//!
25
+
//! let service = CoalescionService::new();
26
+
//!
27
+
//! let user_id = "my_user_id";
28
+
//! let user = service.execute(user_id, || async move {
0 commit comments