ruststream-sqlx 0.7.0

SQL databases for the RustStream messaging framework through sqlx: a transactional outbox over any RustStream broker and task queues in Postgres, MySQL/MariaDB and SQLite tables.
Documentation
[package]
name = "ruststream-sqlx"
description = "SQL databases for the RustStream messaging framework through sqlx: a transactional outbox over any RustStream broker and task queues in Postgres, MySQL/MariaDB and SQLite tables."
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
readme = "../../README.md"
# The offline query data and the sqlx settings serve the doctests of checked mode in this
# repository; a service builds the crate without them.
exclude = [".sqlx", "sqlx.toml"]
keywords = ["sqlx", "outbox", "queue", "messaging", "ruststream"]
categories = ["asynchronous", "database"]

[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true

[features]
default = []
# The task queue in the service's own tables: `#[derive(Inbox)]` describes a queue table and
# `SqlxBroker` serves it.
inbox = [
    "dep:ruststream-sqlx-macros",
    "dep:ruststream",
    "dep:sqlx",
    "dep:sqlx-core",
    # The rows a statement changed, through `AnyQueryResult`, which every sqlx driver converts its
    # result into.
    "sqlx/any",
    "dep:futures",
    "dep:tokio",
    "dep:tokio-util",
    "dep:tracing",
    "dep:thiserror",
    "dep:sync_wrapper",
    "dep:stackfuture",
    "dep:foldhash",
]
# The transactional outbox over any RustStream broker: `#[derive(Outbox)]` describes the outbox
# table, `outbox!` registers it, and two middlewares and a startup republish track what a service
# publishes until a consumer has processed it.
outbox = [
    "dep:ruststream-sqlx-macros",
    "dep:ruststream",
    "dep:sqlx",
    "dep:tokio",
    "dep:tracing",
    "dep:thiserror",
]
# The built-in Postgres dialect, the sqlx driver, and the derive's Postgres insert.
postgres = [
    "ruststream-sqlx-dialect/postgres",
    "ruststream-sqlx-macros?/postgres",
    "sqlx?/postgres",
]
# The built-in MySQL and MariaDB dialect, the sqlx driver, and the derive's MySQL insert.
mysql = [
    "ruststream-sqlx-dialect/mysql",
    "ruststream-sqlx-macros?/mysql",
    "sqlx?/mysql",
]
# The built-in SQLite dialect, the sqlx driver, and the derive's SQLite insert.
sqlite = [
    "ruststream-sqlx-dialect/sqlite",
    "ruststream-sqlx-macros?/sqlite",
    "sqlx?/sqlite",
]
# An `AnyPool`: the broker picks the built-in dialect of the database the pool reaches when it
# connects, among those whose features are on.
any = ["inbox", "sqlx/any"]
# `chrono::DateTime<Utc>` as a time column.
chrono = ["inbox", "dep:chrono", "sqlx/chrono"]
# `time::OffsetDateTime` as a time column.
time = ["inbox", "dep:time", "sqlx/time"]
# A JSON object of strings as the `headers` column of an inbox or an outbox table.
json = ["sqlx?/json"]
# Test builds: the inbox broker's in-process mode for `TestApp`, registered with the harness, and
# the outbox switched off unless `RUSTSTREAM_SQLX_OUTBOX=on`.
testing = ["dep:ruststream", "ruststream/testing"]
# What the inbox adds to the AsyncAPI document: the table a subscription reads.
asyncapi = ["inbox", "ruststream/asyncapi", "dep:serde"]

[dependencies]
ruststream-sqlx-dialect.workspace = true
ruststream-sqlx-macros = { workspace = true, optional = true }
ruststream = { workspace = true, optional = true }
sqlx = { workspace = true, optional = true }
# FIXME(sqlx-mysql 0.9.0): only the crate's own transactions use it, a workaround for a rollback
# that hangs `Pool::close()` after a cancelled prepare; it goes once sqlx fixes that (see the
# workspace manifest).
sqlx-core = { workspace = true, optional = true }
futures = { workspace = true, optional = true }
tokio = { workspace = true, optional = true, features = ["rt", "time", "sync", "macros"] }
tokio-util = { workspace = true, optional = true }
tracing = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }
sync_wrapper = { workspace = true, optional = true }
chrono = { workspace = true, optional = true }
time = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
stackfuture = { workspace = true, optional = true }
foldhash = { workspace = true, optional = true }

[dev-dependencies]
ruststream = { workspace = true, features = ["macros", "json", "memory", "testing", "conformance"] }
# `macros`: the overview's checked structs read their statements' offline data from `.sqlx`, a
# link to the Postgres fixture's; `sqlx-toml`: `sqlx.toml` reads time columns as `chrono` types.
sqlx = { workspace = true, features = ["postgres", "mysql", "sqlite", "chrono", "json", "derive", "macros", "sqlx-toml"] }
# 1.52 brings tokio-macros 2.7, whose `#[tokio::test]` no longer trips `unused_qualifications` on
# the first statement of a test; the library's own floor stays the workspace's.
tokio = { version = "1.52", default-features = false, features = ["rt-multi-thread", "macros", "time", "sync", "net", "io-util"] }
chrono.workspace = true
futures = { workspace = true, features = ["executor"] }
serde.workspace = true
serde_json.workspace = true
trybuild.workspace = true
dhat.workspace = true

# The two services the documentation site shows, one per component.
[[example]]
name = "inbox"
required-features = ["inbox", "postgres"]

[[example]]
name = "outbox"
required-features = ["outbox", "postgres"]