How sartrebrasil/idempotency-library works
A Java idempotency library that ensures an operation runs at most once per key and can replay its first result. The main workflow is a Spring-managed invocation intercepted by the starter, resolved to a key and scope, then handled by the core engine, which coordinates execution and persistence. The README documents HTTP, queue, job, and service use, replay and conflict behavior, and interchangeable in-memory, JDBC, Redis, and Mongo stores. No source excerpts were provided, so relationships below rely on README statements; implementation details not documented there are omitted.
Main entry points: IdempotencyEngine.java Idempotency engine · IdempotencyStore.java Store interface · IdempotencyInterceptor.java Invocation interceptor · IdempotencyAdvisor.java Annotation advisor
Components 17
Spring entry points
- Idempotency annotations
idempotency-core/src/main/java/com/example/idempotency/annotation/Idempotent.java - Annotation advisor
idempotency-spring-boot-starter/src/main/java/com/example/idempotency/spring/aspect/IdempotencyAdvisor.java - Invocation interceptor
idempotency-spring-boot-starter/src/main/java/com/example/idempotency/spring/aspect/IdempotencyInterceptor.java - Key resolution
idempotency-spring-boot-starter/src/main/java/com/example/idempotency/spring/key - Payload fingerprinting
idempotency-spring-boot-starter/src/main/java/com/example/idempotency/spring/aspect/PayloadFingerprinter.java
Idempotency core
- Idempotency engine
idempotency-core/src/main/java/com/example/idempotency/core/IdempotencyEngine.java - Operation execution
idempotency-core/src/main/java/com/example/idempotency/core/IdempotentOperation.java - Operation records
idempotency-core/src/main/java/com/example/idempotency/model/IdempotencyRecord.java - Result serialization
idempotency-core/src/main/java/com/example/idempotency/spi/ResultSerializer.java - Store interface
idempotency-core/src/main/java/com/example/idempotency/spi/IdempotencyStore.java
Persistence backends
- In-memory store
idempotency-core/src/main/java/com/example/idempotency/store/InMemoryIdempotencyStore.java - JDBC store
idempotency-store-jdbc/src/main/java/com/example/idempotency/spring/store/jdbc/JdbcIdempotencyStore.java - Redis store
idempotency-store-redis/src/main/java/com/example/idempotency/spring/store/redis/RedisIdempotencyStore.java - Mongo store
idempotency-store-mongo/src/main/java/com/example/idempotency/spring/store/mongo/MongoIdempotencyStore.java
HTTP integration
- HTTP exception mapping
idempotency-spring-boot-starter/src/main/java/com/example/idempotency/spring/web/IdempotencyExceptionHandler.java
Other components
- Application invocation
- HTTP or worker client
Connections 15
- Application invocation → Annotation advisor: invokes bean
README.md - Annotation advisor → Idempotency annotations: finds annotations
README.md - Annotation advisor → Invocation interceptor: intercepts invocation
- Invocation interceptor → Key resolution: resolves key
README.md - Invocation interceptor → Payload fingerprinting: checks payload
- Invocation interceptor → Idempotency engine: handles operation
- Idempotency engine → Operation execution: executes operation
- Idempotency engine → Store interface: coordinates records
- Idempotency engine → Result serialization: replays result
- Idempotency engine → Operation records: tracks state
- In-memory store → Store interface: implements
README.md - JDBC store → Store interface: implements
README.md - Redis store → Store interface: implements
README.md - Mongo store → Store interface: implements
README.md - HTTP or worker client → HTTP exception mapping: receives HTTP errors
README.md