Skip to content

feat: SQLite ADO.NET implementation of IIdempotencyStore#382

Merged
samtrion merged 2 commits intomainfrom
copilot/add-sqlite-idempotency-store
Apr 15, 2026
Merged

feat: SQLite ADO.NET implementation of IIdempotencyStore#382
samtrion merged 2 commits intomainfrom
copilot/add-sqlite-idempotency-store

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Adds a SQLite-backed IIdempotencyStore using Microsoft.Data.Sqlite, enabling idempotency enforcement in embedded, edge, and test scenarios without a full database server.

Core Implementation

  • SQLiteIdempotencyKeyRepository — implements IIdempotencyKeyRepository with:
    • SELECT 1 … LIMIT 1 for existence checks, with optional CreatedAt >= @validFrom TTL filtering
    • INSERT OR IGNORE for duplicate-safe inserts
    • DateTimeOffset stored as ISO-8601 text ("O" format) for correct lexicographic ordering
    • WAL mode applied per-connection when EnableWalMode = true
  • Scripts/002_CreateIdempotencyKeyTable.sqlCREATE TABLE IF NOT EXISTS with TEXT NOT NULL PRIMARY KEY on IdempotencyKey and an index on CreatedAt for TTL queries
  • SQLiteIdempotencyMediatorBuilderExtensions — three AddSQLiteIdempotencyStore overloads (string, factory, action) registering IIdempotencyKeyRepository as Scoped; mirrors SqlServerIdempotencyMediatorBuilderExtensions

Options

Added EnableWalMode to the shared IdempotencyKeyOptions (consistent with how OutboxOptions exposes the same property).

Integration Tests

  • SQLiteAdoNetIdempotencyInitializer — creates the idempotency table inline via SqliteConnection and wires up AddSQLiteIdempotencyStore
  • SQLiteAdoNetIdempotencyTests — inherits all scenarios from IdempotencyTestsBase: key exists/absent, TTL within range, TTL expired, multiple keys, duplicate insert (same scope), cross-scope duplicate insert

Usage

services.AddPulse(config => config
    .AddSQLiteIdempotencyStore("Data Source=idempotency.db", opts =>
    {
        opts.TableName = "IdempotencyKey";
        opts.TimeToLive = TimeSpan.FromHours(24);
        opts.EnableWalMode = true;
    })
);

Copilot AI linked an issue Apr 14, 2026 that may be closed by this pull request
5 tasks
Copilot AI changed the title [WIP] Add SQLite idempotency store for Pulse implementation feat: SQLite ADO.NET implementation of IIdempotencyStore Apr 14, 2026
Copilot AI requested a review from samtrion April 14, 2026 21:53
@samtrion samtrion force-pushed the copilot/add-sqlite-idempotency-store branch from 2b5a243 to 617375f Compare April 15, 2026 06:33
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 97.56098% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.33%. Comparing base (91e59c9) to head (104c34d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...Lite/Idempotency/SQLiteIdempotencyKeyRepository.cs 98.11% 1 Missing ⚠️
...Lite/SQLiteIdempotencyMediatorBuilderExtensions.cs 96.29% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #382      +/-   ##
==========================================
+ Coverage   91.04%   91.33%   +0.29%     
==========================================
  Files         119      122       +3     
  Lines        4130     4212      +82     
  Branches      375      381       +6     
==========================================
+ Hits         3760     3847      +87     
+ Misses        264      258       -6     
- Partials      106      107       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtrion
Copy link
Copy Markdown
Contributor

@copilot Add Integration tests

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 15, 2026

@copilot Add Integration tests

Added in commit 104c34d:

  • SQLiteAdoNetIdempotencyInitializer — creates the idempotency table inline (same pattern as SQLiteAdoNetOutboxInitializer) and wires up AddSQLiteIdempotencyStore
  • SQLiteAdoNetIdempotencyTests — inherits all 8 tests from IdempotencyTestsBase: key exists/absent, TTL within range, TTL expired, multiple keys, duplicate insert (same scope), cross-scope duplicate insert, and the full options wiring

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1.0.17.172.in-addr.arpa
    • Triggering command: /usr/sbin/mysqld mysqld -container-port 1433 -use-listen-fd conf�� 9c28130c6673ef42487c1462e82110c2719 k/pulse/pulse/.e/run/containerd/io.containerd.runtime.v2.task/moby/a5fde79629ebb345b136b496b8922.process.env += [ "SSL_CERT_DIR=/etc/ssl/certs", "SS--log etc/ssl/certs/ca-certificates.crt", "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certifi 8227e5535ab04c3785c0181061e577b2144/log.json (dns block)
    • Triggering command: /usr/sbin/mysqld mysqld 0/0 --dport 32779 -j DNAT --to-destination 172.17.0.13:1433 5119575ee0dcd981051a1606c1a29e2a462/log.json -i docker0 k/pulse/pulse/sr/var/run/docker/runtime-runc/moby conf�� e21e1c3f9920f0d6/run/containerd/io.containerd.runtime.v2.task/moby/641f4d66b751ca12aad9d8f833524grep } ker/docker-init ns/template.edit/usr/sbin/iptables all("session") a--wait 1c8/log.json ker/docker-init (dns block)
    • Triggering command: /usr/sbin/mysqld mysqld -container-port 1433 -use-listen-fd 2f0b.pid 169abf30c1c24d39 ntime.v2.task/moby/d29d866c2512b2b99726d3ca01e337470aa57d65faae441d3576fbfb04d07179 /snap/bin/git 8227e5535ab04c3785c0181061e577b2144/log.json 0aa57d65faae441d/usr/bin/runc (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@samtrion samtrion marked this pull request as ready for review April 15, 2026 09:50
@samtrion samtrion requested a review from a team as a code owner April 15, 2026 09:50
@samtrion samtrion merged commit 3904a7b into main Apr 15, 2026
10 of 11 checks passed
@samtrion samtrion deleted the copilot/add-sqlite-idempotency-store branch April 15, 2026 11:26
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.

feat: IIdempotencyStore – SQLite ADO.NET implementation

2 participants