fix(cli): elect one service process
This commit is contained in:
@@ -134,6 +134,29 @@ describe("util.effect-flock", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.live(
|
||||
"supports an acquisition timeout",
|
||||
Effect.gen(function* () {
|
||||
const flock = yield* EffectFlock.Service
|
||||
const tmp = yield* Effect.promise(() => fs.mkdtemp(path.join(os.tmpdir(), "eflock-test-")))
|
||||
const dir = path.join(tmp, "locks")
|
||||
const key = "eflock:timeout"
|
||||
|
||||
yield* Effect.scoped(
|
||||
Effect.gen(function* () {
|
||||
yield* flock.acquire(key, dir)
|
||||
const started = performance.now()
|
||||
const error = yield* Effect.scoped(
|
||||
flock.acquire(key, dir, { staleMs: 10_000, timeoutMs: 300 }),
|
||||
).pipe(Effect.flip)
|
||||
expect(error._tag).toBe("LockTimeoutError")
|
||||
expect(performance.now() - started).toBeLessThan(1_000)
|
||||
}),
|
||||
)
|
||||
yield* Effect.promise(() => fs.rm(tmp, { recursive: true, force: true }))
|
||||
}),
|
||||
)
|
||||
|
||||
it.live(
|
||||
"withLock data-first",
|
||||
Effect.gen(function* () {
|
||||
|
||||
Reference in New Issue
Block a user