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

Function sendOutgoing

packages/cluster/src/Sharding.ts:819–855  ·  view source on GitHub ↗
(
    message: Message.Outgoing<any>,
    discard: boolean,
    retries?: number
  )

Source from the content-addressed store, hash-verified

817 })
818
819 function sendOutgoing(
820 message: Message.Outgoing<any>,
821 discard: boolean,
822 retries?: number
823 ): Effect.Effect<
824 void,
825 MailboxFull | AlreadyProcessingMessage | PersistenceError
826 > {
827 return Effect.catchIf(
828 Effect.suspend(() => {
829 const address = message.envelope.address
830 const isPersisted = Context.get(message.rpc.annotations, Persisted)
831 if (isPersisted && !storageEnabled) {
832 return Effect.die("Sharding.sendOutgoing: Persisted messages require MessageStorage")
833 }
834 const maybeRunner = MutableHashMap.get(shardAssignments, address.shardId)
835 const runnerIsLocal = Option.isSome(maybeRunner) && isLocalRunner(maybeRunner.value)
836 if (isPersisted) {
837 return runnerIsLocal
838 ? notifyLocal(message, discard)
839 : runnersService.notify({ address: maybeRunner, message, discard })
840 } else if (Option.isNone(maybeRunner)) {
841 return Effect.fail(new EntityNotAssignedToRunner({ address }))
842 }
843 return runnerIsLocal
844 ? sendLocal(message)
845 : runnersService.send({ address: maybeRunner.value, message })
846 }),
847 (error) => error._tag === "EntityNotAssignedToRunner" || error._tag === "RunnerUnavailable",
848 (error) => {
849 if (retries === 0) {
850 return Effect.die(error)
851 }
852 return Effect.delay(sendOutgoing(message, discard, retries && retries - 1), config.sendRetryInterval)
853 }
854 )
855 }
856
857 const reset: Sharding["Type"]["reset"] = (requestId) =>
858 Effect.matchCause(storage.clearReplies(requestId), {

Callers 2

onFromClientFunction · 0.85
Sharding.tsFile · 0.85

Calls 6

isLocalRunnerFunction · 0.85
notifyLocalFunction · 0.70
sendLocalFunction · 0.70
getMethod · 0.65
dieMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…