Skip to content

Commit edb38bf

Browse files
authored
Merge pull request #23 from jbr/mk/mysql-support
Mk/mysql support
2 parents 7c9ff9b + 0e86024 commit edb38bf

File tree

5 files changed

+565
-16
lines changed

5 files changed

+565
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
RUSTFLAGS: -Dwarnings
1111
POSTGRES_DB: async_sqlx_session_tests
1212
PG_TEST_DB_URL: postgres://postgres:postgres@localhost/async_sqlx_session_tests
13+
MYSQL_DB: async_sqlx_session_tests
14+
MYSQL_TEST_DB_URL: mysql://root:root@localhost/async_sqlx_session_tests
1315

1416
jobs:
1517
build_and_test:
@@ -33,6 +35,19 @@ jobs:
3335
ports:
3436
- 5432:5432
3537

38+
mysql:
39+
image: mysql
40+
env:
41+
MYSQL_ROOT_PASSWORD: root
42+
MYSQL_DATABASE: async_sqlx_session_tests
43+
ports:
44+
- 3306:3306
45+
options: >-
46+
--health-cmd "mysqladmin ping"
47+
--health-interval 10s
48+
--health-timeout 5s
49+
--health-retries 3
50+
3651
steps:
3752
- uses: actions/checkout@main
3853

@@ -42,12 +57,6 @@ jobs:
4257
toolchain: ${{ matrix.rust }}
4358
override: true
4459

45-
- name: check
46-
uses: actions-rs/cargo@v1
47-
with:
48-
command: check
49-
args: --all --bins --examples
50-
5160
- name: check avoid-dev-deps
5261
uses: actions-rs/cargo@v1
5362
if: matrix.rust == 'nightly'
@@ -67,6 +76,12 @@ jobs:
6776
command: test
6877
args: --all --features sqlite,async_std
6978

79+
- name: mysql tests
80+
uses: actions-rs/cargo@v1
81+
with:
82+
command: test
83+
args: --all --features mysql,async_std -- --test-threads=1
84+
7085
check_fmt_and_docs:
7186
name: Checking fmt, clippy, and docs
7287
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ readme = "README.md"
88
repository = "https://github.com/jbr/async-sqlx-session"
99
documentation = "https://docs.rs/async-sqlx-session"
1010
license = "MIT OR Apache-2.0"
11-
keywords = ["sessions", "tide", "async-session", "sqlx", "sqlite"]
11+
keywords = [
12+
"sessions",
13+
"tide",
14+
"async-session",
15+
"sqlx",
16+
"sqlite",
17+
"postgres",
18+
"mysql"
19+
]
1220
categories = ["web-programming::http-server", "web-programming", "database"]
1321

1422
[package.metadata.docs.rs]
15-
features = ["pg", "sqlite", "async_std"]
23+
features = ["pg", "sqlite", "mysql", "async_std"]
1624

1725
[features]
1826
default = ["native-tls"]
@@ -21,6 +29,7 @@ pg = ["sqlx/postgres", "sqlx/json"]
2129
native-tls = ["sqlx/runtime-async-std-native-tls"]
2230
rustls = ["sqlx/runtime-async-std-rustls"]
2331
async_std = ["async-std"]
32+
mysql = ["sqlx/mysql", "sqlx/json"]
2433

2534
[dependencies]
2635
async-session = "3.0.0"
@@ -29,3 +38,7 @@ async-std = { version = "1.9.0", optional = true }
2938

3039
[dev-dependencies]
3140
async-std = { version = "1.9.0", features = ["attributes"] }
41+
42+
[dev-dependencies.sqlx]
43+
version = "0.5.5"
44+
features = ["chrono", "runtime-async-std-native-tls"]

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ async-sqlx-session = { version = "0.3.0", features = ["sqlite"] }
2828
async-sqlx-session = { version = "0.3.0", features = ["pg"] }
2929
```
3030

31+
### mysql:
32+
33+
```toml
34+
async-sqlx-session = { version = "0.3.0", features = ["mysql"] }
35+
```
36+
3137
### Optional `async_std` feature
3238

33-
To use the `spawn_cleanup_task` function on async-std, enable the
34-
`async_std` feature.
39+
To use the `spawn_cleanup_task` function on the async-std runtime,
40+
enable the `async_std` feature, which can be combined with any of the
41+
above datastores.
3542

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

src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*!
22
# async-sqlx-session
33
4-
This crate currently provides two session stores:
5-
[`PostgresSessionStore`] and [`SqliteSessionStore`], each of which
6-
is enabled by a feature flag.
4+
This crate currently provides several session stores, each of which is
5+
enabled by a feature flag.
76
8-
To use [`SqliteSessionStore`], enable the `sqlite` feature on this
7+
* To use [`SqliteSessionStore`], enable the `sqlite` feature on this
98
crate.
10-
11-
To use [`PostgresSessionStore`], enable the `pg` feature on this
9+
* To use [`PostgresSessionStore`], enable the `pg` feature on this
10+
crate.
11+
* To use [`MysqlSessionStore`], enable the `mysql` feature on this
1212
crate.
1313
1414
To use the `spawn_cleanup_task` function for either store on
@@ -49,3 +49,8 @@ pub use sqlite::SqliteSessionStore;
4949
mod pg;
5050
#[cfg(feature = "pg")]
5151
pub use pg::PostgresSessionStore;
52+
53+
#[cfg(feature = "mysql")]
54+
mod mysql;
55+
#[cfg(feature = "mysql")]
56+
pub use mysql::MySqlSessionStore;

0 commit comments

Comments
 (0)