Anarchy.Toolkit.Infrastructure.Persistence.Db.Mysql
Part of Anarchy I/O Toolkit, a .NET developer platform · Pillar: Infrastructure · Layer: Infrastructure · Package catalog
MySQL adapter for the toolkit’s relational persistence layer, using MySqlConnector.
dotnet add package Anarchy.Toolkit.Infrastructure.Persistence.Db.Mysql
MysqlDbDialect, connection pools, unit of work, retry policy and repository bases adapt the shared relational layer to MySQL.- Register
AppTelemetryin DI and configureModuleMysqlwith connection and resilience options factories;AddMysqlHealthReports()adds reader and writer checks. - The unkeyed storage policy uses the writer; use the
readerkey for read-only operations. Port 3306 is the default. - Named session time zones require populated MySQL time-zone tables. Retry the whole unit of work rather than individual commands inside a transaction.
When to use it
Use this adapter for a MySQL-backed application that needs the toolkit’s relational policies, unit of work and repository bases. The consuming application supplies its schema, migrations and MySQL-specific queries.
How to use it
- Register
AppTelemetryand useModuleMysqlwith factories forMysqlConnectionOptionsandMysqlResilienceOptions. Obtain hosts and credentials from the environment or a secret provider rather than committing them. - Configure reader/writer hosts, database name, command timeout and optional session time zone. The port defaults to 3306 and
MaximumPoolSizedefaults to 100; tune pool size for the database and number of application instances. - Implement repositories with the MySQL bases and select the keyed
readerpolicy for read-only work. The unkeyed policy uses the writer. AddAddMysqlHealthReports()if the host should check both endpoints. - Validate the integration against a dedicated MySQL test database using
Testing.Db.Mysql. If a transaction fails, retry the whole unit of work rather than individual statements inside it.
See the MySQL usage notes and Testing.Db.Mysql.
Releases
See the release notes for the complete release history.