mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-18 20:15:20 +02:00
server for rowboatx
This commit is contained in:
parent
ae877e70ae
commit
9ad6331fbc
38 changed files with 2223 additions and 1088 deletions
20
apps/cli/src/runs/lock.ts
Normal file
20
apps/cli/src/runs/lock.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
export interface IRunsLock {
|
||||
lock(runId: string): Promise<boolean>;
|
||||
release(runId: string): Promise<void>;
|
||||
}
|
||||
|
||||
export class InMemoryRunsLock implements IRunsLock {
|
||||
private locks: Record<string, boolean> = {};
|
||||
|
||||
async lock(runId: string): Promise<boolean> {
|
||||
if (this.locks[runId]) {
|
||||
return false;
|
||||
}
|
||||
this.locks[runId] = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
async release(runId: string): Promise<void> {
|
||||
delete this.locks[runId];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue