Class StorageStatisticRepository
java.lang.Object
com.cotani.statistics.storage.StorageStatisticRepository
- All Implemented Interfaces:
StatisticRepository
SQL-backed repository for atomic, idempotent, non-negative player statistics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindAsync(UUID playerId, StatisticId statisticId) Loads one statistic; absence means the player has not recorded it yet.incrementAsync(UUID playerId, StatisticId statisticId, long amount, Instant updatedAt) Atomically increments a statistic and returns the exact previous and current values.incrementIdempotentlyAsync(UUID playerId, StatisticId statisticId, long amount, Instant updatedAt, StatisticOperationId operationId) Atomically increments a statistic with a durable idempotency key.static List<com.cotani.storage.migration.Migration> topAsync(StatisticId statisticId, int limit) Returns a deterministic, value-descending ranking limited by the caller.
-
Constructor Details
-
StorageStatisticRepository
public StorageStatisticRepository(com.cotani.storage.api.CotaniStorage storage)
-
-
Method Details
-
findAsync
Description copied from interface:StatisticRepositoryLoads one statistic; absence means the player has not recorded it yet.- Specified by:
findAsyncin interfaceStatisticRepository
-
incrementAsync
public CompletionStage<StatisticUpdate> incrementAsync(UUID playerId, StatisticId statisticId, long amount, Instant updatedAt) Description copied from interface:StatisticRepositoryAtomically increments a statistic and returns the exact previous and current values.- Specified by:
incrementAsyncin interfaceStatisticRepository
-
incrementIdempotentlyAsync
public CompletionStage<StatisticUpdate> incrementIdempotentlyAsync(UUID playerId, StatisticId statisticId, long amount, Instant updatedAt, StatisticOperationId operationId) Description copied from interface:StatisticRepositoryAtomically increments a statistic with a durable idempotency key.Implementations must persist the idempotency result with the increment and return
StatisticUpdate.newlyApplied()asfalsewhen the same logical operation is replayed. Repositories without idempotency support must reject this operation.- Specified by:
incrementIdempotentlyAsyncin interfaceStatisticRepository
-
topAsync
Description copied from interface:StatisticRepositoryReturns a deterministic, value-descending ranking limited by the caller.- Specified by:
topAsyncin interfaceStatisticRepository
-
migrations
-