(address: string, shardId: string, now: number)
| 918 | ) |
| 919 | |
| 920 | const tryAcquire = (address: string, shardId: string, now: number) => |
| 921 | readLock(shardId).pipe( |
| 922 | Effect.flatMap((lock) => |
| 923 | Option.match(lock, { |
| 924 | onNone: () => createLock(address, shardId, now), |
| 925 | onSome: (doc) => { |
| 926 | if (doc.address !== address && now - doc.acquiredAt <= expires) { |
| 927 | return Effect.succeed(false) |
| 928 | } |
| 929 | doc.address = address |
| 930 | doc.acquiredAt = now |
| 931 | return writeLock(doc) |
| 932 | } |
| 933 | }) |
| 934 | ), |
| 935 | Effect.map((acquired) => acquired ? Option.some(shardId) : Option.none()) |
| 936 | ) |
| 937 | |
| 938 | return RunnerStorage.makeEncoded({ |
| 939 | getRunners: Effect.sync(() => Date.now()).pipe( |
no test coverage detected
searching dependent graphs…