mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-03 03:25:40 +08:00
don't restart entities on shutdown (#624)
This commit is contained in:
@@ -273,11 +273,14 @@ export const make = Effect.fnUntraced(function*<
|
||||
)
|
||||
|
||||
function onDefect(cause: Cause.Cause<never>): Effect.Effect<void> {
|
||||
if (!activeServers.has(address.entityId)) {
|
||||
return endLatch.open
|
||||
}
|
||||
const effect = writeRef.rebuildUnsafe()
|
||||
defectRequestIds = Array.from(activeRequests.keys())
|
||||
return Effect.logError("Defect in entity, restarting", cause).pipe(
|
||||
Effect.andThen(Effect.ignore(retryDriver(void 0))),
|
||||
Effect.andThen(effect),
|
||||
Effect.flatMap((_) => activeServers.has(address.entityId) ? effect : endLatch.open),
|
||||
Effect.annotateLogs({
|
||||
module: "EntityManager",
|
||||
address,
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ResourceRef<A, E = never> {
|
||||
return Effect.interrupt
|
||||
}
|
||||
const prevScope = s.scope
|
||||
const scope = Effect.runSync(Scope.make())
|
||||
const scope = Scope.makeUnsafe()
|
||||
this.latch.closeUnsafe()
|
||||
MutableRef.set(this.state, { _tag: "Acquiring", scope })
|
||||
return Effect.withFiber((fiber) => {
|
||||
@@ -77,6 +77,9 @@ export class ResourceRef<A, E = never> {
|
||||
}).pipe(
|
||||
Effect.andThen(this.acquire(scope)),
|
||||
Effect.flatMap((value) => {
|
||||
if (this.state.current._tag === "Closed") {
|
||||
return Effect.interrupt
|
||||
}
|
||||
MutableRef.set(this.state, { _tag: "Acquired", scope, value })
|
||||
return this.latch.open
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user