Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates for async-sessions-v4 (pending) #29

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
RUST_TEST_THREADS = "1"
13 changes: 3 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,23 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- name: check avoid-dev-deps
uses: actions-rs/cargo@v1
if: matrix.rust == 'nightly'
with:
command: check
args: --all -Z avoid-dev-deps

- name: pg tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features pg,async_std -- --test-threads=1
args: --all --features pg -- --test-threads=1

- name: sqlite tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features sqlite,async_std
args: --all --features sqlite

- name: mysql tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features mysql,async_std -- --test-threads=1
args: --all --features mysql -- --test-threads=1

check_fmt_and_docs:
name: Checking fmt, clippy, and docs
Expand Down
18 changes: 11 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ keywords = ["sessions", "sqlx", "sqlite", "postgres", "mysql"]
categories = ["web-programming::http-server", "web-programming", "database"]

[package.metadata.docs.rs]
features = ["pg", "sqlite", "mysql", "async_std"]
features = ["pg", "sqlite", "mysql"]

[features]
default = ["native-tls"]
default = []
sqlite = ["sqlx/sqlite"]
pg = ["sqlx/postgres", "sqlx/json"]
native-tls = ["sqlx/runtime-async-std-native-tls"]
rustls = ["sqlx/runtime-async-std-rustls"]
async_std = ["async-std"]
mysql = ["sqlx/mysql", "sqlx/json"]

[dependencies]
async-session = "3.0.0"
sqlx = { version = "0.6.2", features = ["chrono"] }
async-std = { version = "1.12.0", optional = true }
async-session = { git = "https://github.com/http-rs/async-session", branch = "overhaul-session-and-session-store", default-features = false }
sqlx = { version = "0.6.2", features = ["time"] }
log = "0.4.17"
serde_json = "1.0.93"
serde = "1.0.152"
thiserror = "1.0.38"
time = "0.3.18"
base64 = "0.21.0"

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }

[dev-dependencies.sqlx]
version = "0.6.2"
features = ["chrono", "runtime-async-std-native-tls"]
features = ["runtime-async-std-native-tls"]
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ async-sqlx-session = { version = "0.4.0", features = ["pg"] }
async-sqlx-session = { version = "0.4.0", features = ["mysql"] }
```

### Optional `async_std` feature

To use the `spawn_cleanup_task` function on the async-std runtime,
enable the `async_std` feature, which can be combined with any of the
above datastores.

```toml
async-sqlx-session = { version = "0.4.0", features = ["pg", "async_std"] }
```

## Cargo Features:

## Safety
This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in
100% Safe Rust.
Expand All @@ -58,7 +46,7 @@ Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
</sup>

<br/>

p

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

<sub>
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
Expand Down
17 changes: 17 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// Errors that can arise in the operation of the session stores
/// included in this crate
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
/// an error that comes from sqlx
#[error(transparent)]
SqlxError(#[from] sqlx::Error),

/// an error that comes from serde_json
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),

/// an error that comes from base64
#[error(transparent)]
Base64(#[from] base64::DecodeError),
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ pub use pg::PostgresSessionStore;
mod mysql;
#[cfg(feature = "mysql")]
pub use mysql::MySqlSessionStore;

mod error;
pub use error::Error;
Loading