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

Function fromPubSub

packages/effect/src/internal/stream.ts:3130–3146  ·  view source on GitHub ↗
(pubsub, options)

Source from the content-addressed store, hash-verified

3128 readonly shutdown?: boolean | undefined
3129 }): Stream.Stream<A>
3130} = (pubsub, options): any => {
3131 const maxChunkSize = options?.maxChunkSize ?? DefaultChunkSize
3132
3133 if (options?.scoped) {
3134 const effect = Effect.map(
3135 PubSub.subscribe(pubsub),
3136 (queue) => fromQueue(queue, { maxChunkSize, shutdown: true })
3137 )
3138
3139 return options.shutdown ? Effect.map(effect, ensuring(PubSub.shutdown(pubsub))) : effect
3140 }
3141 const stream = flatMap(
3142 scoped(PubSub.subscribe(pubsub)),
3143 (queue) => fromQueue(queue, { maxChunkSize })
3144 )
3145 return options?.shutdown ? ensuring(stream, PubSub.shutdown(pubsub)) : stream
3146}
3147
3148/** @internal */
3149export const fromTPubSub = <A>(pubsub: TPubSub.TPubSub<A>): Stream.Stream<A> => {

Callers 1

stream.tsFile · 0.70

Calls 5

fromQueueFunction · 0.70
scopedFunction · 0.70
mapMethod · 0.65
subscribeMethod · 0.65
shutdownMethod · 0.45

Tested by

no test coverage detected