MCPcopy Create free account
hub / github.com/effect-app/libs / effect

Function effect

packages/infra/test/rpc-stream-fullstack.test.ts:130–153  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

128
129const router = Router(StreamyRsc)({
130 *effect(match) {
131 return match({
132 StreamTicks: () => Stream.fromIterable([10, 20, 30]),
133 StreamCountTo: ({ to }: { readonly to: number }) =>
134 Effect
135 .gen(function*() {
136 return Stream.range(1, to)
137 })
138 .pipe(Stream.unwrap),
139 // emits 3 values 100ms apart so the test can prove element-by-element
140 // delivery rather than a single batched response
141 StreamRealtime: () =>
142 Stream.fromIterable([1, 2, 3]).pipe(
143 Stream.mapEffect((n) => Effect.sleep("100 millis").pipe(Effect.as(n)))
144 ),
145 StreamFailStream: () => Stream.fail(new StreamBoom({ reason: "from-stream" })),
146 StreamNoSuccess: () => Stream.empty,
147 // handlers below are unreachable when middleware-auth fails; bodies exist
148 // only so the resource type-checks
149 StreamRequiresAuth: () => Stream.fromIterable([1, 2, 3]),
150 CommandRequiresAuth: () => Effect.succeed(1),
151 QueryRequiresAuth: () => Effect.succeed(1)
152 })
153 }
154})
155
156const RpcRouterLayer = matchAll({ router })

Callers

nothing calls this directly

Calls 5

pipeMethod · 0.65
sleepMethod · 0.65
matchFunction · 0.50
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…