Skip to content

Add database/sql resilience example.#64

Merged
cinar merged 4 commits into
cinar:mainfrom
Mak-1911:example/sql-resilience
Apr 25, 2026
Merged

Add database/sql resilience example.#64
cinar merged 4 commits into
cinar:mainfrom
Mak-1911:example/sql-resilience

Conversation

@Mak-1911
Copy link
Copy Markdown
Contributor

@Mak-1911 Mak-1911 commented Apr 13, 2026

Fixes #60

Description

Adds a new example in examples/sql/ demonstrating how to use Resile with Go's standard database/sql package.

The example wraps db.ExecContext with resile.Do, retries, and a circuit breaker. It uses a small mock database/sql/driver that fails the first two calls and succeeds on the third call, so the example can run without SQLite, external services, or new dependencies.

Checklist

Please ensure your contribution meets the project standards:

  • Code is formatted with go fmt.

  • All tests pass (go test -v ./...).

  • Architectural mandates (zero-dependency, type safety) are respected.

  • Tested with:

  go run ./examples/sql
  go test -v ./...

Additional Context

This example uses a mock SQL driver instead of SQLite to keep the example dependency-free while still exercising the standard database/sql API. Although I can implement the SQLite if the project demands.

@Mak-1911 Mak-1911 force-pushed the example/sql-resilience branch from 94f56eb to 77154e7 Compare April 13, 2026 17:49
@cinar cinar merged commit 908deb6 into cinar:main Apr 25, 2026
@cinar
Copy link
Copy Markdown
Owner

cinar commented Apr 25, 2026

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example: SQL Database Resilience with sql.DB

2 participants