Fun

A mostly functional discriminated union based API for use from F#

Nested types and modules

TypeDescription
Hashed
Lock

Type representing a Lock that has definitely been acquired. Locks are IDisposable; disposing the lock will ensure it is released.

LockResult

A type representing the possible results of attempting to acquire a lock.

Functions and values

Function or valueDescription
AwaitLock timeOut getLock
Signature: timeOut:TimeSpan -> getLock:(unit -> LockResult) -> LockResult

Poll the server waiting for a lock to become available. The method will block for no more than timeOut time.

DropLock lock
Signature: lock:Lock -> unit

Drop a lock. Equivilent to calling Lock.Dispose().

GetEnvironmentLock (...)
Signature: connString:string -> organisation:string -> environment:string -> maxDuration:TimeSpan -> lockIdentifier:string -> LockResult

Attempts to acquire an environment scoped lock from the specified server with the specified lockIdentifier. After maxDuration has elapsed the lock will become "stale" and will be automatically released to the next requester.

GetGlobalLock (...)
Signature: connString:string -> maxDuration:TimeSpan -> lockIdentifier:string -> LockResult

Attempts to acquire a global lock from the specified server with the specified lockIdentifier. After maxDuration has elapsed the lock will become "stale" and will be automatically released to the next requester.

GetOrganisationLock (...)
Signature: connString:string -> organisation:string -> maxDuration:TimeSpan -> lockIdentifier:string -> LockResult

Attempts to acquire an organisation scoped lock from the specified server with the specified lockIdentifier. After maxDuration has elapsed the lock will become "stale" and will be automatically released to the next requester.

OneOfLocks getLock lockIds
Signature: getLock:('?6161 -> LockResult) -> lockIds:seq<'?6161> -> LockResult
Type parameters: '?6161

Given a getLock function of lockId -> LockResult and a list of lockIds, this function will try and acquire any one of the specified lockIds working through them in a random order.

Fork me on GitHub