You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`Out()` method can be used only once on each pipeline. Any subsequent `Pipe()` call will cause panic.
128
-
Though, when you need to stream values somewhere from the middle of the pipeline - just send them to your own channel.
129
-
* do not try to `Push` to the pipeline before the first `Pipe` is defined - it will panic
130
-
* as at the time of writing Go does not have generics, you have to assert the type for incoming messages in pipes explicitly,
131
-
which means the type of the message can be checked in runtime only.
132
-
133
105
### Performance
134
106
135
-
As already was mentioned, parapipe makes use of `interface{}` and also executes callbacks in a separate goroutine per each message.
136
-
This can have a great performance impact because of heap allocation and creation of goroutines.
137
-
For instance if you try to stream a slice of integers, each of them will be converted to an interface type and
138
-
will likely be allocated in heap.
139
-
Moreover, if an execution time of each step is relatively small,
140
-
than a goroutine creation may decrease overall performance considerably.
141
-
142
-
If the performance is the priority, its recommended that you pack such messages in batches (i.e. slices)
143
-
and stream that batches instead.
144
-
Obviously that's your responsibility to process batch in the order you like inside step (pipe) callback.
145
-
146
-
Basically the overall recommendations for choosing batch size are in general the same as if you have to create a slice of interfaces
147
-
or create a new goroutine.
107
+
Parapipe makes use of generics and channels.
108
+
Overall it should be performant enough for most of the cases.
109
+
It has zero heap allocations in hot code, thus generates little load for garbage collector.
110
+
However, it uses channels under the hood and is bottlenecked mostly by the channel operations which are several
111
+
writes and reads per each message.
148
112
149
113
Examples
150
114
--------
@@ -159,7 +123,7 @@ See the [working example of using parapipe in AMQP client](http://github.com/naz
159
123
160
124
With parapipe you can:
161
125
162
-
* respond a JSON-feed as stream, retrieve, enrich and marshal each object concurrently, in maintained order and return them to the client
126
+
*in your API respond a long JSON-feed as stream, retrieve, enrich and marshal each object concurrently, in maintained order and return them to the client
163
127
* fetch and merge entries from different sources as one stream
0 commit comments