-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
15,420 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.0.6] - 2024-04-20 | ||
|
||
- Bump **stac** version to v0.6 | ||
- Bump **pgstac** version to v0.8.5 | ||
|
||
## [0.0.5] - 2023-09-25 | ||
|
||
- Bump **stac-api** version to v0.3.0 | ||
|
||
## [0.0.4] - 2023-07-07 | ||
|
||
- Bump **stac** version to v0.5 | ||
- Bump **pgstac** version to v0.6.13 ([#2](https://github.com/stac-utils/pgstac-rs/pull/2)) | ||
|
||
## [0.0.3] - 2023-01-08 | ||
|
||
### Changed | ||
|
||
- `Client` now takes a reference to a generic client, instead of owning it | ||
|
||
### Removed | ||
|
||
- `Client::into_inner` | ||
|
||
## [0.0.2] - 2023-01-08 | ||
|
||
### Changed | ||
|
||
- Make `Error`, `Result`, and `Context` publicly visible | ||
|
||
## [0.0.1] - 2023-01-07 | ||
|
||
Initial release | ||
|
||
[unreleased]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.6...HEAD | ||
[0.0.6]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.5...v0.0.6 | ||
[0.0.5]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.4...v0.0.5 | ||
[0.0.4]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.3...v0.0.4 | ||
[0.0.3]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.2...v0.0.3 | ||
[0.0.2]: https://github.com/stac-utils/pgstac-rs/compare/v0.0.1...v0.0.2 | ||
[0.0.1]: https://github.com/stac-utils/pgstac-rs/tree/v0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "pgstac" | ||
version = "0.0.6" | ||
authors = ["Pete Gadomski <[email protected]>"] | ||
edition = "2021" | ||
description = "Rust interface for pgstac" | ||
homepage = "https://github.com/stac-utils/pgstac-rs" | ||
repository = "https://github.com/stac-utils/pgstac-rs" | ||
license = "MIT OR Apache-2.0" | ||
keywords = ["geospatial", "stac", "metadata", "raster", "database"] | ||
categories = ["database", "data-structures", "science"] | ||
|
||
[dependencies] | ||
geojson = "0.24" | ||
serde = "1" | ||
serde_json = "1" | ||
stac = { version = "0.6", path = "../stac" } | ||
stac-api = { version = "0.3", path = "../stac-api" } | ||
thiserror = "1" | ||
tokio-postgres = { version = "0.7", features = ["with-serde_json-1"] } | ||
|
||
[dev-dependencies] | ||
pgstac-test = { path = "pgstac-test" } | ||
tokio = { version = "1.23", features = ["rt-multi-thread", "macros"] } | ||
tokio-test = "0.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# pgstac-rs | ||
|
||
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/stac-utils/pgstac-rs/ci.yml?branch=main&style=for-the-badge)](https://github.com/stac-utils/pgstac-rs/actions/workflows/ci.yml) | ||
[![docs.rs](https://img.shields.io/docsrs/pgstac?style=for-the-badge)](https://docs.rs/pgstac/latest/pgstac/) | ||
[![Crates.io](https://img.shields.io/crates/v/pgstac?style=for-the-badge)](https://crates.io/crates/pgstac) | ||
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=for-the-badge)](./CODE_OF_CONDUCT) | ||
|
||
Rust interface for [pgstac](https://github.com/stac-utils/pgstac). | ||
|
||
## Usage | ||
|
||
In your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
pgstac = "0.0.6" | ||
``` | ||
|
||
See the [documentation](https://docs.rs/pgstac) for more. | ||
|
||
## Testing | ||
|
||
**pgstac-rs** needs a blank **pgstac** database for testing. | ||
The repo comes with a [docker-compose](./docker-compose.yml) to run one. | ||
To test: | ||
|
||
```shell | ||
docker-compose up -d | ||
cargo test | ||
docker-compose down | ||
``` | ||
|
||
Each test is run in its own transaction, which is rolled back after the test. | ||
|
||
### Customizing the test database connection | ||
|
||
By default, the tests will connect to the database at `postgresql://username:password@localhost:5432/postgis`. | ||
If you need to customize the connection information for whatever reason, set your `PGSTAC_RS_TEST_DB` environment variable: | ||
|
||
```shell | ||
PGSTAC_RS_TEST_DB=postgresql://otherusername:otherpassword@otherhost:7822/otherdbname cargo test | ||
``` | ||
|
||
## Other info | ||
|
||
This crate is part of the [stac-rs](https://github.com/stac-utils/stac-rs) monorepo, see its README for contributing and license information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
services: | ||
database: | ||
container_name: pgstac-rs | ||
image: ghcr.io/stac-utils/pgstac:v0.8.5 | ||
environment: | ||
- POSTGRES_USER=username | ||
- POSTGRES_PASSWORD=password | ||
- POSTGRES_DB=postgis | ||
- PGUSER=username | ||
- PGPASSWORD=password | ||
- PGDATABASE=postgis | ||
ports: | ||
- "5432:5432" | ||
command: postgres -N 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "pgstac-test" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
test = false | ||
doctest = false | ||
|
||
[dependencies] | ||
quote = "1" | ||
syn = { version = "2", features = ["full", "extra-traits"] } | ||
tokio-postgres = { version = "0.7" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use proc_macro::TokenStream; | ||
use quote::quote; | ||
use syn::ItemFn; | ||
|
||
#[proc_macro_attribute] | ||
pub fn pgstac_test(_args: TokenStream, input: TokenStream) -> TokenStream { | ||
let ast = syn::parse(input).unwrap(); | ||
impl_pgstac_test(ast) | ||
} | ||
|
||
fn impl_pgstac_test(ast: ItemFn) -> TokenStream { | ||
let ident = &ast.sig.ident; | ||
let gen = quote! { | ||
#[tokio::test] | ||
async fn #ident() { | ||
let _mutex = MUTEX.lock().unwrap(); | ||
let config = std::env::var("PGSTAC_RS_TEST_DB") | ||
.unwrap_or("postgresql://username:password@localhost:5432/postgis".to_string()); | ||
let (mut client, connection) = tokio_postgres::connect(&config, tokio_postgres::NoTls).await.unwrap(); | ||
tokio::spawn(async move { | ||
connection.await.unwrap() | ||
}); | ||
let transaction = client.transaction().await.unwrap(); | ||
let client = Client::new(&transaction); | ||
#ast | ||
#ident(&client).await; | ||
transaction.rollback().await.unwrap(); | ||
} | ||
}; | ||
gen.into() | ||
} |
Oops, something went wrong.