Skip to content

Commit b229dbf

Browse files
Merge pull request #93 from theseus-rs/add-zonky-binary-support
feat: add support for installing binaries from the zonky project
2 parents 2c33fc4 + e16c522 commit b229dbf

File tree

35 files changed

+1183
-77
lines changed

35 files changed

+1183
-77
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ http = "1.1.0"
3333
human_bytes = { version = "0.4.3", default-features = false }
3434
lazy_static = "1.5.0"
3535
num-format = "0.4.4"
36+
quick-xml = "0.35.0"
3637
rand = "0.8.5"
3738
regex = "1.10.5"
3839
reqwest = { version = "0.12.5", default-features = false }
@@ -52,6 +53,8 @@ thiserror = "1.0.61"
5253
tokio = "1.38.0"
5354
tracing = "0.1.40"
5455
url = "2.5.2"
56+
xz2 = "0.1.7"
57+
zip = "2.1.3"
5558

5659
[workspace.metadata.release]
5760
shared-version = true

deny.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ allow = [
1818
"Apache-2.0",
1919
"BSD-2-Clause",
2020
"BSD-3-Clause",
21+
"BSL-1.0",
2122
"ISC",
2223
"MIT",
2324
"OpenSSL",
2425
"PostgreSQL",
25-
"Unicode-3.0",
2626
"Unicode-DFS-2016",
2727
]
2828

examples/archive_async/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#![forbid(unsafe_code)]
22
#![deny(clippy::pedantic)]
33

4-
use postgresql_archive::{
5-
extract, get_archive, Result, VersionReq, THESEUS_POSTGRESQL_BINARIES_URL,
6-
};
4+
use postgresql_archive::configuration::theseus;
5+
use postgresql_archive::{extract, get_archive, Result, VersionReq};
76

87
#[tokio::main]
98
async fn main() -> Result<()> {
10-
let url = THESEUS_POSTGRESQL_BINARIES_URL;
9+
let url = theseus::URL;
1110
let version_req = VersionReq::STAR;
1211
let (archive_version, archive) = get_archive(url, &version_req).await?;
1312
let out_dir = tempfile::tempdir()?.into_path();

examples/archive_sync/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
#![deny(clippy::pedantic)]
33

44
use postgresql_archive::blocking::{extract, get_archive};
5-
use postgresql_archive::{Result, VersionReq, THESEUS_POSTGRESQL_BINARIES_URL};
5+
use postgresql_archive::configuration::theseus;
6+
use postgresql_archive::{Result, VersionReq};
67

78
fn main() -> Result<()> {
8-
let url = THESEUS_POSTGRESQL_BINARIES_URL;
9+
let url = theseus::URL;
910
let version_req = VersionReq::STAR;
1011
let (archive_version, archive) = get_archive(url, &version_req)?;
1112
let out_dir = tempfile::tempdir()?.into_path();

postgresql_archive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ http = { workspace = true }
1919
human_bytes = { workspace = true, default-features = false }
2020
lazy_static = { workspace = true }
2121
num-format = { workspace = true }
22+
quick-xml = { workspace = true, features = ["serialize"] }
2223
regex = { workspace = true }
2324
reqwest = { workspace = true, default-features = false, features = ["json"] }
2425
reqwest-middleware = { workspace = true }
@@ -36,6 +37,8 @@ thiserror = { workspace = true }
3637
tokio = { workspace = true, features = ["full"], optional = true }
3738
tracing = { workspace = true, features = ["log"] }
3839
url = { workspace = true }
40+
xz2 = { workspace = true }
41+
zip = { workspace = true }
3942

4043
[dev-dependencies]
4144
criterion = { workspace = true }

postgresql_archive/benches/archive.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use criterion::{criterion_group, criterion_main, Criterion};
22
use postgresql_archive::blocking::{extract, get_archive};
3-
use postgresql_archive::{Result, VersionReq, THESEUS_POSTGRESQL_BINARIES_URL};
3+
use postgresql_archive::configuration::theseus;
4+
use postgresql_archive::{Result, VersionReq};
45
use std::fs::{create_dir_all, remove_dir_all};
56
use std::time::Duration;
67

@@ -10,7 +11,7 @@ fn benchmarks(criterion: &mut Criterion) {
1011

1112
fn bench_extract(criterion: &mut Criterion) -> Result<()> {
1213
let version_req = VersionReq::STAR;
13-
let (_archive_version, archive) = get_archive(THESEUS_POSTGRESQL_BINARIES_URL, &version_req)?;
14+
let (_archive_version, archive) = get_archive(theseus::URL, &version_req)?;
1415

1516
criterion.bench_function("extract", |bencher| {
1617
bencher.iter(|| {
@@ -24,7 +25,7 @@ fn bench_extract(criterion: &mut Criterion) -> Result<()> {
2425
fn extract_archive(archive: &Vec<u8>) -> Result<()> {
2526
let out_dir = tempfile::tempdir()?.path().to_path_buf();
2627
create_dir_all(&out_dir)?;
27-
extract(THESEUS_POSTGRESQL_BINARIES_URL, archive, &out_dir)?;
28+
extract(theseus::URL, archive, &out_dir)?;
2829
remove_dir_all(&out_dir)?;
2930
Ok(())
3031
}

postgresql_archive/src/archive.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ use semver::{Version, VersionReq};
77
use std::path::Path;
88
use tracing::instrument;
99

10-
pub const THESEUS_POSTGRESQL_BINARIES_URL: &str =
11-
"https://github.com/theseus-rs/postgresql-binaries";
12-
1310
/// Gets the version for the specified [version requirement](VersionReq). If a version for the
1411
/// [version requirement](VersionReq) is not found, then an error is returned.
1512
///
@@ -52,19 +49,20 @@ pub async fn extract(url: &str, bytes: &Vec<u8>, out_dir: &Path) -> Result<()> {
5249
#[cfg(test)]
5350
mod tests {
5451
use super::*;
52+
use crate::configuration::theseus::URL;
5553

5654
#[tokio::test]
5755
async fn test_get_version() -> Result<()> {
5856
let version_req = VersionReq::parse("=16.3.0")?;
59-
let version = get_version(THESEUS_POSTGRESQL_BINARIES_URL, &version_req).await?;
57+
let version = get_version(URL, &version_req).await?;
6058
assert_eq!(Version::new(16, 3, 0), version);
6159
Ok(())
6260
}
6361

6462
#[tokio::test]
6563
async fn test_get_archive() -> Result<()> {
6664
let version_req = VersionReq::parse("=16.3.0")?;
67-
let (version, bytes) = get_archive(THESEUS_POSTGRESQL_BINARIES_URL, &version_req).await?;
65+
let (version, bytes) = get_archive(URL, &version_req).await?;
6866
assert_eq!(Version::new(16, 3, 0), version);
6967
assert!(!bytes.is_empty());
7068
Ok(())
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod theseus;
2+
pub mod zonky;

0 commit comments

Comments
 (0)