{"id":13822542,"url":"https://github.com/insipx/coil","last_synced_at":"2025-04-09T15:32:55.567Z","repository":{"id":37071427,"uuid":"284506401","full_name":"insipx/coil","owner":"insipx","description":"Futures-based background work queue built with SQLx and Postgres","archived":false,"fork":false,"pushed_at":"2023-03-06T22:04:47.000Z","size":295,"stargazers_count":12,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T01:16:01.068Z","etag":null,"topics":["async-await","async-std","asyncronous-jobs","job-queue","postgres","rust","smol","sqlx","task-queue","tokio"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/insipx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-08-02T17:11:56.000Z","updated_at":"2023-01-21T18:11:22.000Z","dependencies_parsed_at":"2024-01-18T04:14:37.135Z","dependency_job_id":null,"html_url":"https://github.com/insipx/coil","commit_stats":{"total_commits":142,"total_committers":3,"mean_commits":"47.333333333333336","dds":0.2676056338028169,"last_synced_commit":"9e49be7b9d84713804c4ac0aa9a572f18e7af31c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insipx%2Fcoil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insipx%2Fcoil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insipx%2Fcoil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insipx%2Fcoil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insipx","download_url":"https://codeload.github.com/insipx/coil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223402393,"owners_count":17139729,"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":["async-await","async-std","asyncronous-jobs","job-queue","postgres","rust","smol","sqlx","task-queue","tokio"],"created_at":"2024-08-04T08:02:05.297Z","updated_at":"2024-11-06T19:28:23.506Z","avatar_url":"https://github.com/insipx.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Coil\nAn async task queue built with SQLx, Postgres, and Rayon\n\n![](https://github.com/insipx/coil/workflows/Unit%20and%20Integration%20Tests/badge.svg)\n[![Coverage](https://coveralls.io/repos/github/insipx/coil/badge.svg?branch=master)](https://coveralls.io/github/insipx/coil?branch=master)\n\u003ca href=\"https://crates.io/crates/coil\"\u003e\n\t![Crates.io](https://img.shields.io/crates/d/coil)\n\u003c/a\u003e\n\u003ca href=\"https://crates.io/crates/coil\"\u003e\n\t![Crates.io](https://img.shields.io/crates/v/coil)\n\u003c/a\u003e\n\u003c/div\u003e\n\nCoil is heavily inspired by and takes heavily from [swirl](https://github.com/sgrif/swirl). In many places of the codebase, code is very similiar.\n\nSupports synchronous and asynchronous jobs. Synchronous jobs will be spawned into a threadpool managed by [`rayon`](https://github.com/rayon-rs/rayon). Async jobs will be spawned onto an executor. The only requirement is that the executor implements the futures `Spawn` trait. This way, `coil` supports `Tokio`, `smol`, and `async-std`.\n\n\u003csub\u003e\u003csup\u003e† This software is alpha, and not intended for production use yet. Use at your own risk.\n\n\u003csub\u003e\u003csup\u003e†† This software is sublicensed as GPLv3. Portions from `swirl` are licensed under MIT. See the [License](#license) section\n\n---\n\n### Examples\n\n```rust\nstruct Size {\n\twidth: u32,\n\theight: u32\n}\n\n#[coil::background_task]\nasync fn resize_image(id: u32, size: Size) -\u003e Result\u003c(), Error\u003e {\n\t// some work\n}\n```\n\nWith an environment\n```rust\nstruct Size {\n\twidth: u32,\n\theight: u32\n}\n\nstruct Environment {\n    file_server_private_key: String,\n    http_client: http_lib::Client,\n    conn: sqlx::PgPool\n}\n\n#[coil::background_task]\nasync fn resize_image(env: \u0026Environment, id: u32, size: Size) -\u003e Result\u003c(), Error\u003e {\n\t// some work\n}\n```\n\n```rust\nresize_image_with_env(\"tohru\".to_string(), Size { height: 32, width: 32 }).enqueue(\u0026pool).await;\nlet runner = coil::RunnerBuilder::new(env, Executor, pool)\n    .num_threads(8)\n    .build()\n    .unwrap();\nrunner.run_all_pending_tasks().await.unwrap()\n```\n\n### Differences from [`swirl`](https://github.com/sgrif/swirl)\n- Supports asynchronous jobs/executors\n- Supports jobs with generic arguments\n- Serializes data into Postgres with Messagepack instead of JSON\n- In asynchronous jobs, database queries will be run asynchronously with SQLx\n- Migrations are included in the binary and exposed via a `migrate` fn. \n- Enqueue is an `async fn`\n\n## License\nThis program includes code from the `Swirl` library, used under the [MIT License](https://github.com/sgrif/swirl/blob/master/LICENSE-MIT) or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)\n\nThis program is sublicensed under [GPLv3](https://github.com/insipx/coil/blob/master/LICENSE). An original MIT license copy for `Swirl` is provided in the source.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsipx%2Fcoil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsipx%2Fcoil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsipx%2Fcoil/lists"}