Skip to content

Commit 3f29157

Browse files
committed
add support for postgres
1 parent 01ad41c commit 3f29157

File tree

5 files changed

+534
-10
lines changed

5 files changed

+534
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,37 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- master
7+
- main
88

99
env:
1010
RUSTFLAGS: -Dwarnings
11+
POSTGRES_DB: async_sqlx_session_tests
12+
PG_TEST_DB_URL: postgres://postgres:postgres@localhost/async_sqlx_session_tests
1113

1214
jobs:
1315
build_and_test:
1416
name: Build and test
15-
runs-on: ${{ matrix.os }}
17+
runs-on: ubuntu-latest
1618
strategy:
1719
matrix:
18-
os: [ubuntu-latest, windows-latest, macOS-latest]
1920
rust: [stable, nightly]
2021

22+
services:
23+
postgres:
24+
image: postgres
25+
env:
26+
POSTGRES_PASSWORD: postgres
27+
POSTGRES_DB: async_sqlx_session_tests
28+
options: >-
29+
--health-cmd pg_isready
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 5
33+
ports:
34+
- 5432:5432
35+
2136
steps:
22-
- uses: actions/checkout@master
37+
- uses: actions/checkout@main
2338

2439
- name: Install ${{ matrix.rust }}
2540
uses: actions-rs/toolchain@v1
@@ -44,13 +59,13 @@ jobs:
4459
uses: actions-rs/cargo@v1
4560
with:
4661
command: test
47-
args: --all
62+
args: --all --all-features -- --test-threads=1
4863

4964
check_fmt_and_docs:
5065
name: Checking fmt, clippy, and docs
5166
runs-on: ubuntu-latest
5267
steps:
53-
- uses: actions/checkout@master
68+
- uses: actions/checkout@main
5469

5570
- uses: actions-rs/toolchain@v1
5671
with:

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ categories = ["web-programming::http-server", "web-programming", "database"]
1313

1414

1515
[features]
16-
default = ["sqlite"]
16+
default = []
1717
sqlite = ["sqlx/sqlite"]
18+
pg = ["sqlx/postgres", "sqlx/json"]
1819

1920
[dependencies]
2021
async-session = "2.0.0"
21-
sqlx = { version = "0.3.5" }
22+
sqlx = { version = "0.3.5", features = ["chrono"] }
2223
async-std = "1.6.2"
2324

2425

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@
2020
mod sqlite;
2121
#[cfg(feature = "sqlite")]
2222
pub use sqlite::SqliteSessionStore;
23+
24+
#[cfg(feature = "pg")]
25+
mod pg;
26+
#[cfg(feature = "pg")]
27+
pub use pg::PostgresSessionStore;

0 commit comments

Comments
 (0)