mirror of
https://github.com/trailbaseio/trailbase.git
synced 2025-12-30 06:09:48 -06:00
Hook up graft with upstream graft and conditionally register based on vfs.
This commit is contained in:
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -2312,8 +2312,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "graft-core"
|
||||
version = "0.1.5"
|
||||
source = "git+https://github.com/ignatz/graft.git?branch=api#60e4b1fe41fab237a9492d8116bc16bf5fd79c20"
|
||||
version = "0.2.0-rc.2"
|
||||
source = "git+https://github.com/ignatz/graft.git#b098619a13b08a90c2ec0fcff04ff01836cf5554"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"bilrost",
|
||||
@@ -2337,8 +2337,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "graft-kernel"
|
||||
version = "0.1.5"
|
||||
source = "git+https://github.com/ignatz/graft.git?branch=api#60e4b1fe41fab237a9492d8116bc16bf5fd79c20"
|
||||
version = "0.2.0-rc.2"
|
||||
source = "git+https://github.com/ignatz/graft.git#b098619a13b08a90c2ec0fcff04ff01836cf5554"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bilrost",
|
||||
@@ -2350,7 +2350,6 @@ dependencies = [
|
||||
"fjall",
|
||||
"futures",
|
||||
"graft-core",
|
||||
"graft-tracing",
|
||||
"itertools 0.14.0",
|
||||
"lsm-tree",
|
||||
"object_store",
|
||||
@@ -2374,8 +2373,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "graft-sqlite"
|
||||
version = "0.1.5"
|
||||
source = "git+https://github.com/ignatz/graft.git?branch=api#60e4b1fe41fab237a9492d8116bc16bf5fd79c20"
|
||||
version = "0.2.0-rc.2"
|
||||
source = "git+https://github.com/ignatz/graft.git#b098619a13b08a90c2ec0fcff04ff01836cf5554"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"bytestring",
|
||||
@@ -2396,18 +2395,6 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graft-tracing"
|
||||
version = "0.1.5"
|
||||
source = "git+https://github.com/ignatz/graft.git?branch=api#60e4b1fe41fab237a9492d8116bc16bf5fd79c20"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"parking_lot",
|
||||
"rand 0.9.2",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "group"
|
||||
version = "0.13.0"
|
||||
@@ -6234,7 +6221,6 @@ dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"regex-automata",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -6416,6 +6402,7 @@ dependencies = [
|
||||
"arc-swap",
|
||||
"argon2",
|
||||
"base64",
|
||||
"graft-kernel",
|
||||
"graft-sqlite",
|
||||
"jsonschema",
|
||||
"log",
|
||||
@@ -6430,6 +6417,7 @@ dependencies = [
|
||||
"sqlite-vec",
|
||||
"thiserror 2.0.17",
|
||||
"trailbase-sqlean",
|
||||
"url",
|
||||
"uuid",
|
||||
"validator",
|
||||
]
|
||||
|
||||
@@ -105,6 +105,7 @@ trailbase-wasm = { path = "crates/wasm-runtime-guest", version = "0.5.0" }
|
||||
trailbase-wasm-common = { path = "crates/wasm-runtime-common", version = "0.2.0" }
|
||||
trailbase-wasm-runtime-host = { path = "crates/wasm-runtime-host", version = "0.1.0" }
|
||||
ts-rs = { version = "11", features = ["uuid-impl", "serde-json-impl", "indexmap-impl"] }
|
||||
url = { version = "^2.5.7", default-features = false }
|
||||
uuid = { version = "1", default-features = false, features = ["std", "v4", "v7", "serde"] }
|
||||
wasmtime = { version = "39.0.0", features = ["winch"] }
|
||||
wasmtime-wasi = { version = "39.0.0", default-features = false, features = [] }
|
||||
|
||||
@@ -36,7 +36,7 @@ trailbase-build = { workspace = true }
|
||||
trailbase-extension = { workspace = true }
|
||||
trailbase-sqlite = { workspace = true }
|
||||
trailbase-wasm-runtime-host = { workspace = true }
|
||||
url = "2.5.4"
|
||||
url = { workspace = true }
|
||||
utoipa = { version = "5.0.0-beta.0", features = ["axum_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.0", features = ["axum"], optional = true }
|
||||
uuid = { workspace = true }
|
||||
|
||||
@@ -100,7 +100,7 @@ trailbase-sqlvalue = { workspace = true, features = ["rusqlite"] }
|
||||
trailbase-wasm-common = { workspace = true }
|
||||
trailbase-wasm-runtime-host = { workspace = true, optional = true }
|
||||
ts-rs = { workspace = true }
|
||||
url = { version = "^2.4.1", default-features = false }
|
||||
url = { workspace = true }
|
||||
utoipa = { version = "5.0.0-beta.0", features = ["axum_extras"] }
|
||||
uuid = { workspace = true }
|
||||
validator = { version = "0.20.0", default-features = false }
|
||||
|
||||
@@ -11,11 +11,16 @@ readme = "../README.md"
|
||||
[lib]
|
||||
crate-type=["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
graft = ["dep:graft-sqlite", "dep:graft-kernel"]
|
||||
|
||||
[dependencies]
|
||||
arc-swap = "1.7.1"
|
||||
argon2 = { version = "^0.5.3", default-features = false, features = ["alloc", "password-hash", "rand", "std"] }
|
||||
base64 = { version = "0.22.1", default-features = false }
|
||||
graft-sqlite = { git = "https://github.com/ignatz/graft.git", branch = "api", features = ["register-static"] }
|
||||
base64 = { workspace = true }
|
||||
graft-sqlite = { git = "https://github.com/ignatz/graft.git", features = ["register-static"], optional = true }
|
||||
graft-kernel = { git = "https://github.com/ignatz/graft.git", optional = true }
|
||||
jsonschema = { version = "0.37.1", default-features = false }
|
||||
log = "0.4.27"
|
||||
maxminddb = "0.26.0"
|
||||
@@ -29,5 +34,6 @@ sqlite-plugin = "0.4.1"
|
||||
sqlite-vec = { workspace = true }
|
||||
thiserror = "2.0.12"
|
||||
trailbase-sqlean = { workspace = true }
|
||||
url = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
validator = { version = "0.20.0", default-features = false }
|
||||
|
||||
@@ -27,11 +27,9 @@ pub(super) fn base64(context: &Context) -> Result<Value> {
|
||||
let text_str =
|
||||
std::str::from_utf8(text_bytes).map_err(|err| Error::UserFunctionError(err.into()))?;
|
||||
|
||||
Ok(Value::Blob(
|
||||
BASE64_STANDARD
|
||||
.decode(text_str)
|
||||
.map_err(|err| Error::UserFunctionError(err.into()))?,
|
||||
))
|
||||
Ok(Value::Blob(BASE64_STANDARD.decode(text_str).map_err(
|
||||
|err| Error::UserFunctionError(err.to_string().into()),
|
||||
)?))
|
||||
}
|
||||
v => Err(Error::InvalidFunctionParameterType(0, v.data_type())),
|
||||
};
|
||||
@@ -60,11 +58,9 @@ pub(super) fn base64_url_safe(context: &Context) -> Result<Value> {
|
||||
let text_str =
|
||||
std::str::from_utf8(text_bytes).map_err(|err| Error::UserFunctionError(err.into()))?;
|
||||
|
||||
Ok(Value::Blob(
|
||||
BASE64_URL_SAFE
|
||||
.decode(text_str)
|
||||
.map_err(|err| Error::UserFunctionError(err.into()))?,
|
||||
))
|
||||
Ok(Value::Blob(BASE64_URL_SAFE.decode(text_str).map_err(
|
||||
|err| Error::UserFunctionError(err.to_string().into()),
|
||||
)?))
|
||||
}
|
||||
v => Err(Error::InvalidFunctionParameterType(0, v.data_type())),
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#![forbid(clippy::unwrap_used)]
|
||||
#![allow(clippy::needless_return)]
|
||||
|
||||
// use graft_sqlite_extension::graft_static_init;
|
||||
use parking_lot::RwLock;
|
||||
use rusqlite::functions::FunctionFlags;
|
||||
use std::path::PathBuf;
|
||||
@@ -47,11 +46,9 @@ pub fn apply_default_pragmas(conn: &rusqlite::Connection) -> Result<(), rusqlite
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// FIXME: unwraps/expects.
|
||||
fn graft_config() -> graft_sqlite::GraftConfig {
|
||||
let path = std::env::current_dir().expect("FIXME").join("graft");
|
||||
|
||||
let data_dir = path.join("data");
|
||||
#[cfg(feature = "graft")]
|
||||
fn graft_config(path: std::path::PathBuf) -> graft_kernel::setup::GraftConfig {
|
||||
let data_dir = path.join("local");
|
||||
if !data_dir.exists() {
|
||||
if let Err(err) = std::fs::create_dir_all(&data_dir) {
|
||||
log::error!("Failed to create {data_dir:?}: {err}");
|
||||
@@ -66,9 +63,9 @@ fn graft_config() -> graft_sqlite::GraftConfig {
|
||||
// graft::RemoteConfig::Fs { root: remote_dir }
|
||||
// };
|
||||
|
||||
return graft_sqlite::GraftConfig {
|
||||
return graft_kernel::setup::GraftConfig {
|
||||
data_dir,
|
||||
remote: graft_sqlite::RemoteConfig::Memory,
|
||||
remote: graft_kernel::remote::RemoteConfig::Memory,
|
||||
autosync: None,
|
||||
};
|
||||
}
|
||||
@@ -85,11 +82,17 @@ pub fn connect_sqlite(
|
||||
return Err(Error::Other("Failed to load extensions".into()));
|
||||
}
|
||||
|
||||
// TODO: This should be conditionally based on url's "vfs" param.
|
||||
if path.is_some() {
|
||||
graft_sqlite::register_static(false, graft_config()).map_err(|err| {
|
||||
return Error::Other(format!("Failed to load Graft VGS: {err}").into());
|
||||
})?;
|
||||
#[cfg(feature = "graft")]
|
||||
if let Some(ref path) = path {
|
||||
if let Ok(url) = url::Url::parse(&path.to_string_lossy()) {
|
||||
if url.query_pairs().any(|(k, v)| {
|
||||
return k == "vfs" && v == "graft";
|
||||
}) {
|
||||
let config = graft_config(path.clone());
|
||||
graft_sqlite::register_static("graft", false, config)
|
||||
.map_err(|err| Error::Other(format!("Failed to load Graft VGS: {err}").into()))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Then open database and load trailbase_extensions.
|
||||
@@ -98,7 +101,8 @@ pub fn connect_sqlite(
|
||||
use rusqlite::OpenFlags;
|
||||
let flags = OpenFlags::SQLITE_OPEN_READ_WRITE
|
||||
| OpenFlags::SQLITE_OPEN_CREATE
|
||||
| OpenFlags::SQLITE_OPEN_NO_MUTEX;
|
||||
| OpenFlags::SQLITE_OPEN_NO_MUTEX
|
||||
| OpenFlags::SQLITE_OPEN_URI;
|
||||
|
||||
rusqlite::Connection::open_with_flags(p, flags)?
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,6 @@ static_assertions = "1.1.0"
|
||||
thiserror = "2.0.14"
|
||||
trailbase-sqlvalue = { workspace = true }
|
||||
trailbase-wasm-common = { workspace = true }
|
||||
url = "2.5.7"
|
||||
url = { workspace = true }
|
||||
wit-bindgen = "0.48.0"
|
||||
wstd = "=0.5.6"
|
||||
|
||||
Reference in New Issue
Block a user