Designing an environment which consumes and re-exposes a stream #7322
-
I'd like to design an app pattern which can use the start of a stream to instantiate an environment, and then provide the rest of the stream to an app, which is modeled as a sink... I am trying to develop ZLayer-style composition patterns to allow creating complex environments based on stream activity. Possible uses include using a stream of timestamped input events to update the test clock, or simply tracking and composing stats for the incoming stream in the environment. Following is a snippet of one of my attempts at implementing this:
I am concerned about how I re-use the channel yielded by |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
So your If several Is this a correct assessment of the intent? If so, then re-using the "running" channels produced by the "startup" channels should be fine, as long as these "running" channels are designed to be run multiple times (one time with each subsequent (But take my opinion with a grain of salt: my experience with ZIO, and with high-level monadic/functional programming in general, is limited to just about one month.) |
Beta Was this translation helpful? Give feedback.
-
A channel is just a description, so it is fine to "run" a channel multiple times though to the extent running the channel has changed external state (e.g. taking an element from a queue) then that external state may be different the next time the channel is run and may cause running the channel a second time to produce a different result. |
Beta Was this translation helpful? Give feedback.
A channel is just a description, so it is fine to "run" a channel multiple times though to the extent running the channel has changed external state (e.g. taking an element from a queue) then that external state may be different the next time the channel is run and may cause running the channel a second time to produce a different result.