{"id":15640479,"url":"https://github.com/mre/futures-batch","last_synced_at":"2025-04-06T00:09:08.103Z","repository":{"id":52376848,"uuid":"108196293","full_name":"mre/futures-batch","owner":"mre","description":"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.)","archived":false,"fork":false,"pushed_at":"2024-05-13T15:54:33.000Z","size":56,"stargazers_count":76,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T23:08:08.271Z","etag":null,"topics":["adaptor","async","async-std","buffer","chunk","flush","futures","timeout","tokio-rs"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mre"}},"created_at":"2017-10-24T23:48:06.000Z","updated_at":"2025-03-05T13:45:50.000Z","dependencies_parsed_at":"2024-05-13T17:29:14.397Z","dependency_job_id":null,"html_url":"https://github.com/mre/futures-batch","commit_stats":{"total_commits":52,"total_committers":10,"mean_commits":5.2,"dds":0.3653846153846154,"last_synced_commit":"dac445cbd4e93ac053a3629a7033d7ac2bd330fe"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Ffutures-batch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Ffutures-batch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Ffutures-batch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mre%2Ffutures-batch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mre","download_url":"https://codeload.github.com/mre/futures-batch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415967,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adaptor","async","async-std","buffer","chunk","flush","futures","timeout","tokio-rs"],"created_at":"2024-10-03T11:35:40.827Z","updated_at":"2025-04-06T00:09:08.079Z","avatar_url":"https://github.com/mre.png","language":"Rust","readme":"# futures-batch\n\n![Build status](https://github.com/mre/futures-batch/workflows/Rust/badge.svg)\n[![Cargo](https://img.shields.io/crates/v/futures-batch.svg)](https://crates.io/crates/futures-batch)\n[![Documentation](https://docs.rs/futures-batch/badge.svg)](https://docs.rs/futures-batch)\n\nAn adaptor that chunks up completed futures in a stream and flushes them after a timeout or when the buffer is full.\nIt is based on the `Chunks` adaptor of [futures-util](https://github.com/rust-lang-nursery/futures-rs/blob/4613193023dd4071bbd32b666e3b85efede3a725/futures-util/src/stream/chunks.rs), to which we added a timeout.\n\n(The project was initially called `tokio-batch`, but was renamed as it has no dependency on Tokio anymore.)\n\n## Usage\n\nEither as a standalone stream operator or directly as a combinator:\n\n```rust\nuse std::time::Duration;\nuse futures::{stream, StreamExt};\nuse futures_batch::ChunksTimeoutStreamExt;\n\n#[tokio::main]\nasync fn main() {\n    let results = stream::iter(0..10)\n        .chunks_timeout(5, Duration::new(10, 0))\n        .collect::\u003cVec\u003c_\u003e\u003e();\n\n    assert_eq!(vec![vec![0, 1, 2, 3, 4], vec![5, 6, 7, 8, 9]], results.await);\n}\n```\n\nThe above code iterates over a stream and creates chunks of size 5 with a timeout of 10 seconds.  \n_Note:_ This is using the [`futures 0.3`](https://crates.io/crates/futures) crate.\n\n## Performance\n\n`futures-batch` imposes very low overhead on your application. For example, it [is even used to batch syscalls](https://github.com/mre/futures-batch/issues/4).  \nUnder the hood, we are using [`futures-timer`](https://github.com/async-rs/futures-timer), which allows for a microsecond timer resolution.\nIf you find a use-case which is not covered, don't be reluctant to open an issue.\n\n## Credits\n\nThanks to [arielb1](https://github.com/arielb1), [alexcrichton](https://github.com/alexcrichton/), [doyoubi](https://github.com/doyoubi), [leshow](https://github.com/leshow), [spebern](https://github.com/spebern), and [wngr](https://github.com/wngr) for their contributions!\n","funding_links":["https://github.com/sponsors/mre"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmre%2Ffutures-batch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmre%2Ffutures-batch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmre%2Ffutures-batch/lists"}