MCPcopy Create free account
hub / github.com/Effect-TS/effect / rebuildLockConn

Function rebuildLockConn

packages/cluster/src/SqlRunnerStorage.ts:108–131  ·  view source on GitHub ↗
(generation: number)

Source from the content-addressed store, hash-verified

106 let lockConnRebuilding = false
107 let lockConnGeneration = 0
108 const rebuildLockConn = (generation: number) => {
109 if (
110 !lockConn ||
111 lockConnRebuilding ||
112 generation !== lockConnGeneration ||
113 lockConn.state.current._tag === "Closed"
114 ) return Effect.void
115 lockConnRebuilding = true
116 return withDeadline(lockConn.unsafeRebuild()).pipe(
117 Effect.exit,
118 Effect.tap((exit) =>
119 Effect.sync(() => {
120 if (Exit.isSuccess(exit) && lockConn.state.current._tag === "Acquired") {
121 lockConnGeneration++
122 }
123 })
124 ),
125 Effect.ensuring(Effect.sync(() => {
126 lockConnRebuilding = false
127 })),
128 Effect.forkIn(layerScope),
129 Effect.asVoid
130 )
131 }
132 const onErrorRebuildLockConn = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
133 Effect.suspend(() => {
134 const generation = lockConnGeneration

Callers 1

onErrorRebuildLockConnFunction · 0.85

Calls 3

unsafeRebuildMethod · 0.80
syncMethod · 0.80
pipeMethod · 0.65

Tested by

no test coverage detected