Class InMemoryStores
java.lang.Object
com.iantapply.orchestra.adapter.memory.InMemoryStores
- All Implemented Interfaces:
DefinitionRepository, DistributedLock, ExecutionRepository
public final class InMemoryStores
extends Object
implements DefinitionRepository, ExecutionRepository, DistributedLock
Thread-safe in-memory implementation of the core stores and lease provider.
Intended for tests, development, and single-process installations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface DistributedLock
DistributedLock.Lease -
Constructor Summary
ConstructorsConstructorDescriptionCreates empty in-memory definition, execution, and lease stores. -
Method Summary
Modifier and TypeMethodDescriptionbooleancompareAndSet(long expectedVersion, EventExecution replacement) Replaces an execution only if its current version equals the expected version.voidcreate(EventExecution execution) Persists a new execution.Finds one definition.Finds one execution.findActive(int limit) Finds execution state eligible for startup recovery.findAll()Lists known definitions.Finds runnable work due on or before a time.voidsave(EventDefinition definition) Inserts or replaces a definition.tryAcquire(String key, Duration duration) Attempts to claim a key for a bounded duration without waiting.
-
Constructor Details
-
InMemoryStores
public InMemoryStores()Creates empty in-memory definition, execution, and lease stores.
-
-
Method Details
-
save
Description copied from interface:DefinitionRepositoryInserts or replaces a definition.- Specified by:
savein interfaceDefinitionRepository- Parameters:
definition- definition to insert or replace by identifier
-
find
Description copied from interface:DefinitionRepositoryFinds one definition.- Specified by:
findin interfaceDefinitionRepository- Parameters:
id- event identifier- Returns:
- matching definition, if present
-
findAll
Description copied from interface:DefinitionRepositoryLists known definitions.- Specified by:
findAllin interfaceDefinitionRepository- Returns:
- snapshot of all known definitions
-
create
Description copied from interface:ExecutionRepositoryPersists a new execution.- Specified by:
createin interfaceExecutionRepository- Parameters:
execution- new execution to persist
-
find
Description copied from interface:ExecutionRepositoryFinds one execution.- Specified by:
findin interfaceExecutionRepository- Parameters:
id- execution identifier- Returns:
- matching execution, if present
-
findDue
Description copied from interface:ExecutionRepositoryFinds runnable work due on or before a time.- Specified by:
findDuein interfaceExecutionRepository- Parameters:
now- inclusive due-time boundarylimit- maximum results- Returns:
- runnable executions ordered by due time when supported
-
findActive
Description copied from interface:ExecutionRepositoryFinds execution state eligible for startup recovery.- Specified by:
findActivein interfaceExecutionRepository- Parameters:
limit- maximum results- Returns:
- executions eligible for startup recovery
-
compareAndSet
Description copied from interface:ExecutionRepositoryReplaces an execution only if its current version equals the expected version.- Specified by:
compareAndSetin interfaceExecutionRepository- Parameters:
expectedVersion- version observed by the callerreplacement- complete replacement value- Returns:
- whether the replacement was persisted
-
tryAcquire
Description copied from interface:DistributedLockAttempts to claim a key for a bounded duration without waiting.- Specified by:
tryAcquirein interfaceDistributedLock- Parameters:
key- globally meaningful lock keyduration- lease lifetime- Returns:
- owned lease, or empty when another node owns the key
-