mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-29 19:41:39 +03:00
parent
110b9d19b8
commit
13a7be6b6d
97
modules/sqlite/sqlite/Cargo.lock
generated
97
modules/sqlite/sqlite/Cargo.lock
generated
@ -35,6 +35,12 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@ -47,6 +53,21 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.10"
|
||||
@ -73,12 +94,33 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
|
||||
dependencies = [
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.0"
|
||||
@ -129,6 +171,12 @@ version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
@ -308,12 +356,42 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.10.1"
|
||||
@ -328,16 +406,31 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
|
||||
[[package]]
|
||||
name = "uqbar_process_lib"
|
||||
version = "0.2.0"
|
||||
source = "git+ssh://git@github.com/uqbar-dao/process_lib.git?rev=e53c124#e53c124ec95ef99c06d201d4d08dada8ec691d29"
|
||||
version = "0.3.0"
|
||||
source = "git+ssh://git@github.com/uqbar-dao/process_lib.git?rev=7e4065c#7e4065cfa8c918ad8c41ebd2039509f29f828ec5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"http",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"url",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
|
@ -17,7 +17,7 @@ rmp-serde = "1.1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e53c124" }
|
||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "7e4065c" }
|
||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "5390bab780733f1660d14c254ec985df2816bf1d" }
|
||||
|
||||
[lib]
|
||||
|
@ -50,10 +50,10 @@ fn forward_if_have_cap(
|
||||
.target(wit::Address {
|
||||
node: our.node.clone(),
|
||||
process: process_id.clone(),
|
||||
})?
|
||||
})
|
||||
// .target(Address::new(our.node.clone(), process_id.clone()))?
|
||||
.inherit(true)
|
||||
.ipc_bytes(ipc)
|
||||
.ipc(ipc)
|
||||
.send()?;
|
||||
return Ok(());
|
||||
} else {
|
||||
@ -83,9 +83,8 @@ fn handle_message (
|
||||
sq::SqliteMessage::New { ref db } => {
|
||||
// TODO: make atomic
|
||||
// (1): create vfs drive
|
||||
// (2): spin up worker, granting vfs caps
|
||||
// (2): spin up worker, granting vfs caps & msg_cap
|
||||
// (3): issue new caps
|
||||
// (4): persist
|
||||
|
||||
if db_to_process.contains_key(db) {
|
||||
return Err(sq::SqliteError::DbAlreadyExists.into());
|
||||
@ -94,12 +93,13 @@ fn handle_message (
|
||||
// (1)
|
||||
let vfs_address = Address {
|
||||
node: our.node.clone(),
|
||||
process: ProcessId::new("vfs", "sys", "uqbar"),
|
||||
process: ProcessId::new(Some("vfs"), "sys", "uqbar"),
|
||||
};
|
||||
|
||||
let vfs_drive = format!("{}{}", PREFIX, db);
|
||||
let _ = Request::new()
|
||||
.target(vfs_address.clone())?
|
||||
.ipc_bytes(serde_json::to_vec(&kt::VfsRequest {
|
||||
.target(vfs_address.clone())
|
||||
.ipc(serde_json::to_vec(&kt::VfsRequest {
|
||||
drive: vfs_drive.clone(),
|
||||
action: kt::VfsAction::New,
|
||||
})?)
|
||||
@ -110,15 +110,22 @@ fn handle_message (
|
||||
&vfs_address,
|
||||
&make_vfs_cap("read", &vfs_drive),
|
||||
).ok_or(anyhow::anyhow!("New failed: no vfs 'read' capability found"))?;
|
||||
|
||||
let vfs_write = wit::get_capability(
|
||||
&vfs_address,
|
||||
&make_vfs_cap("write", &vfs_drive),
|
||||
).ok_or(anyhow::anyhow!("New failed: no vfs 'write' capability found"))?;
|
||||
|
||||
let msg_cap = wit::get_capability(
|
||||
&source,
|
||||
&"\"messaging\"".into(),
|
||||
).ok_or(anyhow::anyhow!("New failed: no msg capability passed"))?;
|
||||
|
||||
let spawned_process_id = match wit::spawn(
|
||||
None,
|
||||
"/sqlite_worker.wasm",
|
||||
&wit::OnPanic::None, // TODO: notify us
|
||||
&wit::Capabilities::Some(vec![vfs_read, vfs_write]),
|
||||
&wit::OnPanic::None,
|
||||
&wit::Capabilities::Some(vec![vfs_read, vfs_write, msg_cap]),
|
||||
false, // not public
|
||||
) {
|
||||
Ok(spawned_process_id) => spawned_process_id,
|
||||
@ -135,16 +142,14 @@ fn handle_message (
|
||||
.target(wit::Address {
|
||||
node: our.node.clone(),
|
||||
process: spawned_process_id.clone(),
|
||||
})?
|
||||
.ipc_bytes(ipc.clone())
|
||||
})
|
||||
.ipc(ipc.clone())
|
||||
.send()?;
|
||||
|
||||
// (4)
|
||||
db_to_process.insert(db.into(), spawned_process_id);
|
||||
// TODO: persistence?
|
||||
|
||||
Response::new()
|
||||
.ipc_bytes(ipc)
|
||||
.ipc(ipc)
|
||||
.send()?;
|
||||
},
|
||||
sq::SqliteMessage::Write { ref db, ref statement, ref tx_id } => {
|
||||
@ -185,7 +190,9 @@ impl Guest for Component {
|
||||
wit::print_to_terminal(0, "sqlite: begin");
|
||||
|
||||
let our = Address::from_str(&our).unwrap();
|
||||
|
||||
let mut db_to_process: DbToProcess = HashMap::new();
|
||||
|
||||
let read_keywords: HashSet<String> = [
|
||||
"ANALYZE",
|
||||
"ATTACH",
|
||||
@ -232,7 +239,7 @@ impl Guest for Component {
|
||||
).as_str());
|
||||
if let Some(e) = e.downcast_ref::<sq::SqliteError>() {
|
||||
Response::new()
|
||||
.ipc_bytes(serde_json::to_vec(&e).unwrap())
|
||||
.ipc(serde_json::to_vec(&e).unwrap())
|
||||
.send()
|
||||
.unwrap();
|
||||
}
|
||||
|
97
modules/sqlite/sqlite_worker/Cargo.lock
generated
97
modules/sqlite/sqlite_worker/Cargo.lock
generated
@ -58,6 +58,12 @@ version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
@ -91,6 +97,21 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.10"
|
||||
@ -130,12 +151,33 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
|
||||
dependencies = [
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.0.0"
|
||||
@ -202,6 +244,12 @@ version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.27"
|
||||
@ -402,12 +450,42 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.10.1"
|
||||
@ -422,16 +500,31 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
|
||||
[[package]]
|
||||
name = "uqbar_process_lib"
|
||||
version = "0.2.0"
|
||||
source = "git+ssh://git@github.com/uqbar-dao/process_lib.git?rev=e53c124#e53c124ec95ef99c06d201d4d08dada8ec691d29"
|
||||
version = "0.3.0"
|
||||
source = "git+ssh://git@github.com/uqbar-dao/process_lib.git?rev=7e4065c#7e4065cfa8c918ad8c41ebd2039509f29f828ec5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
"http",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"url",
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
@ -19,7 +19,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
base64 = "0.13"
|
||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "e53c124" }
|
||||
uqbar_process_lib = { git = "ssh://git@github.com/uqbar-dao/process_lib.git", rev = "7e4065c" }
|
||||
wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "5390bab780733f1660d14c254ec985df2816bf1d" }
|
||||
|
||||
[lib]
|
||||
|
@ -4,10 +4,9 @@ use std::ffi::CString;
|
||||
use rusqlite::{types::FromSql, types::FromSqlError, types::ToSql, types::ValueRef};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use uqbar_process_lib::{Address, ProcessId, Response, grant_messaging};
|
||||
use uqbar_process_lib::{Address, ProcessId, Response, create_capability};
|
||||
use uqbar_process_lib::uqbar::process::standard as wit;
|
||||
|
||||
use crate::sqlite_types::Deserializable;
|
||||
|
||||
wit_bindgen::generate!({
|
||||
path: "../../../wit",
|
||||
@ -453,7 +452,7 @@ fn handle_message(
|
||||
};
|
||||
|
||||
Response::new()
|
||||
.ipc_bytes(ipc)
|
||||
.ipc(ipc)
|
||||
.send()?;
|
||||
},
|
||||
sq::SqliteMessage::Commit { ref tx_id, .. } => {
|
||||
@ -473,7 +472,7 @@ fn handle_message(
|
||||
tx.commit()?;
|
||||
|
||||
Response::new()
|
||||
.ipc_bytes(ipc)
|
||||
.ipc(ipc)
|
||||
.send()?;
|
||||
},
|
||||
sq::SqliteMessage::Read { ref query, .. } => {
|
||||
@ -525,7 +524,7 @@ fn handle_message(
|
||||
let results_bytes = results.as_bytes().to_vec();
|
||||
|
||||
Response::new()
|
||||
.ipc_bytes(ipc)
|
||||
.ipc(ipc)
|
||||
.payload(wit::Payload {
|
||||
mime: None,
|
||||
bytes: results_bytes,
|
||||
@ -548,9 +547,11 @@ impl Guest for Component {
|
||||
let mut conn: Option<rusqlite::Connection> = None;
|
||||
let mut txs: HashMap<u64, Vec<(String, Vec<sq::SqlValue>)>> = HashMap::new();
|
||||
|
||||
grant_messaging(
|
||||
&our,
|
||||
&Vec::from([ProcessId::from_str("vfs:sys:uqbar").unwrap()])
|
||||
let vfs_address = ProcessId::from_str("vfs:sys:uqbar").unwrap();
|
||||
|
||||
create_capability(
|
||||
&vfs_address,
|
||||
&"\"messaging\"".into(),
|
||||
);
|
||||
|
||||
loop {
|
||||
@ -564,7 +565,7 @@ impl Guest for Component {
|
||||
).as_str());
|
||||
if let Some(e) = e.downcast_ref::<sq::SqliteError>() {
|
||||
Response::new()
|
||||
.ipc_bytes(serde_json::to_vec(&e).unwrap())
|
||||
.ipc(serde_json::to_vec(&e).unwrap())
|
||||
.send()
|
||||
.unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user