Class InMemoryConversationLock
java.lang.Object
at.aimon.session.web.spi.inmemory.InMemoryConversationLock
- All Implemented Interfaces:
ConversationLock
Single-process
ConversationLock backed by a ConcurrentMap.
Suitable for SINGLE_NODE deployments and unit/integration tests. Lease expiry is checked lazily at every
tryAcquire / extend entry — no background scheduler. Fencing tokens are issued from a single
monotonic counter so any stale handle held by a former holder is trivially detectable.
-
Nested Class Summary
Nested classes/interfaces inherited from interface at.aimon.session.web.spi.ConversationLock
ConversationLock.LockHandle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanextend(ConversationLock.LockHandle handle, Duration lease) Extends the lease of an already-held lock.voidrelease(ConversationLock.LockHandle handle) Releases the lock.tryAcquire(at.aimon.core.agent.conversation.ConversationId id, String holderId, Duration lease) Attempts to acquire the lock foridon behalf ofholderId.
-
Constructor Details
-
InMemoryConversationLock
public InMemoryConversationLock() -
InMemoryConversationLock
-
-
Method Details
-
tryAcquire
public Optional<ConversationLock.LockHandle> tryAcquire(at.aimon.core.agent.conversation.ConversationId id, String holderId, Duration lease) Description copied from interface:ConversationLockAttempts to acquire the lock foridon behalf ofholderId.- Specified by:
tryAcquirein interfaceConversationLock- Parameters:
id- the conversation to lock (must not be null)holderId- the requesting holder identity (must not be null)lease- requested lease duration (must not be null)- Returns:
- a
ConversationLock.LockHandleon success, empty if another holder owns it
-
extend
Description copied from interface:ConversationLockExtends the lease of an already-held lock.- Specified by:
extendin interfaceConversationLock- Parameters:
handle- the lock handle returned from a priorConversationLock.tryAcquire(at.aimon.core.agent.conversation.ConversationId, java.lang.String, java.time.Duration)(must not be null)lease- new lease duration (must not be null)- Returns:
truewhen the lease was extended,falsewhen the fencing token no longer matches (lease already expired or released)
-
release
Description copied from interface:ConversationLockReleases the lock. Token mismatches are silently ignored — the manager treatsreleaseas best-effort and the lease will eventually expire.- Specified by:
releasein interfaceConversationLock- Parameters:
handle- the lock handle (must not be null)
-