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

Function pruneChunk

packages/effect/src/eventlog/SqlEventLogServerEncrypted.ts:1115–1129  ·  view source on GitHub ↗
(
      scope: string,
      now: number,
      lease: { readonly owner: string; readonly activeActivation: string },
      f: Effect.Effect<A, SqlError.SqlError>
    )

Source from the content-addressed store, hash-verified

1113 // Runs one chunk of a prune under the store row lock, if this sweeper
1114 // still holds the lease and the active activation hasn't changed.
1115 const pruneChunk = <A>(
1116 scope: string,
1117 now: number,
1118 lease: { readonly owner: string; readonly activeActivation: string },
1119 f: Effect.Effect<A, SqlError.SqlError>
1120 ) =>
1121 sql.withTransaction(Effect.gen(function*() {
1122 const store = yield* lockStore(scope)
1123 if (store.sweepLeaseOwner !== lease.owner || store.activeActivation !== lease.activeActivation) {
1124 return Option.none<A>()
1125 }
1126 const value = yield* f
1127 yield* sql`UPDATE ${storesSql} SET sweep_lease_until = ${now + sweepIntervalMillis} WHERE scope = ${scope}`
1128 return Option.some(value)
1129 }))
1130
1131 // Prunes what no activation still needs: the batch sets of generations
1132 // past their grace, and the originals at or below the lowest base still

Callers 1

makeStorageFunction · 0.85

Calls 2

someMethod · 0.80
lockStoreFunction · 0.70

Tested by

no test coverage detected