8000 build: redb 4, sha2 0.11, prost 0.14, prost-reflect 0.16, protox 0.10 by arminhammer · Pull Request #41 · arminhammer/jackdaw · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ an optional part of the same engine. The CLI is now a separate crate built on th
and the HTTP listener uses axum 0.8.
- `jackdaw run` prints its result when the output is not a terminal.
- The minimum supported Rust version is 1.94.
- **Breaking:** Redb stores use redb 4, whose file format replaces the one redb 2 wrote; a Redb database from 0.1
cannot be opened.
- YAML is parsed with `serde-saphyr`, a pure-Rust parser, instead of the deprecated `serde_yaml` (and the
unmaintained `unsafe-libyaml` under it).
- The documentation uses the specification's new name, the Open Workflow Specification (formerly Serverless Workflow),
Expand Down
123 changes: 45 additions & 78 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions jackdaw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async-trait = "0.1"
uuid = { version = "1", features = ["v4", "serde"] }
base64 = "0.22"
futures = "0.3"
sha2 = "0.10.9"
sha2 = "0.11"
schemars = "1"
metrics = { version = "0.24", optional = true }

Expand All @@ -50,7 +50,7 @@ async-recursion = { version = "1.0", optional = true }
console = { version = "0.15", optional = true }

# stores
redb = { version = "2", optional = true }
redb = { version = "4", optional = true }
sqlx = { version = "0.9", default-features = false, features = ["runtime-tokio", "chrono", "json", "uuid"], optional = true }

# http-client
Expand All @@ -68,10 +68,10 @@ axum = { version = "0.8", optional = true }
# grpc-listener
tonic = { version = "0.14", optional = true }
tonic-reflection = { version = "0.14", optional = true }
prost = { version = "0.13", optional = true }
prost-reflect = { version = "0.14", features = ["serde"], optional = true }
prost-types = { version = "0.13", optional = true }
protox = { version = "0.7", optional = true }
prost = { version = "0.14", optional = true }
prost-reflect = { version = "0.16", features = ["serde"], optional = true }
prost-types = { version = "0.14", optional = true }
protox = { version = "0.10", optional = true }
tower = { version = "0.5", optional = true }
http = { version = "1", optional = true }
http-body = { version = "1", optional = true }
Expand Down
25 changes: 24 additions & 1 deletion jackdaw/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ pub fn compute_cache_key(task_name: &str, inputs: &serde_json::Value) -> String
hasher.update(format!("{task_name}:{inputs_json}"));
let result = hasher.finalize();

format!("{}:{:x}", task_name, result)
// Lowercase hex, two digits a byte (the digest no longer implements `LowerHex`); keys stay as they were.
let hex = result
.iter()
.fold(String::with_capacity(64), |mut hex, byte| {
use std::fmt::Write as _;
let _ = write!(hex, "{byte:02x}");
hex
});
format!("{task_name}:{hex}")
}

/// Normalize JSON by recursively sorting object keys for deterministic serialization
Expand All @@ -128,3 +136,18 @@ fn normalize_json(value: &serde_json::Value) -> serde_json::Value {
}

// pub const CACHE_TABLE: redb::TableDefinition<&str, &[u8]> = redb::TableDefinition::new("cache");

#[cfg(test)]
mod tests {
use super::*;

// The key is `<task>:<SHA-256 of "<task>:<input with sorted keys>">` in lowercase hex. Changing it would make
// every stored cache entry miss.
#[test]
fn cache_keys_are_stable() {
assert_eq!(
compute_cache_key("greet", &serde_json::json!({ "b": 2, "a": 1 })),
"greet:af718860577c19b49a68154a775afca783ee9c54be5ae5836a347f51c4deb336"
);
}
}
1 change: 1 addition & 0 deletions jackdaw/src/providers/cache/redb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A cache in a Redb file, usually the same file as the [`RedbPersistence`](crate::providers::persistence::RedbPersistence) store.
use crate::cache::{CacheEntry, CacheProvider, Error, Result, SerializationSnafu};
use async_trait::async_trait;
use redb::ReadableDatabase as _;
use snafu::prelude::*;
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion jackdaw/src/providers/persistence/redb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::persistence::{
Error, JournalRecord, Lease, PersistenceProvider, Result, SerializationSnafu,
};
use crate::workflow::{WorkflowCheckpoint, WorkflowEvent};
use redb::ReadableTable as _;
use redb::{ReadableDatabase as _, ReadableTable as _};
use std::sync::atomic::{AtomicU64, Ordering};

#[derive(Debug)]
Expand Down
Loading
0