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

Function onFromServer

packages/cluster/src/internal/entityManager.ts:202–305  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

200 concurrency: options.concurrency ?? 1,
201 disableFatalDefects: options.disableFatalDefects,
202 onFromServer(response): Effect.Effect<void> {
203 switch (response._tag) {
204 case "Exit": {
205 const request = activeRequests.get(response.requestId)
206 if (!request) return Effect.void
207
208 request.sentReply = true
209
210 if (
211 isShuttingDown &&
212 Exit.isInterrupted(response.exit) &&
213 defectRequestIds.has(response.requestId)
214 ) {
215 return Effect.void
216 }
217
218 // For durable messages, ignore interrupts during shutdown.
219 // They will be retried when the entity is restarted.
220 // Also, if the request is uninterruptible, we ignore the
221 // interrupt.
222 if (
223 storageEnabled &&
224 Context.get(request.rpc.annotations, Persisted) &&
225 Exit.isFailure(response.exit) &&
226 Exit.isInterrupted(response.exit) &&
227 (isShuttingDown || request.terminating || Uninterruptible.forServer(request.rpc.annotations))
228 ) {
229 if (!isShuttingDown && !request.terminating) {
230 return server.write(0, {
231 ...request.message.envelope,
232 id: RequestId(request.message.envelope.requestId),
233 tag: request.message.envelope.tag as any,
234 payload: new Request({
235 ...request.message.envelope,
236 lastSentChunk: request.lastSentChunk
237 } as any) as any
238 }).pipe(
239 Effect.forkIn(scope)
240 )
241 }
242 activeRequests.delete(response.requestId)
243 return options.storage.unregisterReplyHandler(request.message.envelope.requestId)
244 }
245 request.sentExit = true
246 return retryRespond(
247 4,
248 Effect.suspend(() =>
249 request.message.respond(
250 new Reply.WithExit({
251 requestId: Snowflake.Snowflake(response.requestId),
252 id: snowflakeGen.unsafeNext(),
253 exit: response.exit
254 })
255 )
256 )
257 ).pipe(
258 Effect.flatMap(() => {
259 processedRequestIds.add(request.message.envelope.requestId)

Callers

nothing calls this directly

Calls 11

RequestIdFunction · 0.90
retryRespondFunction · 0.85
onDefectFunction · 0.85
isInterruptedMethod · 0.80
forServerMethod · 0.80
getMethod · 0.65
pipeMethod · 0.65
writeMethod · 0.65
addMethod · 0.65
dieMethod · 0.65

Tested by

no test coverage detected