tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
297
fork
atom
a tool for shared writing and social publishing
297
fork
atom
overview
issues
31
pulls
pipelines
remove locking mechanism
awarm.space
7 months ago
3e1fbd80
deac6341
-10
1 changed file
expand all
collapse all
unified
split
app
api
rpc
[command]
push.ts
-10
app/api/rpc/[command]/push.ts
reviewed
···
7
7
import type { Env } from "./route";
8
8
import { cachedServerMutationContext } from "src/replicache/cachedServerMutationContext";
9
9
import { drizzle } from "drizzle-orm/node-postgres";
10
10
-
import { Lock } from "src/utils/lock";
11
10
import { pool } from "supabase/pool";
12
11
13
12
const mutationV0Schema = z.object({
···
45
44
46
45
type PushRequestZ = z.infer<typeof pushRequestSchema>;
47
46
48
48
-
let locks = new Map<string, Lock>();
49
49
-
50
47
export const push = makeRoute({
51
48
route: "push",
52
49
input: z.object({
···
78
75
start = performance.now();
79
76
const db = drizzle(client);
80
77
let channel = supabase.channel(`rootEntity:${rootEntity}`);
81
81
-
let lock = locks.get(token.id);
82
82
-
if (!lock) {
83
83
-
lock = new Lock();
84
84
-
locks.set(token.id, lock);
85
85
-
}
86
86
-
let release = await lock.lock();
87
78
timeWaitingForLock = performance.now() - start;
88
79
start = performance.now();
89
80
try {
···
210
201
`);
211
202
212
203
client.release();
213
213
-
release();
214
204
await supabase.removeChannel(channel);
215
205
return { result: undefined } as const;
216
206
}