0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-07-14 11:25:17 +00:00

add libsql-hrana crate (#1260)

This commit is contained in:
Lucio Franco
2024-03-25 16:07:55 -07:00
committed by GitHub
parent bce6a9680d
commit 966757ab03
17 changed files with 44 additions and 30 deletions

17
Cargo.lock generated
View File

@ -2705,6 +2705,7 @@ dependencies = [
"http",
"hyper",
"hyper-rustls 0.25.0",
"libsql-hrana",
"libsql-sqlite3-parser",
"libsql-sys",
"libsql_replication",
@ -2753,6 +2754,17 @@ dependencies = [
"libsql-wasmtime-bindings",
]
[[package]]
name = "libsql-hrana"
version = "0.1.0"
dependencies = [
"base64",
"bytes",
"prost",
"serde",
"serde_json",
]
[[package]]
name = "libsql-rusqlite"
version = "0.30.0"
@ -2821,6 +2833,7 @@ dependencies = [
"jsonwebtoken",
"libsql",
"libsql-client",
"libsql-hrana",
"libsql-rusqlite",
"libsql-sqlite3-parser",
"libsql-sys",
@ -2891,14 +2904,10 @@ dependencies = [
name = "libsql-sys"
version = "0.4.0"
dependencies = [
"base64",
"bytes",
"libsql-ffi",
"libsql-rusqlite",
"once_cell",
"prost",
"serde",
"serde_json",
"tracing",
"zerocopy",
]

View File

@ -10,11 +10,12 @@ members = [
"bottomless-cli",
"libsql-replication",
"libsql-ffi",
"libsql-hrana",
"vendored/rusqlite",
"vendored/sqlite3-parser",
"xtask",
"xtask", "libsql-hrana",
]
exclude = [

15
libsql-hrana/Cargo.toml Normal file
View File

@ -0,0 +1,15 @@
[package]
name = "libsql-hrana"
version = "0.1.0"
edition = "2021"
license = "MIT"
[dependencies]
serde = { version = "1.0", features = ["derive", "rc"] }
prost = { version = "0.12" }
base64 = { version = "0.21" }
bytes = "1"
[dev-dependencies]
serde_json = "1.0"

View File

@ -60,7 +60,8 @@ serde_json = { version = "1.0.91", features = ["preserve_order"] }
md-5 = "0.10"
sha2 = "0.10"
sha256 = "1.1.3"
libsql-sys = { path = "../libsql-sys", features = ["wal", "hrana"], default-features = false }
libsql-sys = { path = "../libsql-sys", features = ["wal"], default-features = false }
libsql-hrana = { path = "../libsql-hrana" }
sqlite3-parser = { package = "libsql-sqlite3-parser", path = "../vendored/sqlite3-parser", version = "0.11.0", default-features = false, features = [ "YYNOERRORRECOVERY" ] }
tempfile = "3.7.0"
thiserror = "1.0.38"

View File

@ -1,7 +1,7 @@
use anyhow::{Context, Result};
use bytes::Bytes;
use futures::stream::Stream;
use libsql_sys::hrana::proto;
use libsql_hrana::proto;
use parking_lot::Mutex;
use serde::{de::DeserializeOwned, Serialize};
use std::pin::Pin;

View File

@ -4,7 +4,7 @@ use bytesize::ByteSize;
use super::super::{batch, stmt, ProtocolError, Version};
use super::stream;
use crate::connection::{Connection, RequestContext};
use libsql_sys::hrana::proto;
use libsql_hrana::proto;
const MAX_SQL_COUNT: usize = 50;
const MAX_STORED_SQL_SIZE: ByteSize = ByteSize::kb(5);

View File

@ -6,7 +6,7 @@ pub mod http;
mod result_builder;
pub mod stmt;
pub mod ws;
pub use libsql_sys::hrana::proto;
pub use libsql_hrana::proto;
#[derive(Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub enum Version {

View File

@ -17,12 +17,6 @@ once_cell = "1.18.0"
rusqlite = { workspace = true, features = ["trace"], optional = true }
tracing = "0.1.37"
zerocopy = { version = "0.7.28", features = ["derive"] }
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
prost = { version = "0.12", optional = true }
base64 = { version = "0.21", optional = true }
[dev-dependencies]
serde_json = "1.0"
[features]
default = ["api"]
@ -32,9 +26,4 @@ rusqlite = ["dep:rusqlite"]
wasmtime-bindings = ["libsql-ffi/wasmtime-bindings"]
unix-excl-vfs = []
encryption = ["libsql-ffi/multiple-ciphers"]
serde = ["dep:serde"]
hrana = [
"serde",
"dep:prost",
"dep:base64"
]

View File

@ -63,8 +63,6 @@ pub mod ffi {
#[cfg(feature = "api")]
pub mod connection;
pub mod error;
#[cfg(feature = "hrana")]
pub mod hrana;
#[cfg(feature = "api")]
pub mod statement;
#[cfg(feature = "api")]

View File

@ -11,7 +11,8 @@ tracing = { version = "0.1.37", default-features = false }
thiserror = "1.0.40"
futures = { version = "0.3.28", optional = true }
libsql-sys = { version = "0.4", path = "../libsql-sys", features = ["hrana"], optional = true }
libsql-sys = { version = "0.4", path = "../libsql-sys", optional = true }
libsql-hrana = { version = "0.1", path = "../libsql-hrana", optional = true }
tokio = { version = "1.29.1", features = ["sync"], optional = true }
tokio-util = { version = "0.7", features = ["io-util", "codec"], optional = true }
parking_lot = { version = "0.12.1", optional = true }
@ -101,7 +102,7 @@ hrana = [
"dep:tokio",
"dep:tokio-util",
"dep:bytes",
"libsql-sys",
"dep:libsql-hrana",
]
serde = ["dep:serde"]
remote = [

View File

@ -16,8 +16,8 @@ use crate::parser::StmtKind;
use crate::{params::Params, ValueType};
use bytes::Bytes;
use futures::{Stream, StreamExt};
pub use libsql_sys::hrana::proto;
use libsql_sys::hrana::proto::{Batch, BatchResult, Col, Stmt};
pub use libsql_hrana::proto;
use libsql_hrana::proto::{Batch, BatchResult, Col, Stmt};
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;

View File

@ -3,7 +3,7 @@ use crate::hrana::proto::{Batch, BatchResult, DescribeResult, Stmt, StmtResult};
use crate::hrana::{CursorResponseError, HranaError, HttpSend, Result};
use bytes::{Bytes, BytesMut};
use futures::Stream;
use libsql_sys::hrana::proto::{
use libsql_hrana::proto::{
BatchStreamReq, CloseSqlStreamReq, CloseStreamReq, CloseStreamResp, DescribeStreamReq,
GetAutocommitStreamReq, PipelineReqBody, PipelineRespBody, SequenceStreamReq,
StoreSqlStreamReq, StreamRequest, StreamResponse, StreamResult,

View File

@ -3,7 +3,7 @@ use crate::hrana::stream::HranaStream;
use crate::hrana::{HttpSend, Result};
use crate::parser::StmtKind;
use crate::TransactionBehavior;
use libsql_sys::hrana::proto::{ExecuteStreamReq, StreamRequest};
use libsql_hrana::proto::{ExecuteStreamReq, StreamRequest};
#[derive(Debug, Clone)]
pub(crate) struct HttpTransaction<T>

View File

@ -36,7 +36,7 @@ use crate::{
params::IntoParams,
TransactionBehavior,
};
use libsql_sys::hrana::proto::{Batch, Stmt};
use libsql_hrana::proto::{Batch, Stmt};
pub use crate::wasm::rows::Rows;