File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,24 @@ which consolidates multiple data streams into a single unified channel.
146
146
Fan-out is done with the ** Split2** function, that divides a single input stream into two distinct output channels.
147
147
This division is based on a discriminator function, allowing parallel processing paths based on data characteristics.
148
148
149
+ When splitting a stream, you create a scenario with a single producer and two consumers.
150
+ It's important to note that if one consumer is blocked, it can lock the entire pipeline,
151
+ affecting the producer and the other consumer.
152
+ One way to mitigate this is to use a buffer on the output channels, but be aware that this will increase memory usage.
153
+
154
+ ``` go
155
+ out1 , out2 := rill.Split2 (input, 10 , func (item string ) bool {
156
+ // Some splitting logic...
157
+ })
158
+
159
+ // out1 is slow. Buffer up to 100 items that go to it
160
+ out1 = rill.Buffer (out1, 100 )
161
+
162
+ // Now, work with out1 and out2 as usual
163
+ ```
164
+
165
+
166
+
149
167
150
168
151
169
## Error handling
You can’t perform that action at this time.
0 commit comments