Table of Contents

Class WorkflowLock

Namespace
JD.AI.Workflows.Consensus
Assembly
JD.AI.Workflows.dll

Provides advisory workflow-level locking for exclusive edit access. Locks are held by a specific user and expire after a configurable duration to prevent stale locks from blocking other users indefinitely.

public sealed class WorkflowLock
Inheritance
WorkflowLock
Inherited Members

Constructors

WorkflowLock(TimeSpan?)

Creates a new workflow lock manager.

public WorkflowLock(TimeSpan? defaultExpiry = null)

Parameters

defaultExpiry TimeSpan?

Default lock duration before auto-expiry. Defaults to 30 minutes.

Properties

ActiveLockCount

Number of active (non-expired) locks.

public int ActiveLockCount { get; }

Property Value

int

Methods

Extend(string, string, TimeSpan)

Extends the expiry of an existing lock. Only the owner can extend.

public bool Extend(string workflowName, string owner, TimeSpan extension)

Parameters

workflowName string
owner string
extension TimeSpan

Returns

bool

ForceRelease(string)

Force-releases a lock regardless of owner (admin operation).

public bool ForceRelease(string workflowName)

Parameters

workflowName string

Returns

bool

GetLock(string)

Checks if a workflow is currently locked and by whom.

public LockEntry? GetLock(string workflowName)

Parameters

workflowName string

Returns

LockEntry

IsLockedBy(string, string)

Checks if the given user holds the lock (or the workflow is unlocked).

public bool IsLockedBy(string workflowName, string owner)

Parameters

workflowName string
owner string

Returns

bool

ListActiveLocks()

Lists all active (non-expired) locks.

public IReadOnlyList<LockEntry> ListActiveLocks()

Returns

IReadOnlyList<LockEntry>

Release(string, string)

Releases a lock. Only the lock owner can release it.

public bool Release(string workflowName, string owner)

Parameters

workflowName string
owner string

Returns

bool

TryAcquire(string, string, TimeSpan?)

Attempts to acquire an exclusive lock on a workflow. Returns true if the lock was acquired, false if held by another user.

public bool TryAcquire(string workflowName, string owner, TimeSpan? expiry = null)

Parameters

workflowName string
owner string
expiry TimeSpan?

Returns

bool