MCPcopy Index your code
hub / github.com/Effect-TS/effect / sendLocal

Function sendLocal

packages/cluster/src/Sharding.ts:729–756  ·  view source on GitHub ↗
(message: M)

Source from the content-addressed store, hash-verified

727 // --- Sending messages ---
728
729 const sendLocal = <M extends Message.Outgoing<any> | Message.Incoming<any>>(message: M) =>
730 Effect.suspend(function loop(): Effect.Effect<
731 void,
732 | EntityNotAssignedToRunner
733 | MailboxFull
734 | AlreadyProcessingMessage
735 | (M extends Message.Incoming<any> ? never : PersistenceError)
736 > {
737 const address = message.envelope.address
738 if (!isEntityOnLocalShards(address)) {
739 return Effect.fail(new EntityNotAssignedToRunner({ address }))
740 }
741 const state = entityManagers.get(address.entityType)
742 if (!state) {
743 return Effect.flatMap(waitForEntityManager(address.entityType), loop)
744 } else if (state.status === "closed" || (state.status === "closing" && message._tag === "IncomingRequest")) {
745 // if we are shutting down, we don't accept new requests
746 return Effect.fail(new EntityNotAssignedToRunner({ address }))
747 }
748
749 return message._tag === "IncomingRequest" || message._tag === "IncomingEnvelope" ?
750 state.manager.send(message) :
751 runnersService.sendLocal({
752 message,
753 send: state.manager.sendLocal,
754 simulateRemoteSerialization: config.simulateRemoteSerialization
755 }) as any
756 })
757
758 type PendingNotification = {
759 resume: (_: Effect.Effect<void, EntityNotAssignedToRunner>) => void

Callers 1

sendOutgoingFunction · 0.70

Calls 4

isEntityOnLocalShardsFunction · 0.85
waitForEntityManagerFunction · 0.85
failMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…