From 7043b6a5c50765a60ce5163dde2b880ecae12353 Mon Sep 17 00:00:00 2001 From: G-XD Date: Sat, 7 Oct 2023 15:19:53 +0800 Subject: [PATCH 1/5] feat(service/libsql): support libsql --- .env.example | 8 + Cargo.lock | 849 +++++++++++++++++++++------- core/Cargo.toml | 2 + core/src/services/libsql/backend.rs | 345 +++++++++++ core/src/services/libsql/docs.md | 50 ++ core/src/services/libsql/mod.rs | 19 + core/src/services/mod.rs | 5 + core/src/types/scheme.rs | 4 + core/tests/behavior/main.rs | 2 + 9 files changed, 1093 insertions(+), 191 deletions(-) create mode 100644 core/src/services/libsql/backend.rs create mode 100644 core/src/services/libsql/docs.md create mode 100644 core/src/services/libsql/mod.rs diff --git a/.env.example b/.env.example index 2a5b0344876b..5a382ec2bac7 100644 --- a/.env.example +++ b/.env.example @@ -164,3 +164,11 @@ OPENDAL_GDRIVE_ACCESS_TOKEN= OPENDAL_GDRIVE_REFRESH_TOKEN= OPENDAL_GDRIVE_CLIENT_ID= OPENDAL_GDRIVE_CLIENT_SECRET= +# libsql +OPENDAL_LIBSQL_TEST=false +OPENDAL_LIBSQL_ROOT=/tmp/opendal/ +OPENDAL_LIBSQL_CONNECTION_STRING=file://tmp/example.db +OPENDAL_LIBSQL_AUTH_TOKEN= +OPENDAL_LIBSQL_TABLE=t_opendal +OPENDAL_LIBSQL_KEY_FIELD=key +OPENDAL_LIBSQL_VALUE_FIELD=val diff --git a/Cargo.lock b/Cargo.lock index 5cc7e68be272..f39ef36fd527 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,9 +210,9 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "840d2e9edec91ac974365978efc6f00781ff497e706a12306fff29ae92f8ad46" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -303,8 +303,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -314,9 +314,9 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -362,9 +362,9 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -382,7 +382,7 @@ dependencies = [ "futures-core", "futures-io", "rustls 0.19.1", - "webpki", + "webpki 0.21.4", "webpki-roots 0.21.1", ] @@ -392,9 +392,9 @@ version = "0.1.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -622,8 +622,8 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", "rustc-hash", "shlex", @@ -644,12 +644,35 @@ dependencies = [ "log", "peeking_take_while", "prettyplease 0.2.9", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", "rustc-hash", "shlex", - "syn 2.0.23", + "syn 2.0.32", + "which", +] + +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.3.3", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease 0.2.9", + "proc-macro2 1.0.63", + "quote 1.0.29", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.32", "which", ] @@ -720,7 +743,7 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", - "proc-macro2", + "proc-macro2 1.0.63", "syn 1.0.109", ] @@ -730,8 +753,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -741,8 +764,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -790,8 +813,8 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -801,6 +824,26 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +dependencies = [ + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", +] + [[package]] name = "byteorder" version = "1.4.3" @@ -812,6 +855,9 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] [[package]] name = "bzip2" @@ -908,8 +954,8 @@ dependencies = [ "heck", "indexmap 1.9.3", "log", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "serde", "serde_json", "syn 1.0.109", @@ -1056,9 +1102,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -1327,7 +1373,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.9.0", "scopeguard", ] @@ -1372,7 +1418,7 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ - "quote", + "quote 1.0.29", "syn 1.0.109", ] @@ -1382,8 +1428,8 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eed5fff0d93c7559121e9c72bf9c242295869396255071ff2cb1617147b608c5" dependencies = [ - "quote", - "syn 2.0.23", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -1413,10 +1459,10 @@ dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "scratch", - "syn 2.0.23", + "syn 2.0.32", ] [[package]] @@ -1431,9 +1477,9 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -1464,8 +1510,8 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "strsim", "syn 1.0.109", ] @@ -1478,10 +1524,10 @@ checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "strsim", - "syn 2.0.23", + "syn 2.0.32", ] [[package]] @@ -1491,7 +1537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core 0.14.4", - "quote", + "quote 1.0.29", "syn 1.0.109", ] @@ -1502,8 +1548,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", - "quote", - "syn 2.0.23", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -1575,6 +1621,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1" +[[package]] +name = "default-env" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f753eb82d29277e79efc625e84aecacfd4851ee50e05a8573a4740239a77bfd3" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + [[package]] name = "defer" version = "0.1.0" @@ -1598,8 +1655,8 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -1609,9 +1666,9 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -1630,8 +1687,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" dependencies = [ "darling 0.14.4", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -1651,8 +1708,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35cb7e5875e1028a73e551747d6d0118f25c3d6dbba2dadf97cc0f4d0c53f2f5" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -1776,8 +1833,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ "heck", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -1837,10 +1894,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4b0ea5ef6dc2388a4b1669fa32097249bc03a15417b97cb75e38afb309e4a89" dependencies = [ "http", - "prost", + "prost 0.11.9", "tokio", "tokio-stream", - "tonic", + "tonic 0.9.2", "tonic-build", "tower", "tower-service", @@ -1882,8 +1939,8 @@ dependencies = [ "darling 0.14.4", "ident_case", "lazy_static", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -2032,9 +2089,9 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83c8d52fe8b46ab822b4decdcc0d6d85aeedfc98f0d52ba2bd4aec4a97807516" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", "try_map", ] @@ -2071,8 +2128,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", - "quote", - "syn 2.0.23", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -2082,9 +2139,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35b54add839292b743aeda6ebedbd8b11e93404f902c56223e51b9ec18a13d2c" dependencies = [ "frunk_core", - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -2095,8 +2152,8 @@ checksum = "71b85a1d4a9a6b300b41c05e8e13ef2feca03e0334127f29eca9506a7fe13a93" dependencies = [ "frunk_core", "frunk_proc_macro_helpers", - "quote", - "syn 2.0.23", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -2184,9 +2241,9 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -2487,6 +2544,35 @@ dependencies = [ "winapi", ] +[[package]] +name = "hrana-client" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80430f3ff61d4ec7388b11feb2e5df4b2fe8b61f1f7956673307fc3ae4f82798" +dependencies = [ + "anyhow", + "base64 0.21.2", + "futures", + "hrana-client-proto", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", +] + +[[package]] +name = "hrana-client-proto" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16b4e41e289da3fd60e64f245246a97e78fab7b3788c6d8147b3ae7d9f5e533" +dependencies = [ + "anyhow", + "base64 0.21.2", + "serde", + "serde_json", +] + [[package]] name = "htmlescape" version = "0.3.1" @@ -2592,9 +2678,12 @@ checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", + "log", "rustls 0.21.6", + "rustls-native-certs", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", + "webpki-roots 0.23.1", ] [[package]] @@ -2880,8 +2969,8 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8edfc11b8f56ce85e207e62ea21557cfa09bb24a8f6b04ae181b086ff8611c22" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", "syn 1.0.109", ] @@ -2892,10 +2981,10 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0a1d9139f0ee2e862e08a9c5d0ba0470f2aa21cd1e1aa1b1562f83116c725f" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", - "syn 2.0.23", + "syn 2.0.32", ] [[package]] @@ -3033,6 +3122,100 @@ dependencies = [ "libz-sys", ] +[[package]] +name = "libsql" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b338b21c151cd923d619146adc7e5364197794381cebb3270c31338da6736e" +dependencies = [ + "async-trait", + "base64 0.21.2", + "crossbeam-channel", + "futures", + "hrana-client-proto", + "hyper", + "hyper-rustls", + "libsql-sys", + "libsql_replication", + "parking_lot 0.12.1", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "libsql-client" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5422994ae3142c5302ce94626f5e7a783b68839c64db35a93002cb029628afd5" +dependencies = [ + "anyhow", + "base64 0.21.2", + "fallible-iterator", + "futures", + "hrana-client", + "hrana-client-proto", + "libsql", + "num-traits", + "reqwest", + "serde", + "serde_json", + "sqlite3-parser", + "tracing", + "url", +] + +[[package]] +name = "libsql-sys" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beff96c554acb45beb77380110d724767837952985aecb78d545bbba90b0c80c" +dependencies = [ + "bindgen 0.66.1", + "cc", + "default-env", + "once_cell", + "tracing", +] + +[[package]] +name = "libsql_replication" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd143d93ffc33a234b1386bdcaaa7bc8478c2105a0e588b3983cc5ec322e20a" +dependencies = [ + "anyhow", + "bytemuck", + "bytes", + "crossbeam", + "futures", + "http", + "hyper", + "hyper-rustls", + "libsql-sys", + "memmap", + "nix", + "once_cell", + "parking_lot 0.12.1", + "prost 0.12.1", + "regex", + "serde", + "serde_json", + "tempfile", + "thiserror", + "tokio", + "tokio-stream", + "tonic 0.10.0", + "tonic-web", + "tower", + "tower-http", + "tracing", + "uuid", +] + [[package]] name = "libsqlite3-sys" version = "0.26.0" @@ -3214,8 +3397,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d248e97b1a48826a12c3828d921e8548e714394bf17274dd0a93910dc946e1" dependencies = [ "darling 0.14.4", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3237,8 +3420,8 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3284,6 +3467,16 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "memmap2" version = "0.5.10" @@ -3293,6 +3486,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -3319,8 +3521,8 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3342,9 +3544,9 @@ version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4901771e1d44ddb37964565c654a3223ba41a594d02b8da471cc4464912b5cfa" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -3418,8 +3620,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2277f13e7d585f02062590b3496cc0ca862aefadd24888efa01d50843605b79" dependencies = [ "proc-macro-error", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3476,8 +3678,8 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9214e60d3cf1643013b107330fcd374ccec1e4ba1eef76e7e5da5e8202e71c0" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3524,9 +3726,9 @@ dependencies = [ "num-bigint", "proc-macro-crate 1.3.1", "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", "termcolor", "thiserror", ] @@ -3637,8 +3839,8 @@ dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3650,8 +3852,8 @@ checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17" dependencies = [ "convert_case", "once_cell", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", "semver", "syn 1.0.109", @@ -3684,6 +3886,19 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", +] + [[package]] name = "no-std-compat" version = "0.4.1" @@ -3756,8 +3971,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -3897,7 +4112,7 @@ version = "1.0.0-beta.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae2b0b155a81c2f3f9e71cb1f47e84d705d852e9ea7c10955d8bce1fa2d26aa0" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.63", "syn 1.0.109", ] @@ -3907,8 +4122,8 @@ version = "1.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdffd393e5e346c52509608ac6c3be178523931bf9f50c18d23836474521d17" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -4005,6 +4220,7 @@ dependencies = [ "http", "hyper", "lazy-regex 3.0.1", + "libsql-client", "libtest-mimic", "log", "madsim", @@ -4028,7 +4244,7 @@ dependencies = [ "pretty_assertions", "prometheus", "prometheus-client", - "prost", + "prost 0.11.9", "quick-xml 0.30.0", "rand 0.8.5", "redb", @@ -4289,9 +4505,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -4657,6 +4873,26 @@ dependencies = [ "phf_shared", ] +[[package]] +name = "phf_codegen" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared", + "rand 0.8.5", +] + [[package]] name = "phf_shared" version = "0.11.2" @@ -4664,6 +4900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", + "uncased", ] [[package]] @@ -4681,9 +4918,9 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -4868,7 +5105,7 @@ version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.63", "syn 1.0.109", ] @@ -4878,8 +5115,8 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" dependencies = [ - "proc-macro2", - "syn 2.0.23", + "proc-macro2 1.0.63", + "syn 2.0.32", ] [[package]] @@ -4918,8 +5155,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", "version_check", ] @@ -4930,8 +5167,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "version_check", ] @@ -4941,6 +5178,15 @@ version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + [[package]] name = "proc-macro2" version = "1.0.63" @@ -4999,9 +5245,9 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -5011,7 +5257,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", ] [[package]] @@ -5028,7 +5284,7 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost", + "prost 0.11.9", "prost-types", "regex", "syn 1.0.109", @@ -5044,18 +5300,31 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", ] [[package]] @@ -5079,8 +5348,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -5104,7 +5373,7 @@ dependencies = [ "cfg-if", "indoc", "libc", - "memoffset", + "memoffset 0.9.0", "parking_lot 0.12.1", "pyo3-build-config", "pyo3-ffi", @@ -5151,9 +5420,9 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a5caec6a1dd355964a841fcbeeb1b89fe4146c87295573f94228911af3cc5a2" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.63", "pyo3-macros-backend", - "quote", + "quote 1.0.29", "syn 1.0.109", ] @@ -5163,8 +5432,8 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0b78ccbb160db1556cdb6fd96c50334c5d4ec44dc5e0a968d0a1208fa0efa8b" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -5226,13 +5495,22 @@ dependencies = [ "serde", ] +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + [[package]] name = "quote" version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.63", ] [[package]] @@ -5369,8 +5647,8 @@ checksum = "335a95eb0420d52fa94ef12019df3c2c250c6b19cbb3c60bd05cb7e9c362072c" dependencies = [ "bindgen 0.62.0", "lazy_static", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "regex", "shell-words", "syn 1.0.109", @@ -5419,7 +5697,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-retry", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-util", "url", ] @@ -5580,7 +5858,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-util", "tower-service", "trust-dns-resolver", @@ -5589,6 +5867,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", + "webpki-roots 0.22.6", "winreg 0.10.1", ] @@ -5646,8 +5925,8 @@ version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -5795,7 +6074,19 @@ dependencies = [ "log", "ring", "sct 0.6.1", - "webpki", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.2", ] [[package]] @@ -5974,9 +6265,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.166" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -5992,13 +6283,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.166" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -6232,8 +6523,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "475b3bbe5245c26f2d8a6f62d67c1f30eb9fffeccee721c45d162c3ebbdf81b2" dependencies = [ "heck", - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "syn 1.0.109", ] @@ -6282,6 +6573,25 @@ dependencies = [ "der", ] +[[package]] +name = "sqlite3-parser" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3995a6daa13c113217b6ad22154865fb06f9cb939bef398fd04f4a7aaaf5bd7" +dependencies = [ + "bitflags 2.3.3", + "cc", + "fallible-iterator", + "indexmap 1.9.3", + "log", + "memchr", + "phf", + "phf_codegen", + "phf_shared", + "smallvec", + "uncased", +] + [[package]] name = "ssh_format" version = "0.14.1" @@ -6378,25 +6688,36 @@ dependencies = [ "thiserror", ] +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid", +] + [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.23" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 1.0.63", + "quote 1.0.29", "unicode-ident", ] @@ -6466,22 +6787,22 @@ checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -6543,7 +6864,7 @@ dependencies = [ "log", "pin-project", "prometheus", - "prost", + "prost 0.11.9", "rand 0.8.5", "regex", "semver", @@ -6551,7 +6872,7 @@ dependencies = [ "serde_derive", "thiserror", "tokio", - "tonic", + "tonic 0.9.2", "tonic-build", "tonic-disable-doctest", ] @@ -6674,9 +6995,9 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -6734,6 +7055,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls 0.20.9", + "tokio", + "webpki 0.22.2", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -6755,6 +7087,22 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" +dependencies = [ + "futures-util", + "log", + "rustls 0.20.9", + "tokio", + "tokio-rustls 0.23.4", + "tungstenite", + "webpki 0.22.2", + "webpki-roots 0.22.6", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -6832,10 +7180,10 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", + "prost 0.11.9", "rustls-pemfile", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-stream", "tower", "tower-layer", @@ -6843,6 +7191,37 @@ dependencies = [ "tracing", ] +[[package]] +name = "tonic" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5469afaf78a11265c343a88969045c1568aa8ecc6c787dbf756e92e70f199861" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.2", + "bytes", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.12.1", + "rustls-native-certs", + "rustls-pemfile", + "tokio", + "tokio-rustls 0.24.1", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", + "webpki-roots 0.25.2", +] + [[package]] name = "tonic-build" version = "0.9.2" @@ -6850,9 +7229,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" dependencies = [ "prettyplease 0.1.25", - "proc-macro2", + "proc-macro2 1.0.63", "prost-build", - "quote", + "quote 1.0.29", "syn 1.0.109", ] @@ -6867,6 +7246,26 @@ dependencies = [ "tonic-build", ] +[[package]] +name = "tonic-web" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fddb2a37b247e6adcb9f239f4e5cefdcc5ed526141a416b943929f13aea2cce" +dependencies = [ + "base64 0.21.2", + "bytes", + "http", + "http-body", + "hyper", + "pin-project", + "tokio-stream", + "tonic 0.10.0", + "tower-http", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower" version = "0.4.13" @@ -6889,9 +7288,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8bd22a874a2d0b70452d5597b12c537331d49060824a95f49f108994f94aa4c" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "bitflags 2.3.3", "bytes", @@ -6901,6 +7300,7 @@ dependencies = [ "http-body", "http-range-header", "pin-project-lite", + "tower", "tower-layer", "tower-service", "tracing", @@ -6937,9 +7337,9 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", ] [[package]] @@ -7010,7 +7410,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f" dependencies = [ - "quote", + "quote 1.0.29", "syn 1.0.109", ] @@ -7082,6 +7482,27 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb1626d07cb5c1bb2cf17d94c0be4852e8a7c02b041acec9a8c5bdda99f9d580" +[[package]] +name = "tungstenite" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +dependencies = [ + "base64 0.13.1", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand 0.8.5", + "rustls 0.20.9", + "sha1", + "thiserror", + "url", + "utf-8", + "webpki 0.22.2", +] + [[package]] name = "twox-hash" version = "1.6.3" @@ -7099,6 +7520,15 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uncased" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" +dependencies = [ + "version_check", +] + [[package]] name = "unicase" version = "2.6.0" @@ -7141,6 +7571,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unindent" version = "0.1.11" @@ -7194,6 +7630,12 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.1" @@ -7322,9 +7764,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", "wasm-bindgen-shared", ] @@ -7346,7 +7788,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ - "quote", + "quote 1.0.29", "wasm-bindgen-macro-support", ] @@ -7356,9 +7798,9 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.23", + "proc-macro2 1.0.63", + "quote 1.0.29", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7402,13 +7844,32 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki-roots" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" dependencies = [ - "webpki", + "webpki 0.21.4", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki 0.22.2", ] [[package]] @@ -7420,6 +7881,12 @@ dependencies = [ "rustls-webpki 0.100.1", ] +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "which" version = "4.4.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index f1c568c516b9..4c845bda61b0 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -178,6 +178,7 @@ services-webdav = [] services-webhdfs = [] services-mysql = ["dep:mysql_async"] services-sqlite = ["dep:rusqlite"] +services-libsql = ["dep:libsql-client"] [lib] bench = false @@ -278,6 +279,7 @@ uuid = { version = "1", features = ["serde", "v4"] } mysql_async = { version = "0.32.2", optional = true } bb8-postgres = { version = "0.8.1", optional = true } rusqlite = { version = "0.29.0", optional = true, features = ["bundled"] } +libsql-client = { version = "0.32.0", optional = true } [dev-dependencies] criterion = { version = "0.4", features = ["async", "async_tokio"] } diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs new file mode 100644 index 000000000000..3060d5ca9826 --- /dev/null +++ b/core/src/services/libsql/backend.rs @@ -0,0 +1,345 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::collections::HashMap; +use std::fmt::Debug; + +use async_trait::async_trait; +use libsql_client::{args, Config, Statement, SyncClient, Value}; +use tokio::task; + +use crate::raw::adapters::kv; +use crate::raw::*; +use crate::*; + +#[doc = include_str!("docs.md")] +#[derive(Default)] +pub struct LibsqlBuilder { + connection_string: Option, + auth_token: Option, + + table: Option, + key_field: Option, + value_field: Option, + root: Option, +} + +impl Debug for LibsqlBuilder { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut ds = f.debug_struct("LibsqlBuilder"); + ds.field("connection_string", &self.connection_string) + .field("table", &self.table) + .field("key_field", &self.key_field) + .field("value_field", &self.value_field) + .field("root", &self.root); + + if self.auth_token.is_some() { + ds.field("auth_token", &""); + } + ds.finish() + } +} + +impl LibsqlBuilder { + /// Set the connection_string of the libsql service. + /// + /// This connection string is used to connect to the libsql service. There are url based formats: + /// + /// ## Url + /// + /// This format resembles the url format of the libsql client. + /// + /// for a local database stored in a file: + /// + /// - `file://data.db` + /// + /// for a remote database connection: + /// + /// - `https://example.com/db` + pub fn connection_string(&mut self, v: &str) -> &mut Self { + if !v.is_empty() { + self.connection_string = Some(v.to_string()); + } + self + } + + /// set the authentication token for libsql service. + /// + /// default: no authentication token + pub fn auth_token(&mut self, auth_token: &str) -> &mut Self { + if !auth_token.is_empty() { + self.auth_token = Some(auth_token.to_owned()); + } + self + } + + /// set the working directory, all operations will be performed under it. + /// + /// default: "/" + pub fn root(&mut self, root: &str) -> &mut Self { + if !root.is_empty() { + self.root = Some(root.to_string()); + } + self + } + + /// Set the table name of the libsql service to read/write. + pub fn table(&mut self, table: &str) -> &mut Self { + if !table.is_empty() { + self.table = Some(table.to_string()); + } + self + } + + /// Set the key field name of the libsql service to read/write. + /// + /// Default to `key` if not specified. + pub fn key_field(&mut self, key_field: &str) -> &mut Self { + if !key_field.is_empty() { + self.key_field = Some(key_field.to_string()); + } + self + } + + /// Set the value field name of the libsql service to read/write. + /// + /// Default to `value` if not specified. + pub fn value_field(&mut self, value_field: &str) -> &mut Self { + if !value_field.is_empty() { + self.value_field = Some(value_field.to_string()); + } + self + } +} + +impl Builder for LibsqlBuilder { + const SCHEME: Scheme = Scheme::Libsql; + type Accessor = LibsqlBackend; + + fn from_map(map: HashMap) -> Self { + let mut builder = LibsqlBuilder::default(); + map.get("connection_string") + .map(|v| builder.connection_string(v)); + map.get("auth_token").map(|v| builder.auth_token(v)); + map.get("table").map(|v| builder.table(v)); + map.get("key_field").map(|v| builder.key_field(v)); + map.get("value_field").map(|v| builder.value_field(v)); + map.get("root").map(|v| builder.root(v)); + builder + } + + fn build(&mut self) -> Result { + let conn = match self.connection_string.clone() { + Some(v) => v, + None => { + return Err( + Error::new(ErrorKind::ConfigInvalid, "connection_string is empty") + .with_context("service", Scheme::Libsql), + ) + } + }; + + let table = match self.table.clone() { + Some(v) => v, + None => { + return Err(Error::new(ErrorKind::ConfigInvalid, "table is empty") + .with_context("service", Scheme::Libsql)) + } + }; + let key_field = match self.key_field.clone() { + Some(v) => v, + None => "key".to_string(), + }; + let value_field = match self.value_field.clone() { + Some(v) => v, + None => "value".to_string(), + }; + let root = normalize_root( + self.root + .clone() + .unwrap_or_else(|| "/".to_string()) + .as_str(), + ); + + Ok(LibsqlBackend::new(Adapter { + connection_string: conn, + auth_token: self.auth_token.clone(), + table, + key_field, + value_field, + }) + .with_root(&root)) + } +} + +/// Backend for libsql service +pub type LibsqlBackend = kv::Backend; + +#[derive(Clone)] +pub struct Adapter { + connection_string: String, + auth_token: Option, + + table: String, + key_field: String, + value_field: String, +} + +impl Debug for Adapter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut ds = f.debug_struct("LibsqlAdapter"); + ds.field("connection_string", &self.connection_string) + .field("table", &self.table) + .field("key_field", &self.key_field) + .field("value_field", &self.value_field); + + if self.auth_token.is_some() { + ds.field("auth_token", &""); + } + + ds.finish() + } +} + +impl Adapter { + fn get_config(&self) -> Result { + let mut config = Config::new(self.connection_string.clone().as_str()).map_err(|err| { + Error::new(ErrorKind::ConfigInvalid, "connection_string is invalid") + .with_context("service", Scheme::Libsql) + .set_source(err) + })?; + if let Some(auth_token) = self.auth_token.clone() { + config = config.with_auth_token(auth_token); + } + Ok(config) + } +} + +#[async_trait] +impl kv::Adapter for Adapter { + fn metadata(&self) -> kv::Metadata { + kv::Metadata::new( + Scheme::Libsql, + &self.table, + Capability { + read: true, + write: true, + create_dir: true, + delete: true, + ..Default::default() + }, + ) + } + + async fn get(&self, path: &str) -> Result>> { + let cloned_path = path.to_string(); + let cloned_self = self.clone(); + + task::spawn_blocking(move || cloned_self.blocking_get(cloned_path.as_str())) + .await + .map_err(|err| { + Error::new( + ErrorKind::Unexpected, + "unhandled error from libsql when spawning task", + ) + .set_source(err) + }) + .and_then(|inner_result| inner_result) + } + + fn blocking_get(&self, path: &str) -> Result>> { + let query = format!( + "SELECT {} FROM {} WHERE `{}` = ? LIMIT 1", + self.value_field, self.table, self.key_field + ); + let client = SyncClient::from_config(self.get_config()?).map_err(|err| { + Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) + })?; + let rs = client + .execute(Statement::with_args(query, args!(path))) + .map_err(|err| Error::new(ErrorKind::Unexpected, "get failed").set_source(err))?; + let val = rs.rows.first().map(|row| row.values.get(0)); + match val { + Some(Some(v)) => match v { + Value::Null => Ok(None), + Value::Blob { value } => Ok(Some(value.to_owned())), + _ => Err(Error::new(ErrorKind::Unexpected, "invalid value type")), + }, + _ => Ok(None), + } + } + + async fn set(&self, path: &str, value: &[u8]) -> Result<()> { + let cloned_path = path.to_string(); + let cloned_value = value.to_vec(); + let cloned_self = self.clone(); + + task::spawn_blocking(move || cloned_self.blocking_set(cloned_path.as_str(), &cloned_value)) + .await + .map_err(|err| { + Error::new( + ErrorKind::Unexpected, + "unhandled error from libsql when spawning task", + ) + .set_source(err) + }) + .and_then(|inner_result| inner_result) + } + + fn blocking_set(&self, path: &str, value: &[u8]) -> Result<()> { + let query = format!( + "INSERT OR REPLACE INTO `{}` (`{}`, `{}`) VALUES (?, ?)", + self.table, self.key_field, self.value_field + ); + let client = SyncClient::from_config(self.get_config()?).map_err(|err| { + Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) + })?; + + client + .execute(Statement::with_args(query, args!(path, value.to_vec()))) + .map_err(|err| Error::new(ErrorKind::Unexpected, "set failed").set_source(err))?; + Ok(()) + } + + async fn delete(&self, path: &str) -> Result<()> { + let cloned_path = path.to_string(); + let cloned_self = self.clone(); + + task::spawn_blocking(move || cloned_self.blocking_delete(cloned_path.as_str())) + .await + .map_err(|err| { + Error::new( + ErrorKind::Unexpected, + "unhandled error from libsql when spawning task", + ) + .set_source(err) + }) + .and_then(|inner_result| inner_result) + } + + fn blocking_delete(&self, path: &str) -> Result<()> { + let query = format!("DELETE FROM {} WHERE `{}` = ?", self.table, self.key_field); + + let client = SyncClient::from_config(self.get_config()?).map_err(|err| { + Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) + })?; + client + .execute(Statement::with_args(query, args!(path))) + .map_err(|err| Error::new(ErrorKind::Unexpected, "delete failed").set_source(err))?; + Ok(()) + } +} diff --git a/core/src/services/libsql/docs.md b/core/src/services/libsql/docs.md new file mode 100644 index 000000000000..00d0408c12c7 --- /dev/null +++ b/core/src/services/libsql/docs.md @@ -0,0 +1,50 @@ +## Capabilities + +This service can be used to: + +- [x] stat +- [x] read +- [x] write +- [x] create_dir +- [x] delete +- [ ] copy +- [ ] rename +- [ ] ~~list~~ +- [ ] scan +- [ ] ~~presign~~ +- [ ] blocking + +## Configuration + +- `root`: Set the working directory of `OpenDAL` +- `connection_string`: Set the connection string for libsql server +- `auth_token`: Set the authentication token for libsql server +- `table`: Set the table of libsql +- `key_field`: Set the key field of libsql +- `value_field`: Set the value field of libsql + +## Example + +### Via Builder + +```rust +use anyhow::Result; +use opendal::services::Libsql; +use opendal::Operator; + +#[tokio::main] +async fn main() -> Result<()> { + let mut builder = Libsql::default(); + builder.root("/"); + builder.connection_string("https://example.com/db"); + builder.auth_token("secret"); + builder.table("your_table"); + // key field type in the table should be compatible with Rust's &str like text + builder.key_field("key"); + // value field type in the table should be compatible with Rust's Vec like bytea + builder.value_field("value"); + + let op = Operator::new(builder)?.finish(); + Ok(()) +} +``` diff --git a/core/src/services/libsql/mod.rs b/core/src/services/libsql/mod.rs new file mode 100644 index 000000000000..0bd6cb7999e7 --- /dev/null +++ b/core/src/services/libsql/mod.rs @@ -0,0 +1,19 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +mod backend; +pub use backend::LibsqlBuilder as Libsql; diff --git a/core/src/services/mod.rs b/core/src/services/mod.rs index 4e00c19fcff8..5293aaa443e9 100644 --- a/core/src/services/mod.rs +++ b/core/src/services/mod.rs @@ -84,6 +84,11 @@ mod ipmfs; #[cfg(feature = "services-ipmfs")] pub use ipmfs::Ipmfs; +#[cfg(feature = "services-libsql")] +mod libsql; +#[cfg(feature = "services-libsql")] +pub use libsql::Libsql; + #[cfg(feature = "services-memcached")] mod memcached; #[cfg(feature = "services-memcached")] diff --git a/core/src/types/scheme.rs b/core/src/types/scheme.rs index 84480bf68b74..ec3298b7bd59 100644 --- a/core/src/types/scheme.rs +++ b/core/src/types/scheme.rs @@ -88,6 +88,8 @@ pub enum Scheme { Redis, /// [postgresql][crate::services::Postgresql]: Postgresql services Postgresql, + /// [libsql][crate::services::Libsql]: Libsql services + Libsql, /// [mysql][crate::services::Mysql]: Mysql services Mysql, /// [sqlite][crate::services::Sqlite]: Sqlite services @@ -169,6 +171,7 @@ impl FromStr for Scheme { "ftp" | "ftps" => Ok(Scheme::Ftp), "ipfs" | "ipns" => Ok(Scheme::Ipfs), "ipmfs" => Ok(Scheme::Ipmfs), + "libsql" => Ok(Scheme::Libsql), "memcached" => Ok(Scheme::Memcached), "memory" => Ok(Scheme::Memory), "mysql" => Ok(Scheme::Mysql), @@ -216,6 +219,7 @@ impl From for &'static str { Scheme::Ftp => "ftp", Scheme::Ipfs => "ipfs", Scheme::Ipmfs => "ipmfs", + Scheme::Libsql => "libsql", Scheme::Memcached => "memcached", Scheme::Memory => "memory", Scheme::MiniMoka => "mini_moka", diff --git a/core/tests/behavior/main.rs b/core/tests/behavior/main.rs index 695eefe2ce28..4c203d099351 100644 --- a/core/tests/behavior/main.rs +++ b/core/tests/behavior/main.rs @@ -132,6 +132,8 @@ fn main() -> anyhow::Result<()> { tests.extend(behavior_test::()); #[cfg(feature = "services-ipmfs")] tests.extend(behavior_test::()); + #[cfg(feature = "services-libsql")] + tests.extend(behavior_test::()); #[cfg(feature = "services-memcached")] tests.extend(behavior_test::()); #[cfg(feature = "services-memory")] From 699126ddee0901a1e905c5b90e461673d4e6a84b Mon Sep 17 00:00:00 2001 From: G-XD Date: Sat, 7 Oct 2023 16:03:42 +0800 Subject: [PATCH 2/5] ci(service/libsql): add ci action --- .github/workflows/service_test_libsql.yml | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/service_test_libsql.yml diff --git a/.github/workflows/service_test_libsql.yml b/.github/workflows/service_test_libsql.yml new file mode 100644 index 000000000000..8595266f617e --- /dev/null +++ b/.github/workflows/service_test_libsql.yml @@ -0,0 +1,83 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Service Test Libsql + +on: + push: + branches: + - main + pull_request: + branches: + - main + paths: + - "core/src/**" + - "core/tests/**" + - "!core/src/docs/**" + - "!core/src/services/**" + - "core/src/services/libsql/**" + - ".github/workflows/service_test_libsql.yml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + +jobs: + libsql: + runs-on: ubuntu-latest + + services: + libsql: + image: ghcr.io/libsql/sqld:latest + ports: + - "8080:8080" + env: + SQLD_MAX_RESPONSE_SIZE: 20971520 + SQLD_MAX_TOTAL_RESPONSE_SIZE: 209715200 + + steps: + - uses: actions/checkout@v4 + - name: Create table + shell: bash + working-directory: core + run: | + curl --location '127.0.0.1:8080/' \ + --header 'Content-Type: application/json' \ + --data '{ + "statements": [ + {"q": "CREATE TABLE IF NOT EXISTS `data` (`key` TEXT PRIMARY KEY NOT NULL CHECK(length(key) <= 255),`data` BLOB);"} + ] + }' + + - name: Setup Rust toolchain + uses: ./.github/actions/setup + with: + need-nextest: true + + - name: Test + shell: bash + working-directory: core + # The sqld service allows a maximum of 128 connections. If all connections are in use, new connections will be queued and wait for up to 1 second before becoming available. + # And that these connection settings are hard-coded. + # See: https://github.com/libsql/sqld/pull/383 + run: NEXTEST_TEST_THREADS=1 cargo nextest run libsql --features services-libsql + env: + OPENDAL_LIBSQL_TEST: on + OPENDAL_LIBSQL_CONNECTION_STRING: http://127.0.0.1:8080 + OPENDAL_LIBSQL_TABLE: data + OPENDAL_LIBSQL_KEY_FIELD: key + OPENDAL_LIBSQL_VALUE_FIELD: data From 6dff8cd71567789b15783816c0b31b059e6c7c8c Mon Sep 17 00:00:00 2001 From: G-XD Date: Tue, 10 Oct 2023 22:54:34 +0800 Subject: [PATCH 3/5] feat(service/libsql): replace libsql-client with basic http request --- Cargo.lock | 754 ++++++---------------------- core/Cargo.toml | 4 +- core/src/services/libsql/backend.rs | 249 +++++---- core/src/services/libsql/error.rs | 60 +++ core/src/services/libsql/mod.rs | 2 + 5 files changed, 367 insertions(+), 702 deletions(-) create mode 100644 core/src/services/libsql/error.rs diff --git a/Cargo.lock b/Cargo.lock index f39ef36fd527..d101e5b5653e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,8 +210,8 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "840d2e9edec91ac974365978efc6f00781ff497e706a12306fff29ae92f8ad46" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -303,8 +303,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -314,8 +314,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -362,8 +362,8 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -382,7 +382,7 @@ dependencies = [ "futures-core", "futures-io", "rustls 0.19.1", - "webpki 0.21.4", + "webpki", "webpki-roots 0.21.1", ] @@ -392,8 +392,8 @@ version = "0.1.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -622,8 +622,8 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -644,31 +644,8 @@ dependencies = [ "log", "peeking_take_while", "prettyplease 0.2.9", - "proc-macro2 1.0.63", - "quote 1.0.29", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.32", - "which", -] - -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.3.3", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease 0.2.9", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -743,7 +720,7 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", - "proc-macro2 1.0.63", + "proc-macro2", "syn 1.0.109", ] @@ -753,8 +730,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -764,8 +741,8 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -813,8 +790,8 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -824,26 +801,6 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" -[[package]] -name = "bytemuck" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" -dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", - "syn 2.0.32", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -855,9 +812,6 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -dependencies = [ - "serde", -] [[package]] name = "bzip2" @@ -954,8 +908,8 @@ dependencies = [ "heck", "indexmap 1.9.3", "log", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "serde", "serde_json", "syn 1.0.109", @@ -1102,8 +1056,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -1373,7 +1327,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset", "scopeguard", ] @@ -1418,7 +1372,7 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ - "quote 1.0.29", + "quote", "syn 1.0.109", ] @@ -1428,7 +1382,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eed5fff0d93c7559121e9c72bf9c242295869396255071ff2cb1617147b608c5" dependencies = [ - "quote 1.0.29", + "quote", "syn 2.0.32", ] @@ -1459,8 +1413,8 @@ dependencies = [ "cc", "codespan-reporting", "once_cell", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "scratch", "syn 2.0.32", ] @@ -1477,8 +1431,8 @@ version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -1510,8 +1464,8 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "strsim", "syn 1.0.109", ] @@ -1524,8 +1478,8 @@ checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "strsim", "syn 2.0.32", ] @@ -1537,7 +1491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core 0.14.4", - "quote 1.0.29", + "quote", "syn 1.0.109", ] @@ -1548,7 +1502,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", - "quote 1.0.29", + "quote", "syn 2.0.32", ] @@ -1621,17 +1575,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1" -[[package]] -name = "default-env" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f753eb82d29277e79efc625e84aecacfd4851ee50e05a8573a4740239a77bfd3" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "defer" version = "0.1.0" @@ -1655,8 +1598,8 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -1666,8 +1609,8 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53e0efad4403bfc52dc201159c4b842a246a14b98c64b55dfd0f2d89729dfeb8" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -1687,8 +1630,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" dependencies = [ "darling 0.14.4", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -1708,8 +1651,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35cb7e5875e1028a73e551747d6d0118f25c3d6dbba2dadf97cc0f4d0c53f2f5" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -1833,8 +1776,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ "heck", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -1894,10 +1837,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4b0ea5ef6dc2388a4b1669fa32097249bc03a15417b97cb75e38afb309e4a89" dependencies = [ "http", - "prost 0.11.9", + "prost", "tokio", "tokio-stream", - "tonic 0.9.2", + "tonic", "tonic-build", "tower", "tower-service", @@ -1939,8 +1882,8 @@ dependencies = [ "darling 0.14.4", "ident_case", "lazy_static", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -2089,8 +2032,8 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83c8d52fe8b46ab822b4decdcc0d6d85aeedfc98f0d52ba2bd4aec4a97807516" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", "try_map", ] @@ -2128,7 +2071,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", - "quote 1.0.29", + "quote", "syn 2.0.32", ] @@ -2139,8 +2082,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35b54add839292b743aeda6ebedbd8b11e93404f902c56223e51b9ec18a13d2c" dependencies = [ "frunk_core", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -2152,7 +2095,7 @@ checksum = "71b85a1d4a9a6b300b41c05e8e13ef2feca03e0334127f29eca9506a7fe13a93" dependencies = [ "frunk_core", "frunk_proc_macro_helpers", - "quote 1.0.29", + "quote", "syn 2.0.32", ] @@ -2241,8 +2184,8 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -2544,23 +2487,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "hrana-client" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80430f3ff61d4ec7388b11feb2e5df4b2fe8b61f1f7956673307fc3ae4f82798" -dependencies = [ - "anyhow", - "base64 0.21.2", - "futures", - "hrana-client-proto", - "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-tungstenite", -] - [[package]] name = "hrana-client-proto" version = "0.2.1" @@ -2678,12 +2604,9 @@ checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ "http", "hyper", - "log", "rustls 0.21.6", - "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", - "webpki-roots 0.23.1", + "tokio-rustls", ] [[package]] @@ -2969,8 +2892,8 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8edfc11b8f56ce85e207e62ea21557cfa09bb24a8f6b04ae181b086ff8611c22" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "syn 1.0.109", ] @@ -2981,8 +2904,8 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0a1d9139f0ee2e862e08a9c5d0ba0470f2aa21cd1e1aa1b1562f83116c725f" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "syn 2.0.32", ] @@ -3122,100 +3045,6 @@ dependencies = [ "libz-sys", ] -[[package]] -name = "libsql" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b338b21c151cd923d619146adc7e5364197794381cebb3270c31338da6736e" -dependencies = [ - "async-trait", - "base64 0.21.2", - "crossbeam-channel", - "futures", - "hrana-client-proto", - "hyper", - "hyper-rustls", - "libsql-sys", - "libsql_replication", - "parking_lot 0.12.1", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "libsql-client" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5422994ae3142c5302ce94626f5e7a783b68839c64db35a93002cb029628afd5" -dependencies = [ - "anyhow", - "base64 0.21.2", - "fallible-iterator", - "futures", - "hrana-client", - "hrana-client-proto", - "libsql", - "num-traits", - "reqwest", - "serde", - "serde_json", - "sqlite3-parser", - "tracing", - "url", -] - -[[package]] -name = "libsql-sys" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beff96c554acb45beb77380110d724767837952985aecb78d545bbba90b0c80c" -dependencies = [ - "bindgen 0.66.1", - "cc", - "default-env", - "once_cell", - "tracing", -] - -[[package]] -name = "libsql_replication" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd143d93ffc33a234b1386bdcaaa7bc8478c2105a0e588b3983cc5ec322e20a" -dependencies = [ - "anyhow", - "bytemuck", - "bytes", - "crossbeam", - "futures", - "http", - "hyper", - "hyper-rustls", - "libsql-sys", - "memmap", - "nix", - "once_cell", - "parking_lot 0.12.1", - "prost 0.12.1", - "regex", - "serde", - "serde_json", - "tempfile", - "thiserror", - "tokio", - "tokio-stream", - "tonic 0.10.0", - "tonic-web", - "tower", - "tower-http", - "tracing", - "uuid", -] - [[package]] name = "libsqlite3-sys" version = "0.26.0" @@ -3397,8 +3226,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d248e97b1a48826a12c3828d921e8548e714394bf17274dd0a93910dc946e1" dependencies = [ "darling 0.14.4", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3420,8 +3249,8 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cc17af1d45442c011aa579d727ec6cff8a69aea8a6bbad26736e7112d749bfb" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3467,16 +3296,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "memmap2" version = "0.5.10" @@ -3486,15 +3305,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -3521,8 +3331,8 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3544,8 +3354,8 @@ version = "5.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4901771e1d44ddb37964565c654a3223ba41a594d02b8da471cc4464912b5cfa" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -3620,8 +3430,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2277f13e7d585f02062590b3496cc0ca862aefadd24888efa01d50843605b79" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3678,8 +3488,8 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9214e60d3cf1643013b107330fcd374ccec1e4ba1eef76e7e5da5e8202e71c0" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3726,8 +3536,8 @@ dependencies = [ "num-bigint", "proc-macro-crate 1.3.1", "proc-macro-error", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", "termcolor", "thiserror", @@ -3839,8 +3649,8 @@ dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -3852,8 +3662,8 @@ checksum = "20bbc7c69168d06a848f925ec5f0e0997f98e8c8d4f2cc30157f0da51c009e17" dependencies = [ "convert_case", "once_cell", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "semver", "syn 1.0.109", @@ -3886,19 +3696,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", - "pin-utils", -] - [[package]] name = "no-std-compat" version = "0.4.1" @@ -3971,8 +3768,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -4112,7 +3909,7 @@ version = "1.0.0-beta.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae2b0b155a81c2f3f9e71cb1f47e84d705d852e9ea7c10955d8bce1fa2d26aa0" dependencies = [ - "proc-macro2 1.0.63", + "proc-macro2", "syn 1.0.109", ] @@ -4122,8 +3919,8 @@ version = "1.0.0-beta.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdffd393e5e346c52509608ac6c3be178523931bf9f50c18d23836474521d17" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -4217,10 +4014,10 @@ dependencies = [ "futures", "governor", "hdrs", + "hrana-client-proto", "http", "hyper", "lazy-regex 3.0.1", - "libsql-client", "libtest-mimic", "log", "madsim", @@ -4244,7 +4041,7 @@ dependencies = [ "pretty_assertions", "prometheus", "prometheus-client", - "prost 0.11.9", + "prost", "quick-xml 0.30.0", "rand 0.8.5", "redb", @@ -4505,8 +4302,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -4873,26 +4670,6 @@ dependencies = [ "phf_shared", ] -[[package]] -name = "phf_codegen" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" -dependencies = [ - "phf_generator", - "phf_shared", -] - -[[package]] -name = "phf_generator" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" -dependencies = [ - "phf_shared", - "rand 0.8.5", -] - [[package]] name = "phf_shared" version = "0.11.2" @@ -4900,7 +4677,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ "siphasher", - "uncased", ] [[package]] @@ -4918,8 +4694,8 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -5105,7 +4881,7 @@ version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ - "proc-macro2 1.0.63", + "proc-macro2", "syn 1.0.109", ] @@ -5115,7 +4891,7 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" dependencies = [ - "proc-macro2 1.0.63", + "proc-macro2", "syn 2.0.32", ] @@ -5155,8 +4931,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", "version_check", ] @@ -5167,8 +4943,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "version_check", ] @@ -5178,15 +4954,6 @@ version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid", -] - [[package]] name = "proc-macro2" version = "1.0.63" @@ -5245,8 +5012,8 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -5257,17 +5024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive 0.11.9", -] - -[[package]] -name = "prost" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" -dependencies = [ - "bytes", - "prost-derive 0.12.1", + "prost-derive", ] [[package]] @@ -5284,7 +5041,7 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost 0.11.9", + "prost", "prost-types", "regex", "syn 1.0.109", @@ -5300,31 +5057,18 @@ checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] -[[package]] -name = "prost-derive" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2 1.0.63", - "quote 1.0.29", - "syn 2.0.32", -] - [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost 0.11.9", + "prost", ] [[package]] @@ -5348,8 +5092,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -5373,7 +5117,7 @@ dependencies = [ "cfg-if", "indoc", "libc", - "memoffset 0.9.0", + "memoffset", "parking_lot 0.12.1", "pyo3-build-config", "pyo3-ffi", @@ -5420,9 +5164,9 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a5caec6a1dd355964a841fcbeeb1b89fe4146c87295573f94228911af3cc5a2" dependencies = [ - "proc-macro2 1.0.63", + "proc-macro2", "pyo3-macros-backend", - "quote 1.0.29", + "quote", "syn 1.0.109", ] @@ -5432,8 +5176,8 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0b78ccbb160db1556cdb6fd96c50334c5d4ec44dc5e0a968d0a1208fa0efa8b" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -5495,22 +5239,13 @@ dependencies = [ "serde", ] -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ - "proc-macro2 1.0.63", + "proc-macro2", ] [[package]] @@ -5647,8 +5382,8 @@ checksum = "335a95eb0420d52fa94ef12019df3c2c250c6b19cbb3c60bd05cb7e9c362072c" dependencies = [ "bindgen 0.62.0", "lazy_static", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "regex", "shell-words", "syn 1.0.109", @@ -5697,7 +5432,7 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-retry", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-util", "url", ] @@ -5858,7 +5593,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-util", "tower-service", "trust-dns-resolver", @@ -5867,7 +5602,6 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 0.22.6", "winreg 0.10.1", ] @@ -5925,8 +5659,8 @@ version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -6074,19 +5808,7 @@ dependencies = [ "log", "ring", "sct 0.6.1", - "webpki 0.21.4", -] - -[[package]] -name = "rustls" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" -dependencies = [ - "log", - "ring", - "sct 0.7.0", - "webpki 0.22.2", + "webpki", ] [[package]] @@ -6287,8 +6009,8 @@ version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -6523,8 +6245,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "475b3bbe5245c26f2d8a6f62d67c1f30eb9fffeccee721c45d162c3ebbdf81b2" dependencies = [ "heck", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 1.0.109", ] @@ -6573,25 +6295,6 @@ dependencies = [ "der", ] -[[package]] -name = "sqlite3-parser" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3995a6daa13c113217b6ad22154865fb06f9cb939bef398fd04f4a7aaaf5bd7" -dependencies = [ - "bitflags 2.3.3", - "cc", - "fallible-iterator", - "indexmap 1.9.3", - "log", - "memchr", - "phf", - "phf_codegen", - "phf_shared", - "smallvec", - "uncased", -] - [[package]] name = "ssh_format" version = "0.14.1" @@ -6688,25 +6391,14 @@ dependencies = [ "thiserror", ] -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid", -] - [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "unicode-ident", ] @@ -6716,8 +6408,8 @@ version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "unicode-ident", ] @@ -6800,8 +6492,8 @@ version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -6864,7 +6556,7 @@ dependencies = [ "log", "pin-project", "prometheus", - "prost 0.11.9", + "prost", "rand 0.8.5", "regex", "semver", @@ -6872,7 +6564,7 @@ dependencies = [ "serde_derive", "thiserror", "tokio", - "tonic 0.9.2", + "tonic", "tonic-build", "tonic-disable-doctest", ] @@ -6995,8 +6687,8 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -7055,17 +6747,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls 0.20.9", - "tokio", - "webpki 0.22.2", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -7087,22 +6768,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" -dependencies = [ - "futures-util", - "log", - "rustls 0.20.9", - "tokio", - "tokio-rustls 0.23.4", - "tungstenite", - "webpki 0.22.2", - "webpki-roots 0.22.6", -] - [[package]] name = "tokio-util" version = "0.7.8" @@ -7180,10 +6845,10 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost 0.11.9", + "prost", "rustls-pemfile", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-stream", "tower", "tower-layer", @@ -7191,37 +6856,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tonic" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5469afaf78a11265c343a88969045c1568aa8ecc6c787dbf756e92e70f199861" -dependencies = [ - "async-stream", - "async-trait", - "axum", - "base64 0.21.2", - "bytes", - "h2", - "http", - "http-body", - "hyper", - "hyper-timeout", - "percent-encoding", - "pin-project", - "prost 0.12.1", - "rustls-native-certs", - "rustls-pemfile", - "tokio", - "tokio-rustls 0.24.1", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", - "webpki-roots 0.25.2", -] - [[package]] name = "tonic-build" version = "0.9.2" @@ -7229,9 +6863,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" dependencies = [ "prettyplease 0.1.25", - "proc-macro2 1.0.63", + "proc-macro2", "prost-build", - "quote 1.0.29", + "quote", "syn 1.0.109", ] @@ -7246,26 +6880,6 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "tonic-web" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fddb2a37b247e6adcb9f239f4e5cefdcc5ed526141a416b943929f13aea2cce" -dependencies = [ - "base64 0.21.2", - "bytes", - "http", - "http-body", - "hyper", - "pin-project", - "tokio-stream", - "tonic 0.10.0", - "tower-http", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower" version = "0.4.13" @@ -7300,7 +6914,6 @@ dependencies = [ "http-body", "http-range-header", "pin-project-lite", - "tower", "tower-layer", "tower-service", "tracing", @@ -7337,8 +6950,8 @@ version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", ] @@ -7410,7 +7023,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebeb235c5847e2f82cfe0f07eb971d1e5f6804b18dac2ae16349cc604380f82f" dependencies = [ - "quote 1.0.29", + "quote", "syn 1.0.109", ] @@ -7482,27 +7095,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb1626d07cb5c1bb2cf17d94c0be4852e8a7c02b041acec9a8c5bdda99f9d580" -[[package]] -name = "tungstenite" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "rustls 0.20.9", - "sha1", - "thiserror", - "url", - "utf-8", - "webpki 0.22.2", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -7520,15 +7112,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "uncased" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" -dependencies = [ - "version_check", -] - [[package]] name = "unicase" version = "2.6.0" @@ -7571,12 +7154,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unindent" version = "0.1.11" @@ -7630,12 +7207,6 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" -[[package]] -name = "utf-8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" - [[package]] name = "utf8parse" version = "0.2.1" @@ -7764,8 +7335,8 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", "wasm-bindgen-shared", ] @@ -7788,7 +7359,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ - "quote 1.0.29", + "quote", "wasm-bindgen-macro-support", ] @@ -7798,8 +7369,8 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", + "proc-macro2", + "quote", "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -7844,32 +7415,13 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ecc0cd7cac091bf682ec5efa18b1cff79d617b84181f38b3951dbe135f607f" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki-roots" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" dependencies = [ - "webpki 0.21.4", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki 0.22.2", + "webpki", ] [[package]] @@ -7881,12 +7433,6 @@ dependencies = [ "rustls-webpki 0.100.1", ] -[[package]] -name = "webpki-roots" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - [[package]] name = "which" version = "4.4.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index 4c845bda61b0..d36c82baceba 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -178,7 +178,7 @@ services-webdav = [] services-webhdfs = [] services-mysql = ["dep:mysql_async"] services-sqlite = ["dep:rusqlite"] -services-libsql = ["dep:libsql-client"] +services-libsql = ["dep:hrana-client-proto"] [lib] bench = false @@ -279,7 +279,7 @@ uuid = { version = "1", features = ["serde", "v4"] } mysql_async = { version = "0.32.2", optional = true } bb8-postgres = { version = "0.8.1", optional = true } rusqlite = { version = "0.29.0", optional = true, features = ["bundled"] } -libsql-client = { version = "0.32.0", optional = true } +hrana-client-proto = { version = "0.2.1", optional = true } [dev-dependencies] criterion = { version = "0.4", features = ["async", "async_tokio"] } diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs index 3060d5ca9826..cbe99d5be32e 100644 --- a/core/src/services/libsql/backend.rs +++ b/core/src/services/libsql/backend.rs @@ -17,15 +17,24 @@ use std::collections::HashMap; use std::fmt::Debug; +use std::str; use async_trait::async_trait; -use libsql_client::{args, Config, Statement, SyncClient, Value}; -use tokio::task; +use bytes::Bytes; +use hrana_client_proto::pipeline::{ + ClientMsg, Response, ServerMsg, StreamExecuteReq, StreamExecuteResult, StreamRequest, + StreamResponse, StreamResponseError, StreamResponseOk, +}; +use hrana_client_proto::Error as PipelineError; +use hrana_client_proto::{Stmt, StmtResult, Value}; +use http::{Request, Uri}; use crate::raw::adapters::kv; use crate::raw::*; use crate::*; +use super::error::parse_error; + #[doc = include_str!("docs.md")] #[derive(Default)] pub struct LibsqlBuilder { @@ -143,15 +152,7 @@ impl Builder for LibsqlBuilder { } fn build(&mut self) -> Result { - let conn = match self.connection_string.clone() { - Some(v) => v, - None => { - return Err( - Error::new(ErrorKind::ConfigInvalid, "connection_string is empty") - .with_context("service", Scheme::Libsql), - ) - } - }; + let conn = self.get_connection_string()?; let table = match self.table.clone() { Some(v) => v, @@ -175,7 +176,13 @@ impl Builder for LibsqlBuilder { .as_str(), ); + let client = HttpClient::new().map_err(|err| { + err.with_operation("Builder::build") + .with_context("service", Scheme::Libsql) + })?; + Ok(LibsqlBackend::new(Adapter { + client, connection_string: conn, auth_token: self.auth_token.clone(), table, @@ -186,11 +193,41 @@ impl Builder for LibsqlBuilder { } } +impl LibsqlBuilder { + fn get_connection_string(&self) -> Result { + let connection_string = self + .connection_string + .clone() + .ok_or_else(|| Error::new(ErrorKind::ConfigInvalid, "connection_string is empty"))?; + + let ep_url = connection_string + .replace("libsql://", "https://") + .parse::() + .map_err(|e| { + Error::new(ErrorKind::ConfigInvalid, "connection_string is invalid") + .with_context("service", Scheme::Libsql) + .with_context("connection_string", connection_string) + .set_source(e) + })?; + + match ep_url.scheme_str() { + None => Ok(format!("https://{ep_url}/")), + Some("http") | Some("https") => Ok(ep_url.to_string()), + Some(s) => Err( + Error::new(ErrorKind::ConfigInvalid, "invalid or unsupported scheme") + .with_context("service", Scheme::Libsql) + .with_context("scheme", s), + ), + } + } +} + /// Backend for libsql service pub type LibsqlBackend = kv::Backend; #[derive(Clone)] pub struct Adapter { + client: HttpClient, connection_string: String, auth_token: Option, @@ -216,16 +253,63 @@ impl Debug for Adapter { } impl Adapter { - fn get_config(&self) -> Result { - let mut config = Config::new(self.connection_string.clone().as_str()).map_err(|err| { - Error::new(ErrorKind::ConfigInvalid, "connection_string is invalid") + async fn execute(&self, sql: String, args: Vec) -> Result { + let url = format!("{}v2/pipeline", self.connection_string); + + let mut req = Request::post(&url); + + if let Some(auth_token) = self.auth_token.clone() { + req = req.header("Authorization", auth_token); + } + + let msg = ClientMsg { + baton: None, + requests: vec![StreamRequest::Execute(StreamExecuteReq { + stmt: Stmt { + sql, + args, + named_args: vec![], + want_rows: true, + }, + })], + }; + let body = serde_json::to_string(&msg).map_err(|err| { + Error::new(ErrorKind::Unexpected, "failed to serialize request") .with_context("service", Scheme::Libsql) .set_source(err) })?; - if let Some(auth_token) = self.auth_token.clone() { - config = config.with_auth_token(auth_token); + + let req = req + .body(AsyncBody::Bytes(Bytes::from(body))) + .map_err(new_request_build_error)?; + + let resp = self.client.send(req).await?; + + if resp.status() != http::StatusCode::OK { + return Err(parse_error(resp).await?); } - Ok(config) + + let bs = resp.into_body().bytes().await?; + + let resp: ServerMsg = serde_json::from_slice(&bs).map_err(|e| { + Error::new(ErrorKind::Unexpected, "deserialize json from response").set_source(e) + })?; + + if resp.results.is_empty() { + return Err(Error::new( + ErrorKind::Unexpected, + "Unexpected empty response from server", + )); + } + + if resp.results.len() > 1 { + return Err(Error::new( + ErrorKind::Unexpected, + "Unexpected multiple response from server", + )); + } + + Ok(resp) } } @@ -246,100 +330,73 @@ impl kv::Adapter for Adapter { } async fn get(&self, path: &str) -> Result>> { - let cloned_path = path.to_string(); - let cloned_self = self.clone(); - - task::spawn_blocking(move || cloned_self.blocking_get(cloned_path.as_str())) - .await - .map_err(|err| { - Error::new( - ErrorKind::Unexpected, - "unhandled error from libsql when spawning task", - ) - .set_source(err) - }) - .and_then(|inner_result| inner_result) - } - - fn blocking_get(&self, path: &str) -> Result>> { let query = format!( "SELECT {} FROM {} WHERE `{}` = ? LIMIT 1", self.value_field, self.table, self.key_field ); - let client = SyncClient::from_config(self.get_config()?).map_err(|err| { - Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) - })?; - let rs = client - .execute(Statement::with_args(query, args!(path))) - .map_err(|err| Error::new(ErrorKind::Unexpected, "get failed").set_source(err))?; - let val = rs.rows.first().map(|row| row.values.get(0)); - match val { - Some(Some(v)) => match v { - Value::Null => Ok(None), - Value::Blob { value } => Ok(Some(value.to_owned())), - _ => Err(Error::new(ErrorKind::Unexpected, "invalid value type")), - }, - _ => Ok(None), + let mut resp = self.execute(query, vec![Value::from(path)]).await?; + + match resp.results.swap_remove(0) { + Response::Ok(StreamResponseOk { + response: + StreamResponse::Execute(StreamExecuteResult { + result: StmtResult { cols: _, rows, .. }, + }), + }) => { + if rows.is_empty() || rows[0].is_empty() { + return Ok(None); + } else { + let val = &rows[0][0]; + match val { + Value::Null => Ok(None), + Value::Blob { value } => Ok(Some(value.to_owned())), + _ => Err(Error::new(ErrorKind::Unexpected, "invalid value type")), + } + } + } + Response::Ok(_) => Err(Error::new( + ErrorKind::Unexpected, + "Unexpected response from server", + )), + Response::Error(StreamResponseError { + error: PipelineError { message }, + }) => Err(Error::new( + ErrorKind::Unexpected, + format!("get failed: {}", message).as_str(), + )), } } async fn set(&self, path: &str, value: &[u8]) -> Result<()> { - let cloned_path = path.to_string(); - let cloned_value = value.to_vec(); - let cloned_self = self.clone(); - - task::spawn_blocking(move || cloned_self.blocking_set(cloned_path.as_str(), &cloned_value)) - .await - .map_err(|err| { - Error::new( - ErrorKind::Unexpected, - "unhandled error from libsql when spawning task", - ) - .set_source(err) - }) - .and_then(|inner_result| inner_result) - } - - fn blocking_set(&self, path: &str, value: &[u8]) -> Result<()> { let query = format!( "INSERT OR REPLACE INTO `{}` (`{}`, `{}`) VALUES (?, ?)", self.table, self.key_field, self.value_field ); - let client = SyncClient::from_config(self.get_config()?).map_err(|err| { - Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) - })?; - - client - .execute(Statement::with_args(query, args!(path, value.to_vec()))) - .map_err(|err| Error::new(ErrorKind::Unexpected, "set failed").set_source(err))?; - Ok(()) + let mut resp = self + .execute(query, vec![Value::from(path), Value::from(value.to_vec())]) + .await?; + match resp.results.swap_remove(0) { + Response::Ok(_) => Ok(()), + Response::Error(StreamResponseError { + error: PipelineError { message }, + }) => Err(Error::new( + ErrorKind::Unexpected, + format!("set failed: {}", message).as_str(), + )), + } } async fn delete(&self, path: &str) -> Result<()> { - let cloned_path = path.to_string(); - let cloned_self = self.clone(); - - task::spawn_blocking(move || cloned_self.blocking_delete(cloned_path.as_str())) - .await - .map_err(|err| { - Error::new( - ErrorKind::Unexpected, - "unhandled error from libsql when spawning task", - ) - .set_source(err) - }) - .and_then(|inner_result| inner_result) - } - - fn blocking_delete(&self, path: &str) -> Result<()> { let query = format!("DELETE FROM {} WHERE `{}` = ?", self.table, self.key_field); - - let client = SyncClient::from_config(self.get_config()?).map_err(|err| { - Error::new(ErrorKind::Unexpected, "connection failed").set_source(err) - })?; - client - .execute(Statement::with_args(query, args!(path))) - .map_err(|err| Error::new(ErrorKind::Unexpected, "delete failed").set_source(err))?; - Ok(()) + let mut resp = self.execute(query, vec![Value::from(path)]).await?; + match resp.results.swap_remove(0) { + Response::Ok(_) => Ok(()), + Response::Error(StreamResponseError { + error: PipelineError { message }, + }) => Err(Error::new( + ErrorKind::Unexpected, + format!("delete failed: {}", message).as_str(), + )), + } } } diff --git a/core/src/services/libsql/error.rs b/core/src/services/libsql/error.rs new file mode 100644 index 000000000000..a2a80a02ec10 --- /dev/null +++ b/core/src/services/libsql/error.rs @@ -0,0 +1,60 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use http::Response; +use http::StatusCode; + +use crate::raw::*; +use crate::Error; +use crate::ErrorKind; +use crate::Result; + +/// Parse error response into Error. +pub async fn parse_error(resp: Response) -> Result { + let (parts, body) = resp.into_parts(); + let bs = body.bytes().await?; + + let (kind, retryable) = match parts.status { + StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), + StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, false), + StatusCode::PRECONDITION_FAILED | StatusCode::NOT_MODIFIED => { + (ErrorKind::ConditionNotMatch, false) + } + StatusCode::INTERNAL_SERVER_ERROR + | StatusCode::BAD_GATEWAY + | StatusCode::SERVICE_UNAVAILABLE + | StatusCode::GATEWAY_TIMEOUT => (ErrorKind::Unexpected, true), + _ => (ErrorKind::Unexpected, false), + }; + + let mut message = String::from_utf8_lossy(&bs).into_owned(); + + // If there is no body here, fill with http response code. + if message.is_empty() { + message = format!("Error response code: {}", parts.status); + } + + let mut err = Error::new(kind, &message); + + err = with_error_response_context(err, parts); + + if retryable { + err = err.set_temporary(); + } + + Ok(err) +} diff --git a/core/src/services/libsql/mod.rs b/core/src/services/libsql/mod.rs index 0bd6cb7999e7..1b0d623c4e4a 100644 --- a/core/src/services/libsql/mod.rs +++ b/core/src/services/libsql/mod.rs @@ -17,3 +17,5 @@ mod backend; pub use backend::LibsqlBuilder as Libsql; + +mod error; From d70e3c16ce1fca2e83d7fd797f1f86dd79d66492 Mon Sep 17 00:00:00 2001 From: G-XD Date: Wed, 11 Oct 2023 02:01:29 +0800 Subject: [PATCH 4/5] ci(service/libsql): add test of auth --- .github/workflows/service_test_libsql.yml | 91 +++++++++++++++++------ core/src/services/libsql/backend.rs | 2 +- fixtures/libsql/docker-compose-auth.yml | 28 +++++++ fixtures/libsql/docker-compose.yml | 27 +++++++ 4 files changed, 126 insertions(+), 22 deletions(-) create mode 100644 fixtures/libsql/docker-compose-auth.yml create mode 100644 fixtures/libsql/docker-compose.yml diff --git a/.github/workflows/service_test_libsql.yml b/.github/workflows/service_test_libsql.yml index 8595266f617e..68ac2124c6ca 100644 --- a/.github/workflows/service_test_libsql.yml +++ b/.github/workflows/service_test_libsql.yml @@ -40,44 +40,93 @@ jobs: libsql: runs-on: ubuntu-latest - services: - libsql: - image: ghcr.io/libsql/sqld:latest - ports: - - "8080:8080" - env: - SQLD_MAX_RESPONSE_SIZE: 20971520 - SQLD_MAX_TOTAL_RESPONSE_SIZE: 209715200 - steps: - uses: actions/checkout@v4 + - name: Setup libsql Server + shell: bash + working-directory: fixtures/libsql + run: docker-compose -f docker-compose.yml up -d + + - name: Setup Rust toolchain + uses: ./.github/actions/setup + with: + need-nextest: true + - name: Create table shell: bash working-directory: core run: | - curl --location '127.0.0.1:8080/' \ + curl --location '127.0.0.1:8080/v2/pipeline' \ --header 'Content-Type: application/json' \ --data '{ - "statements": [ - {"q": "CREATE TABLE IF NOT EXISTS `data` (`key` TEXT PRIMARY KEY NOT NULL CHECK(length(key) <= 255),`data` BLOB);"} + "baton": null, + "requests": [ + { + "type": "execute", + "stmt": { + "sql": "CREATE TABLE IF NOT EXISTS `data` (`key` TEXT PRIMARY KEY NOT NULL CHECK(length(key) <= 255),`data` BLOB);", + "args": [], + "want_rows": true + } + } ] }' - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - - name: Test shell: bash working-directory: core - # The sqld service allows a maximum of 128 connections. If all connections are in use, new connections will be queued and wait for up to 1 second before becoming available. - # And that these connection settings are hard-coded. - # See: https://github.com/libsql/sqld/pull/383 - run: NEXTEST_TEST_THREADS=1 cargo nextest run libsql --features services-libsql + run: cargo nextest run libsql --features services-libsql env: OPENDAL_LIBSQL_TEST: on OPENDAL_LIBSQL_CONNECTION_STRING: http://127.0.0.1:8080 OPENDAL_LIBSQL_TABLE: data OPENDAL_LIBSQL_KEY_FIELD: key OPENDAL_LIBSQL_VALUE_FIELD: data + + libsql-auth: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup libsql-auth Server + shell: bash + working-directory: fixtures/libsql + run: docker-compose -f docker-compose-auth.yml up -d + + - name: Setup Rust toolchain + uses: ./.github/actions/setup + with: + need-nextest: true + + - name: Create table + shell: bash + working-directory: core + run: | + curl --location '127.0.0.1:8080/v2/pipeline' \ + --header 'Content-Type: application/json' \ + --header 'Authorization: Bearer eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjc5ODg0ODM4Mjd9.MatB2aLnPFusagqH2RMoVExP37o2GFLmaJbmd52OdLtAehRNeqeJZPrefP1t2GBFidApUTLlaBRL6poKq_s3CQ' \ + --data '{ + "baton": null, + "requests": [ + { + "type": "execute", + "stmt": { + "sql": "CREATE TABLE IF NOT EXISTS `data` (`key` TEXT PRIMARY KEY NOT NULL CHECK(length(key) <= 255),`data` BLOB);", + "args": [], + "want_rows": true + } + } + ] + }' + + - name: Test + shell: bash + working-directory: core + run: cargo nextest run libsql --features services-libsql + env: + OPENDAL_LIBSQL_TEST: on + OPENDAL_LIBSQL_CONNECTION_STRING: http://127.0.0.1:8080 + OPENDAL_LIBSQL_AUTH_TOKEN: eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjc5ODg0ODM4Mjd9.MatB2aLnPFusagqH2RMoVExP37o2GFLmaJbmd52OdLtAehRNeqeJZPrefP1t2GBFidApUTLlaBRL6poKq_s3CQ + OPENDAL_LIBSQL_TABLE: data + OPENDAL_LIBSQL_KEY_FIELD: key + OPENDAL_LIBSQL_VALUE_FIELD: data diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs index cbe99d5be32e..566e894c5261 100644 --- a/core/src/services/libsql/backend.rs +++ b/core/src/services/libsql/backend.rs @@ -259,7 +259,7 @@ impl Adapter { let mut req = Request::post(&url); if let Some(auth_token) = self.auth_token.clone() { - req = req.header("Authorization", auth_token); + req = req.header("Authorization", format!("Bearer {}", auth_token)); } let msg = ClientMsg { diff --git a/fixtures/libsql/docker-compose-auth.yml b/fixtures/libsql/docker-compose-auth.yml new file mode 100644 index 000000000000..d14214a0a597 --- /dev/null +++ b/fixtures/libsql/docker-compose-auth.yml @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +version: '3.8' + +services: + libsql: + image: ghcr.io/libsql/sqld:v0.21.9 + ports: + - '8080:8080' + environment: + - 'SQLD_MAX_RESPONSE_SIZE=20971520' + - 'SQLD_MAX_TOTAL_RESPONSE_SIZE=209715200' + - 'SQLD_AUTH_JWT_KEY=zaMv-aFGmB7PXkjM4IrMdF6B5zCYEiEGXW3RgMjNAtc' diff --git a/fixtures/libsql/docker-compose.yml b/fixtures/libsql/docker-compose.yml new file mode 100644 index 000000000000..77304afcc15f --- /dev/null +++ b/fixtures/libsql/docker-compose.yml @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +version: '3.8' + +services: + libsql: + image: ghcr.io/libsql/sqld:v0.21.9 + ports: + - '8080:8080' + environment: + - 'SQLD_MAX_RESPONSE_SIZE=20971520' + - 'SQLD_MAX_TOTAL_RESPONSE_SIZE=209715200' From a9649626c272f96e60c4968e3280cb6a40b93148 Mon Sep 17 00:00:00 2001 From: G-XD Date: Wed, 11 Oct 2023 02:15:18 +0800 Subject: [PATCH 5/5] doc(service/libsql): update --- .env.example | 2 +- core/src/services/libsql/backend.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 751645cd348b..79211cb97a46 100644 --- a/.env.example +++ b/.env.example @@ -167,7 +167,7 @@ OPENDAL_GDRIVE_CLIENT_SECRET= # libsql OPENDAL_LIBSQL_TEST=false OPENDAL_LIBSQL_ROOT=/tmp/opendal/ -OPENDAL_LIBSQL_CONNECTION_STRING=file://tmp/example.db +OPENDAL_LIBSQL_CONNECTION_STRING=https://example.com/db OPENDAL_LIBSQL_AUTH_TOKEN= OPENDAL_LIBSQL_TABLE=t_opendal OPENDAL_LIBSQL_KEY_FIELD=key diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs index 566e894c5261..db1291485e5e 100644 --- a/core/src/services/libsql/backend.rs +++ b/core/src/services/libsql/backend.rs @@ -72,13 +72,11 @@ impl LibsqlBuilder { /// /// This format resembles the url format of the libsql client. /// - /// for a local database stored in a file: - /// - /// - `file://data.db` - /// /// for a remote database connection: /// + /// - `http://example.com/db` /// - `https://example.com/db` + /// - `libsql://example.com/db` pub fn connection_string(&mut self, v: &str) -> &mut Self { if !v.is_empty() { self.connection_string = Some(v.to_string());