-
Notifications
You must be signed in to change notification settings - Fork 1
chore: prepare taskito-core for crates.io publishing #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f775d69
chore: inherit shared crate metadata via workspace.package
pratyush618 fc72861
docs: document the taskito-core public API
pratyush618 8cb8579
ci: gate taskito-core publish readiness
pratyush618 179a649
fix(redis): return empty page for zero-limit log queries
pratyush618 dda32fd
docs(storage): align doc comments with backend behavior
pratyush618 d18992a
ci: harden publish-readiness job
pratyush618 78cd0c3
ci: fail closed on crates.io baseline probe errors
pratyush618 049eb1e
ci: send a User-Agent on the crates.io probe
pratyush618 c57dc0d
ci: probe the sparse index for the semver baseline
pratyush618 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2026 Pratyush Sharma | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # taskito-core | ||
|
|
||
| Embeddable task queue for Rust: durable jobs on SQLite (default), PostgreSQL, | ||
| or Redis, a scheduler with retries, rate limits, circuit breakers, cron | ||
| periodics, and pub/sub fan-out — and a native worker that runs your handlers. | ||
|
|
||
| This crate is the engine behind the Taskito SDKs; it works standalone in any | ||
| Rust program. | ||
|
|
||
| ## Quick start | ||
|
|
||
| ```rust,no_run | ||
| use taskito_core::{ | ||
| now_millis, Job, NewJob, SqliteStorage, Storage, StorageBackend, Worker, | ||
| }; | ||
|
|
||
| fn main() -> taskito_core::Result<()> { | ||
| let storage = StorageBackend::Sqlite(SqliteStorage::new("taskito.db")?); | ||
|
|
||
| // A worker executes registered handlers for dequeued jobs. | ||
| let handle = Worker::new(storage.clone()) | ||
| .num_workers(4) | ||
| .register("greet", |job: &Job| { | ||
| println!("hello, {}!", String::from_utf8_lossy(&job.payload)); | ||
| Ok(None) | ||
| }) | ||
| .spawn()?; | ||
|
|
||
| // Producers enqueue jobs — from this process or any other. | ||
| storage.enqueue(NewJob { | ||
| queue: "default".to_string(), | ||
| task_name: "greet".to_string(), | ||
| payload: b"world".to_vec(), | ||
| priority: 0, | ||
| scheduled_at: now_millis(), | ||
| max_retries: 3, | ||
| timeout_ms: 30_000, | ||
| unique_key: None, | ||
| metadata: None, | ||
| notes: None, | ||
| depends_on: vec![], | ||
| expires_at: None, | ||
| result_ttl_ms: None, | ||
| namespace: None, | ||
| })?; | ||
|
|
||
| std::thread::sleep(std::time::Duration::from_millis(500)); | ||
| handle.shutdown() | ||
| } | ||
| ``` | ||
|
|
||
| Async handlers work too — `register_async` spawns the future on the worker's | ||
| runtime. See `examples/hello.rs` for a runnable version. | ||
|
|
||
| ## Storage backends | ||
|
|
||
| | Backend | Feature | Notes | | ||
| |---|---|---| | ||
| | SQLite | (default) | Zero-config, single file, bundled `libsqlite3` | | ||
| | PostgreSQL | `postgres` | `SKIP LOCKED` dequeue, `LISTEN/NOTIFY` push dispatch | | ||
| | Redis | `redis` | JSON blobs + sorted-set indexes, Lua-atomic claims | | ||
|
|
||
| All three pass one shared contract test suite; behavior is identical up to | ||
| backend-documented differences. | ||
|
|
||
| ## What's in the box | ||
|
|
||
| - **Jobs**: priorities, delays, per-job timeouts, uniqueness/idempotency keys, | ||
| dependencies, expiry, result TTLs, namespaces. | ||
| - **Scheduler**: adaptive polling (or event-driven wakeups via the | ||
| `push-dispatch` feature), batch claiming, bounded in-flight dispatch, | ||
| stale-job reaping, retention with per-table windows. | ||
| - **Resilience**: exponential-backoff retries, per-task rate limits and retry | ||
| budgets, circuit breakers, a dead-letter queue with replay. | ||
| - **Workers**: `Worker` builder + `TaskRegistry` for sync and async Rust | ||
| handlers, heartbeat/registry with elected cluster reaps. | ||
| - **Pub/sub**: topics with durable/ephemeral subscriptions and fan-out on | ||
| publish. | ||
| - **Periodic tasks**: cron expressions with optional time zones. | ||
|
|
||
| ## License | ||
|
|
||
| MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,69 @@ | ||
| use thiserror::Error; | ||
|
|
||
| /// Every error the queue can produce. | ||
| #[derive(Error, Debug)] | ||
| pub enum QueueError { | ||
| /// A Diesel query or transaction failed. | ||
| #[error("storage error: {0}")] | ||
| Storage(#[from] diesel::result::Error), | ||
|
|
||
| /// The r2d2 connection pool could not hand out a connection. | ||
| #[error("connection pool error: {0}")] | ||
| Pool(#[from] diesel::r2d2::PoolError), | ||
|
|
||
| /// A Redis command or connection failed. | ||
| #[cfg(feature = "redis")] | ||
| #[error("redis error: {0}")] | ||
| Redis(#[from] redis::RedisError), | ||
|
|
||
| /// JSON encoding or decoding failed. | ||
| #[error("json error: {0}")] | ||
| Json(#[from] serde_json::Error), | ||
|
|
||
| /// No job exists with the given id. | ||
| #[error("job not found: {0}")] | ||
| JobNotFound(String), | ||
|
|
||
| /// A job referenced a task name with no registered handler. | ||
| #[error("task not registered: {0}")] | ||
| TaskNotRegistered(String), | ||
|
|
||
| /// A payload or result could not be serialized/deserialized. | ||
| #[error("serialization error: {0}")] | ||
| Serialization(String), | ||
|
|
||
| /// A worker-side failure (spawn, dispatch, or pool error). | ||
| #[error("worker error: {0}")] | ||
| Worker(String), | ||
|
|
||
| /// A scheduler-side failure (dispatch, maintenance, or config). | ||
| #[error("scheduler error: {0}")] | ||
| Scheduler(String), | ||
|
|
||
| /// A queue/task rate limit rejected the operation. | ||
| #[error("rate limit exceeded for: {0}")] | ||
| RateLimitExceeded(String), | ||
|
|
||
| /// A job exceeded its execution timeout. | ||
| #[error("job timed out: {0}")] | ||
| Timeout(String), | ||
|
|
||
| /// Invalid or inconsistent configuration. | ||
| #[error("config error: {0}")] | ||
| Config(String), | ||
|
|
||
| /// A job dependency id does not exist. | ||
| #[error("dependency not found: {0}")] | ||
| DependencyNotFound(String), | ||
|
|
||
| /// A distributed lock was already held by another owner. | ||
| #[error("lock not acquired: {0}")] | ||
| LockNotAcquired(String), | ||
|
|
||
| /// Any other failure that fits no specific variant. | ||
| #[error("{0}")] | ||
| Other(String), | ||
| } | ||
|
|
||
| /// Crate-wide result alias over [`QueueError`]. | ||
| pub type Result<T> = std::result::Result<T, QueueError>; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.