def lock.present

mylsm-lsm-store@0.6.0.1 · src/transfer/MigrateIo.bend:652

import mylsm-lsm-store@0.6.0.1/src/transfer/MigrateIo.bend as MigrateIo
import Base
import mylsm-lsm-store@0.6.0.1/src/DbLock.bend as DbLock
import mylsm-lsm-store@0.6.0.1/src/DurableError.bend as DurableError

652# Requires an existing stable lock file and acquires it before reading the WAL.
653def lock.present(
654  +path: String,
655  result: Result<&1, &1, U32 & String, Bool>
656) -> IO(Result<&1, &1, Error, Nat>):
657  match result:
658    case Fail{error}: host.without_lock(error)
659    case Done{False{}}:
660      IO.pure(Result<&1, &1, Error, Nat>, Fail{HostError{2, "database LOCK file is missing"}})
661    case Done{True{}}:
662      do IO<Result<&1, &1, Error, Nat>>:
663        acquired : Result<&1, &1, DurableError.Error, DbLock.Lock> <-
664          DbLock.acquire(path, "migrate-verify")
665        locked(path, acquired)

Uses (15)

Used by (1)