freddy 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +31 -0
- data/.rubocop.yml +9 -28
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +3 -4
- data/README.md +15 -10
- data/freddy.gemspec +11 -18
- data/lib/freddy.rb +21 -17
- data/lib/freddy/adapters.rb +3 -28
- data/lib/freddy/adapters/bunny_adapter.rb +20 -3
- data/lib/freddy/consumers.rb +1 -1
- data/lib/freddy/consumers/respond_to_consumer.rb +3 -13
- data/lib/freddy/consumers/response_consumer.rb +2 -4
- data/lib/freddy/consumers/tap_into_consumer.rb +41 -25
- data/lib/freddy/delivery.rb +46 -13
- data/lib/freddy/payload.rb +3 -34
- data/lib/freddy/producers.rb +1 -1
- data/lib/freddy/producers/reply_producer.rb +12 -5
- data/lib/freddy/producers/send_and_forget_producer.rb +5 -11
- data/lib/freddy/producers/send_and_wait_response_producer.rb +19 -33
- data/lib/freddy/request_manager.rb +1 -9
- data/lib/freddy/tracing.rb +37 -0
- data/lib/freddy/version.rb +5 -0
- data/spec/.rubocop.yml +26 -0
- data/spec/freddy/error_response_spec.rb +6 -6
- data/spec/freddy/payload_spec.rb +25 -16
- data/spec/integration/concurrency_spec.rb +8 -12
- data/spec/integration/tap_into_with_group_spec.rb +34 -0
- data/spec/integration/tracing_spec.rb +15 -32
- data/spec/spec_helper.rb +5 -13
- metadata +31 -19
- data/.npmignore +0 -8
- data/.travis.yml +0 -13
- data/lib/freddy/adapters/march_hare_adapter.rb +0 -64
- data/lib/freddy/trace_carrier.rb +0 -28
- data/spec/freddy/trace_carrier_spec.rb +0 -56
data/lib/freddy/trace_carrier.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Freddy
|
4
|
-
# Carrier for rabbitmq following OpenTracing API
|
5
|
-
# See https://github.com/opentracing/opentracing-ruby/blob/master/lib/opentracing/carrier.rb
|
6
|
-
class TraceCarrier
|
7
|
-
def initialize(properties)
|
8
|
-
@properties = properties
|
9
|
-
end
|
10
|
-
|
11
|
-
def [](key)
|
12
|
-
@properties.headers && @properties.headers["x-trace-#{key}"]
|
13
|
-
end
|
14
|
-
|
15
|
-
def []=(key, value)
|
16
|
-
@properties[:headers] ||= {}
|
17
|
-
@properties[:headers]["x-trace-#{key}"] = value
|
18
|
-
end
|
19
|
-
|
20
|
-
def each(&block)
|
21
|
-
Hash[
|
22
|
-
(@properties.headers || {})
|
23
|
-
.select { |key, _| key =~ /^x-trace/ }
|
24
|
-
.map { |key, value| [key.sub(/x-trace-/, ''), value] }
|
25
|
-
].each(&block)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Freddy::TraceCarrier do
|
4
|
-
subject(:carrier) { described_class.new(properties) }
|
5
|
-
|
6
|
-
context 'when adding trace information' do
|
7
|
-
let(:properties) { { x: 'y' } }
|
8
|
-
let(:key_name) { 'some-key' }
|
9
|
-
let(:key_value) { 'some-key' }
|
10
|
-
|
11
|
-
it 'adds a header with x-trace- prefix' do
|
12
|
-
carrier[key_name] = key_value
|
13
|
-
expect(properties[:headers]["x-trace-#{key_name}"]).to eq(key_value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when extracting trace information' do
|
18
|
-
let(:key_name) { 'some-key' }
|
19
|
-
let(:serialized_key_name) { "x-trace-#{key_name}" }
|
20
|
-
let(:key_value) { 'some-key' }
|
21
|
-
|
22
|
-
let(:properties) do
|
23
|
-
double(headers: { serialized_key_name => key_value })
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'extracts a header with x-trace- prefix' do
|
27
|
-
expect(carrier[key_name]).to eq(key_value)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#each' do
|
32
|
-
context 'when headers are present' do
|
33
|
-
let(:properties) do
|
34
|
-
double(
|
35
|
-
headers: {
|
36
|
-
'x-trace-key1' => 'value1',
|
37
|
-
'x-trace-key2' => 'value2',
|
38
|
-
'other-key' => 'value3'
|
39
|
-
}
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'iterates over keys starting with x-trace- prefix' do
|
44
|
-
expect(carrier.each.count).to eq(2)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when no headers' do
|
49
|
-
let(:properties) { double(headers: nil) }
|
50
|
-
|
51
|
-
it 'iterates over an empty list' do
|
52
|
-
expect(carrier.each.count).to eq(0)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|