mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 14:23:13 +00:00
5431b9273d
Signed-off-by: jaehanbyun <awbrg789@naver.com> Signed-off-by: houseme <housemecn@gmail.com> Signed-off-by: Gunther Xing <jiengup@gmail.com> Signed-off-by: JaySon-Huang <tshent@qq.com> Co-authored-by: jaehanbyun <awbrg789@naver.com> Co-authored-by: Gunther Xing <jiengup@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: cxymds <Cxymds@qq.com> Co-authored-by: JaySon <tshent@qq.com> Co-authored-by: 安正超 <anzhengchao@gmail.com>
1.7 KiB
1.7 KiB
Targets Crate Instructions
Applies to crates/targets/.
rustfs-targets provides the notification target abstraction layer:
the Target<E> trait, built-in implementations (Webhook, Kafka, MQTT,
NATS, Pulsar, MySQL), persistent queue store, DSN/configuration
builders, and the ChannelTargetType registry that maps target types
to their runtime factories.
Library Design
- Treat crate code as reusable library code by default.
- Prefer
thiserrorfor library-facing error types. - Do not use
unwrap(),expect(), or panic-driven control flow outside tests.
Testing
- Keep unit tests close to the module they test.
- Keep integration tests under
crates/targets/tests/directory. - Add regression tests for bug fixes and behavior changes.
Async and Performance
- Keep async paths non-blocking.
- Move CPU-heavy operations out of async hot paths with
tokio::task::spawn_blockingwhen appropriate.
Integration Tests
MySQL Integration Tests
Integration tests in tests/mysql_integration.rs require a running MySQL 8.0+
or TiDB 8.5+ instance. They are #[ignore] by default so CI never runs them.
Start a test MySQL instance with Podman:
podman run -d --name rustfs-mysql-test \
-e MYSQL_ROOT_PASSWORD=testpass \
-e MYSQL_DATABASE=testdb \
-p 3306:3306 \
docker.io/library/mysql:8.0.36
Wait for MySQL to be ready (look for ready for connections in logs),
then run the integration tests:
RUSTFS_MYSQL_TEST_DSN="root:testpass@tcp(127.0.0.1:3306)/testdb" \
cargo test -p rustfs-targets -- --ignored
Clean up:
podman rm -f rustfs-mysql-test
Suggested Validation
cargo test -p rustfs-targets- Full gate before commit:
make pre-commit