Skip to content

feat: IIdempotencyStore – PostgreSQL ADO.NET implementation #228

@samtrion

Description

@samtrion

User Story

As a developer using PostgreSQL with Pulse, I want an IIdempotencyStore backed by PostgreSQL ADO.NET, so that I can enforce idempotency in applications that use NetEvolve.Pulse.PostgreSql without adopting EF Core.


Background

Mirrors the SQL Server implementation (#227) but uses Npgsql and PostgreSQL-specific DDL (TIMESTAMP WITH TIME ZONE, ON CONFLICT DO NOTHING).


Requirements

  • Add src/NetEvolve.Pulse.PostgreSql/Scripts/IdempotencyKey.sql:
    • Table "{schema}"."IdempotencyKey" with idempotency_key VARCHAR(500) NOT NULL PRIMARY KEY and created_at TIMESTAMP WITH TIME ZONE NOT NULL.
    • PostgreSQL functions: fn_exists_idempotency_key, fn_insert_idempotency_key, fn_delete_expired_idempotency_keys.
  • Create PostgreSqlIdempotencyKeyOptions: Schema, TableName, TimeToLive?.
  • Implement PostgreSqlIdempotencyStore : IIdempotencyStore via Npgsql ADO.NET:
    • ExistsAsync: calls fn_exists_idempotency_key.
    • StoreAsync: calls fn_insert_idempotency_key; ignores PostgreSQL error 23505 (unique violation).
  • Expose AddPostgreSqlIdempotencyStore extension overloads in PostgreSqlIdempotencyMediatorBuilderExtensions.

Acceptance Criteria

  • DDL script creates the table and all three functions using PostgreSQL syntax.
  • ExistsAsync returns true for an existing key, false for a new one, and ignores expired keys when TimeToLive is set.
  • StoreAsync does not throw on error 23505.
  • Both AddPostgreSqlIdempotencyStore overloads register IIdempotencyStore as Scoped.
  • Unit tests cover: key exists, key absent, TTL expiry, duplicate insert, options wiring.
  • Integration tests cover

Dependencies

Metadata

Metadata

Labels

type:featureIndicates a new feature or enhancement to be added.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions