FileSystem.Lock
A module for creating lockfiles. A lockfile can only be held by a single process at a time, and can thus be used to avoid having two or more programs working on a set of files simultaniously.
This implementation is based on proper-lockfile.
TEA
type alias Model =
{ locks : Set String, retryOptions : Maybe RetryOptions }
type alias RetryOptions =
{ attempts : Int, millisecondsBetween : Int }
How often, and at what interval, to retry aquiring a lock.
init :
Maybe RetryOptions -> Model
type Msg
type UpdateResult
= Working (Cmd Msg)
| UnexpectedError ({ path : Path, error : Error })
| LockAquired ({ path : Path, model : Model, command : Cmd Msg })
| LockReleased ({ path : Path, model : Model, command : Cmd Msg })
| AlreadyLocked Path
The different possible results returned by update.
update :
Permission -> Msg -> Model -> UpdateResult
Operations
aquire :
Path -> Cmd Msg
Attempt to aquire a lock with the given Path
. Once aquired, other
processes will fail to aquire the same lock until you release it.
release :
Path -> Cmd Msg
Release the lock provided by the specific Path
. This will allow other
processes to aquire the same lock.
getLocks :
Model -> Array Path
Get an Array
of the currently held locks.