Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Feb 21, 2022
1 parent 543777e commit 0507f9a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"crates/bonsaidb-server",
"crates/bonsaidb-keystorage-s3",
"crates/bonsaidb-utils",
"crates/bonsaidb-jobs",
"examples/*",
"book/book-examples",
"xtask",
Expand Down
23 changes: 23 additions & 0 deletions crates/bonsaidb-jobs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "bonsaidb-jobs"
version = "0.2.0"
authors = ["Jonathan Johnson <[email protected]>"]
edition = "2021"
description = "Persistent job queueing and scheduling for BonsaiDb."
repository = "https://github.com/khonsulabs/bonsaidb"
license = "MIT OR Apache-2.0"
keywords = ["bonsaidb", "job", "queue"]
categories = ["config"]
readme = "./README.md"
homepage = "https://bonsaidb.io/"
rust-version = "1.58"

[dependencies]
bonsaidb-core = { version = "0.2.0", path = "../bonsaidb-core" }
serde = { version = "1", features = ["derive"] }

[dev-dependencies]
tokio = { version = "=1.16.1", features = ["full"] }
bonsaidb-core = { version = "0.2.0", path = "../bonsaidb-core", features = [
"test-util",
] }
36 changes: 36 additions & 0 deletions crates/bonsaidb-jobs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use bonsaidb_core::{
arc_bytes::serde::Bytes,
keyvalue::Timestamp,
schema::{Authority, Collection, CollectionName, SchemaName, Schematic},
};
use serde::{Deserialize, Serialize};

pub fn define_collections(schematic: &mut Schematic) -> Result<(), bonsaidb_core::Error> {
schematic.define_collection::<Queue>()?;
schematic.define_collection::<Job>()?;

Ok(())
}

#[derive(Collection, Debug, Serialize, Deserialize)]
#[collection(name = "queues", authority = "bonsaidb", core = bonsaidb_core)]
pub struct Queue {
pub owner: QueueOwner,
pub name: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum QueueOwner {
Collection(CollectionName),
Authority(Authority),
Schema(SchemaName),
Backend,
}

#[derive(Collection, Debug, Serialize, Deserialize)]
#[collection(name = "jobs", authority = "bonsaidb", core = bonsaidb_core)]
pub struct Job {
pub queue_id: u64,
pub payload: Bytes,
pub enqueued_at: Timestamp,
}

0 comments on commit 0507f9a

Please sign in to comment.