All Projects → mre → Futures Batch

mre / Futures Batch

Licence: apache-2.0
An adapter for futures, which chunks up elements and flushes them after a timeout, or when the buffer is full. (Formerly known as tokio-batch.)

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Futures Batch

Base64 Async
Non-blocking chunked Base64 encoding
Stars: ✭ 98 (+164.86%)
Mutual labels:  async, chunk
Google Books Android Viewer
Android library to bridge between RecyclerView and sources like web page or database. Includes demonstrator (Google Books viewer)
Stars: ✭ 37 (+0%)
Mutual labels:  async, chunk
Write
Write data to the file system, creating any intermediate directories if they don't already exist. Used by flat-cache and many others!
Stars: ✭ 68 (+83.78%)
Mutual labels:  async, buffer
Hydra
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift
Stars: ✭ 1,954 (+5181.08%)
Mutual labels:  async, futures
Smol
A small and fast async runtime for Rust
Stars: ✭ 2,206 (+5862.16%)
Mutual labels:  async, futures
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+1764.86%)
Mutual labels:  async, futures
Funfix
Functional Programming Library for JavaScript, TypeScript and Flow ✨⚡️
Stars: ✭ 596 (+1510.81%)
Mutual labels:  async, futures
Node Procedural Async
Write procedural style code that runs asynchronously. It may look synchronous, but it's not!
Stars: ✭ 17 (-54.05%)
Mutual labels:  async, futures
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+106894.59%)
Mutual labels:  async
Csp
Communicating Sequential Processes in JavaScript
Stars: ✭ 33 (-10.81%)
Mutual labels:  async
Iguazu Rest
✨ Iguazu REST is a plugin for the Iguazu ecosystem that allows for pre-built async calls for REST with smart caching.
Stars: ✭ 21 (-43.24%)
Mutual labels:  async
React Hydrate
Generic data fetching, caching, and SSR hydration pattern for React
Stars: ✭ 27 (-27.03%)
Mutual labels:  async
Storage Based Queue
Javascript queue library with persistent storage based queue mechanism for the browsers environments. Specially designed for offline.
Stars: ✭ 33 (-10.81%)
Mutual labels:  async
Ktx
LibKTX: Kotlin extensions for LibGDX games and applications
Stars: ✭ 913 (+2367.57%)
Mutual labels:  async
Yii2 Queue
Yii2 Queue Extension. Supports DB, Redis, RabbitMQ, Beanstalk and Gearman
Stars: ✭ 977 (+2540.54%)
Mutual labels:  async
May
rust stackful coroutine library
Stars: ✭ 909 (+2356.76%)
Mutual labels:  async
Koahub Demo
koahub+async/await+mysql
Stars: ✭ 15 (-59.46%)
Mutual labels:  async
Garnet
Garnet — bot-friendly telethon
Stars: ✭ 36 (-2.7%)
Mutual labels:  async
Render async
render_async lets you include pages asynchronously with AJAX
Stars: ✭ 974 (+2532.43%)
Mutual labels:  async
Restless
Express.js api, type safe validations and more
Stars: ✭ 32 (-13.51%)
Mutual labels:  async

futures-batch

Build status Cargo Documentation

An adaptor that chunks up completed futures in a stream and flushes them after a timeout or when the buffer is full. It is based on the Chunks adaptor of futures-util, to which we added a timeout.

(The project was initially called tokio-batch, but was renamed as it has no dependency on Tokio anymore.)

Usage

Either as a standalone stream operator or directly as a combinator:

use std::time::Duration;
use futures::{stream, StreamExt};
use futures_batch::ChunksTimeoutStreamExt;

#[tokio::main]
async fn main() {
    let iter = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9].into_iter();
    let results = stream::iter(iter)
        .chunks_timeout(5, Duration::new(10, 0))
        .collect::<Vec<_>>();

    assert_eq!(vec![vec![0, 1, 2, 3, 4], vec![5, 6, 7, 8, 9]], results.await);
}

The above code iterates over a stream and creates chunks of size 5 with a timeout of 10 seconds.
Note: This is using the futures 0.3 crate.

Performance

futures-batch imposes very low overhead on your application. For example, it is even used to batch syscalls.
Under the hood, we are using futures-timer, which allows for a microsecond timer resolution. If you find a use-case which is not covered, don't be reluctant to open an issue.

Credits

Thanks to arielb1, alexcrichton, doyoubi, leshow, spebern, and wngr for their contributions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].