Skip to content

Commit 2fc60b8

Browse files
authored
Merge pull request #1663 from tursodatabase/lucio/resolve-solana-build
libsql: add `tls` feature
2 parents de45f4e + 2f1d71d commit 2fc60b8

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libsql-replication/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "MIT"
99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010

1111
[dependencies]
12-
tonic = { version = "0.11", features = ["tls"] }
12+
tonic = { version = "0.11", default-features = false, features = ["codegen", "prost"] }
1313
prost = "0.12"
1414
libsql-sys = { version = "0.7", path = "../libsql-sys", default-features = false, features = ["wal", "rusqlite", "api"] }
1515
libsql-wal = { path = "../libsql-wal/", optional = true }

libsql/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ libsql-hrana = { version = "0.2", path = "../libsql-hrana", optional = true }
1616
tokio = { version = "1.29.1", features = ["sync"], optional = true }
1717
tokio-util = { version = "0.7", features = ["io-util", "codec"], optional = true }
1818
parking_lot = { version = "0.12.1", optional = true }
19-
hyper = { workspace = true, features = ["client", "stream"], optional = true }
19+
hyper = { version = "0.14", features = ["client", "http1", "http2", "stream", "runtime"], optional = true }
2020
hyper-rustls = { version = "0.25", features = ["webpki-roots"], optional = true }
2121
base64 = { version = "0.21", optional = true }
2222
serde = { version = "1", features = ["derive"], optional = true }
@@ -31,7 +31,7 @@ anyhow = { version = "1.0.71", optional = true }
3131
bytes = { version = "1.4.0", features = ["serde"], optional = true }
3232
uuid = { version = "1.4.0", features = ["v4", "serde"], optional = true }
3333
tokio-stream = { version = "0.1.14", optional = true }
34-
tonic = { version = "0.11", features = ["tls", "tls-roots", "tls-webpki-roots"], optional = true}
34+
tonic = { version = "0.11", optional = true}
3535
tonic-web = { version = "0.11", optional = true }
3636
tower-http = { version = "0.4.4", features = ["trace", "set-header", "util"], optional = true }
3737
http = { version = "0.2", optional = true }
@@ -53,7 +53,7 @@ tempfile = { version = "3.7.0" }
5353
rand = "0.8.5"
5454

5555
[features]
56-
default = ["core", "replication", "remote"]
56+
default = ["core", "replication", "remote", "tls"]
5757
core = [
5858
"libsql-sys",
5959
"dep:bitflags",
@@ -88,7 +88,6 @@ replication = [
8888
"dep:tonic",
8989
"dep:tonic-web",
9090
"dep:tower-http",
91-
"dep:hyper-rustls",
9291
"dep:futures",
9392
"dep:libsql_replication",
9493
]
@@ -109,22 +108,26 @@ remote = [
109108
"hrana",
110109
"dep:tower",
111110
"dep:hyper",
111+
"dep:hyper",
112112
"dep:http",
113113
"dep:tokio",
114114
"dep:futures",
115115
"dep:bitflags",
116-
"dep:hyper-rustls",
117116
]
118117
wasm = ["hrana"]
119118
cloudflare = [
120119
"wasm",
121120
"dep:worker"
122121
]
123122
encryption = ["core", "libsql-sys/encryption", "dep:bytes"]
123+
tls = ["dep:hyper-rustls"]
124124

125125
[[bench]]
126126
name = "benchmark"
127127
harness = false
128128

129129
[package.metadata.docs.rs]
130130
rustdoc-args = ["--cfg", "docsrs"]
131+
132+
[package.metadata.cargo-udeps.ignore]
133+
normal = ["hyper-rustls"]

libsql/src/database.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,10 @@ impl Database {
619619
}
620620
}
621621

622-
#[cfg(any(feature = "replication", feature = "remote"))]
622+
#[cfg(any(
623+
all(feature = "tls", feature = "replication"),
624+
all(feature = "tls", feature = "remote")
625+
))]
623626
fn connector() -> Result<hyper_rustls::HttpsConnector<hyper::client::HttpConnector>> {
624627
let mut http = hyper::client::HttpConnector::new();
625628
http.enforce_http(false);
@@ -633,6 +636,14 @@ fn connector() -> Result<hyper_rustls::HttpsConnector<hyper::client::HttpConnect
633636
.wrap_connector(http))
634637
}
635638

639+
#[cfg(any(
640+
all(not(feature = "tls"), feature = "replication"),
641+
all(not(feature = "tls"), feature = "remote")
642+
))]
643+
fn connector() -> Result<hyper::client::HttpConnector> {
644+
panic!("The `tls` feature is disabled, you must provide your own http connector");
645+
}
646+
636647
impl std::fmt::Debug for Database {
637648
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
638649
f.debug_struct("Database").finish()

libsql/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,32 @@
8888
//! that will allow you to sync you remote database locally.
8989
//! - `remote` this feature flag only includes HTTP code that will allow you to run queries against
9090
//! a remote database.
91+
//! - `tls` this feature flag disables the builtin TLS connector and instead requires that you pass
92+
//! your own connector for any of the features that require HTTP.
9193
9294
#![cfg_attr(docsrs, feature(doc_cfg))]
95+
#![cfg_attr(
96+
all(
97+
any(
98+
not(feature = "remote"),
99+
not(feature = "replication"),
100+
not(feature = "core")
101+
),
102+
feature = "tls"
103+
),
104+
allow(unused_imports)
105+
)]
106+
#![cfg_attr(
107+
all(
108+
any(
109+
not(feature = "remote"),
110+
not(feature = "replication"),
111+
not(feature = "core")
112+
),
113+
feature = "tls"
114+
),
115+
allow(dead_code)
116+
)]
93117

94118
#[macro_use]
95119
mod macros;

0 commit comments

Comments
 (0)