[pkg/queue] Add StartConsumersWithFactory function#2714
[pkg/queue] Add StartConsumersWithFactory function#2714yurishkuro merged 5 commits intojaegertracing:masterfrom
StartConsumersWithFactory function#2714Conversation
This provides a way to keep state for each consumer of a bounded queue, which is useful in certain performance-critical setups. Fixes jaegertracing#2685. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Codecov Report
@@ Coverage Diff @@
## master #2714 +/- ##
==========================================
+ Coverage 95.73% 95.74% +0.01%
==========================================
Files 216 216
Lines 9588 9593 +5
==========================================
+ Hits 9179 9185 +6
Misses 336 336
+ Partials 73 72 -1
Continue to review full report at Codecov.
|
The common part with the assertions was moved to a new `checkQueue` function that is used by `TestBoundedQueue` and `TestBoundedQueueWithFactory`. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Refactor unit tests using a `helper` function that takes a function to start consumers. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
|
@yurishkuro Thanks for the comments, I think I addressed everything, hopefully this looks better :) |
| // We want to test the overflow behavior, so we block the consumer | ||
| // by holding a startLock before submitting items to the queue. | ||
| func TestBoundedQueue(t *testing.T) { | ||
| func helper(t *testing.T, startConsumers func(q *BoundedQueue, consumerFn func(item interface{}))) { |
There was a problem hiding this comment.
hehe, I didn't mean the name helper literally, was just too lazy to type what you had, but that's fine.
There was a problem hiding this comment.
hahaha, I couldn't come up with anything better so I left it like you said 😄
| assert.False(t, q.Produce("x"), "cannot push to closed queue") | ||
| } | ||
|
|
||
| func TestBoundedQueue(t *testing.T) { |
There was a problem hiding this comment.
much cleaner, minimal changes
) * [pkg/queue] Add `StartConsumersWithFactory` function This provides a way to keep state for each consumer of a bounded queue, which is useful in certain performance-critical setups. Fixes jaegertracing#2685. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com> * Refactor bounded queue tests to extract common parts The common part with the assertions was moved to a new `checkQueue` function that is used by `TestBoundedQueue` and `TestBoundedQueueWithFactory`. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com> * Use http.HandlerFunc pattern for getting a Consumer from a callback Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com> * Address review comment about unit tests Refactor unit tests using a `helper` function that takes a function to start consumers. Signed-off-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
Which problem is this PR solving?
Short description of the changes
StartConsumersWithFactoryfunction to allow for keeping state per-consumer.StartConsumerswith a dummy factory function.