freddy 2.2.4 → 2.5.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d6513e834c71f74caf3c8417644369fddf4087d226d8160c0d72f63d6551db0
4
- data.tar.gz: e4cd3e5016030ec1b5727d9764593d7af91c389b528458a2befeecc502a6600a
3
+ metadata.gz: 9e09e2059a52cd5e7395cdbd6a329c7d2531e479c6ef7113f11d8d2f2c198a72
4
+ data.tar.gz: 25b7ce6639e57cb65c03e3d87b3671528c948c3678d1fbf7dd39f5407929d4a7
5
5
  SHA512:
6
- metadata.gz: 81581b4a9c227aebcfb7f96db79367e4d233502bc0586599500530bb339826371dad203f928e45b2e512f74469c87c8f6f591ca9602d0a14e2e6f047868dae61
7
- data.tar.gz: '090195d2a78659ac91cfef94099dca0bdf382b52590b9298680cd17ed5a04586ee87f5ace05e2fb2a465dc8cf87a07c3504445d78f3d25d6839c34208b291a10'
6
+ metadata.gz: b775211cbc18668d00ddf5214bd0d7f75a679db6c80c59e837a3f3403a5a430965bae52418245563e12e6e612b653e68dd81982cde8d443357e50f89d3bf7dd1
7
+ data.tar.gz: 4fdca691514bd170ce0456aff8f69544b98e70dd2083fbd6a909905cd7d28f216fff74ff3236654b18be3a35465239230c65cdc212355c63b1ee05d07a33a1a9
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ['2.6']
14
+ ruby-version: ['2.7']
15
15
  services:
16
16
  rabbitmq:
17
17
  image: rabbitmq
@@ -27,5 +27,6 @@ jobs:
27
27
  with:
28
28
  ruby-version: ${{ matrix.ruby-version }}
29
29
  bundler-cache: true
30
+ cache-version: 2
30
31
  - name: Run lint & tests
31
32
  run: bundle exec rake
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  .bundle/
2
- Gemfile.lock
3
2
  pkg
4
3
  .tags
5
4
  .tags1
data/.rubocop.yml CHANGED
@@ -28,3 +28,6 @@ Style/FrozenStringLiteralComment:
28
28
 
29
29
  Naming/FileName:
30
30
  Enabled: no
31
+
32
+ Gemspec/RequireMFA:
33
+ Enabled: no
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6
1
+ 2.7
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ gem 'hamster', '~> 3.0'
4
4
  gem 'opentelemetry-sdk', '~> 1.0.0.rc3'
5
5
  gem 'pry'
6
6
  gem 'rspec'
7
- gem 'rubocop', '~> 1.19'
7
+ gem 'rubocop', '~> 1.30'
8
8
  gem 'rubocop-rspec', '~> 2.4'
9
9
 
10
10
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ freddy (2.5.0.pre.rc.1)
5
+ bunny (~> 2.11)
6
+ concurrent-ruby (~> 1.0)
7
+ oj (~> 3.6)
8
+ opentelemetry-api (~> 1.0.0.rc3)
9
+ opentelemetry-semantic_conventions (~> 1.0)
10
+ zlib (~> 1.1)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ amq-protocol (2.3.2)
16
+ ast (2.4.2)
17
+ bunny (2.19.0)
18
+ amq-protocol (~> 2.3, >= 2.3.1)
19
+ sorted_set (~> 1, >= 1.0.2)
20
+ coderay (1.1.3)
21
+ concurrent-ruby (1.1.9)
22
+ diff-lcs (1.4.4)
23
+ hamster (3.0.0)
24
+ concurrent-ruby (~> 1.0)
25
+ method_source (1.0.0)
26
+ oj (3.13.14)
27
+ opentelemetry-api (1.0.0.rc3)
28
+ opentelemetry-common (0.19.1)
29
+ opentelemetry-api (~> 1.0.0.rc3)
30
+ opentelemetry-instrumentation-base (0.18.2)
31
+ opentelemetry-api (~> 1.0.0.rc3)
32
+ opentelemetry-sdk (1.0.0.rc3)
33
+ opentelemetry-api (~> 1.0.0.rc3)
34
+ opentelemetry-common (~> 0.19.1)
35
+ opentelemetry-instrumentation-base (~> 0.18.2)
36
+ opentelemetry-semantic_conventions
37
+ opentelemetry-semantic_conventions (1.6.0)
38
+ opentelemetry-api (~> 1.0.0.rc3)
39
+ parallel (1.22.1)
40
+ parser (3.1.2.0)
41
+ ast (~> 2.4.1)
42
+ pry (0.14.1)
43
+ coderay (~> 1.1)
44
+ method_source (~> 1.0)
45
+ rainbow (3.1.1)
46
+ rake (13.0.6)
47
+ rbtree (0.4.5)
48
+ regexp_parser (2.5.0)
49
+ rexml (3.2.5)
50
+ rspec (3.10.0)
51
+ rspec-core (~> 3.10.0)
52
+ rspec-expectations (~> 3.10.0)
53
+ rspec-mocks (~> 3.10.0)
54
+ rspec-core (3.10.1)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-expectations (3.10.1)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.10.0)
59
+ rspec-mocks (3.10.2)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.10.0)
62
+ rspec-support (3.10.2)
63
+ rubocop (1.30.1)
64
+ parallel (~> 1.10)
65
+ parser (>= 3.1.0.0)
66
+ rainbow (>= 2.2.2, < 4.0)
67
+ regexp_parser (>= 1.8, < 3.0)
68
+ rexml (>= 3.2.5, < 4.0)
69
+ rubocop-ast (>= 1.18.0, < 2.0)
70
+ ruby-progressbar (~> 1.7)
71
+ unicode-display_width (>= 1.4.0, < 3.0)
72
+ rubocop-ast (1.18.0)
73
+ parser (>= 3.1.1.0)
74
+ rubocop-rspec (2.4.0)
75
+ rubocop (~> 1.0)
76
+ rubocop-ast (>= 1.1.0)
77
+ ruby-progressbar (1.11.0)
78
+ set (1.0.2)
79
+ sorted_set (1.0.3)
80
+ rbtree
81
+ set (~> 1.0)
82
+ unicode-display_width (2.1.0)
83
+ zlib (1.1.0)
84
+
85
+ PLATFORMS
86
+ ruby
87
+ x86_64-linux
88
+
89
+ DEPENDENCIES
90
+ bundler
91
+ freddy!
92
+ hamster (~> 3.0)
93
+ opentelemetry-sdk (~> 1.0.0.rc3)
94
+ pry
95
+ rake
96
+ rspec
97
+ rubocop (~> 1.30)
98
+ rubocop-rspec (~> 2.4)
99
+
100
+ BUNDLED WITH
101
+ 2.3.9
data/freddy.gemspec CHANGED
@@ -11,20 +11,19 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = 'API for inter-application messaging supporting acknowledgements and request-response'
12
12
  spec.license = 'MIT'
13
13
  spec.homepage = 'https://github.com/salemove/freddy'
14
- spec.required_ruby_version = '>= 2.6'
14
+ spec.required_ruby_version = '>= 2.7'
15
15
 
16
16
  spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ['lib']
20
19
 
21
20
  spec.add_development_dependency 'bundler'
22
21
  spec.add_development_dependency 'rake'
23
22
 
24
23
  spec.add_dependency 'bunny', '~> 2.11'
24
+ spec.add_dependency 'concurrent-ruby', '~> 1.0'
25
25
  spec.add_dependency 'oj', '~> 3.6'
26
26
  spec.add_dependency 'opentelemetry-api', '~> 1.0.0.rc3'
27
27
  spec.add_dependency 'opentelemetry-semantic_conventions', '~> 1.0'
28
- spec.add_dependency 'thread', '~> 0.1'
29
28
  spec.add_dependency 'zlib', '~> 1.1'
30
29
  end
@@ -6,8 +6,14 @@ require 'forwardable'
6
6
  class Freddy
7
7
  module Adapters
8
8
  class BunnyAdapter
9
+ DEFAULT_OPTIONS = {
10
+ connection_timeout: 5,
11
+ read_timeout: 5,
12
+ write_timeout: 5
13
+ }.freeze
14
+
9
15
  def self.connect(config)
10
- bunny = Bunny.new(config)
16
+ bunny = Bunny.new(DEFAULT_OPTIONS.merge(config))
11
17
  bunny.start
12
18
  new(bunny)
13
19
  end
@@ -34,7 +34,7 @@ class Freddy
34
34
  end
35
35
 
36
36
  def process_message(delivery)
37
- @consume_thread_pool.process do
37
+ @consume_thread_pool.post do
38
38
  delivery.in_span do
39
39
  yield(delivery)
40
40
  end
@@ -46,8 +46,8 @@ class Freddy
46
46
  end
47
47
 
48
48
  def process_message(_queue, delivery)
49
- @consume_thread_pool.process do
50
- delivery.in_span(force_follows_from: true) do
49
+ @consume_thread_pool.post do
50
+ delivery.in_span do
51
51
  yield delivery.payload, delivery.routing_key
52
52
  @channel.acknowledge(delivery.tag)
53
53
  end
@@ -24,28 +24,13 @@ class Freddy
24
24
  @metadata.reply_to
25
25
  end
26
26
 
27
- def in_span(force_follows_from: false, &block)
27
+ def in_span(&block)
28
28
  name = "#{Tracing.span_destination(@exchange, @routing_key)} process"
29
29
  kind = OpenTelemetry::Trace::SpanKind::CONSUMER
30
30
  producer_context = OpenTelemetry.propagation.extract(@metadata[:headers] || {})
31
31
 
32
- if force_follows_from
33
- producer_span_context = OpenTelemetry::Trace.current_span(producer_context).context
34
-
35
- links = []
36
- links << OpenTelemetry::Trace::Link.new(producer_span_context) if producer_span_context.valid?
37
-
38
- root_span = Freddy.tracer.start_root_span(name, attributes: span_attributes, links: links, kind: kind)
39
-
40
- OpenTelemetry::Trace.with_span(root_span) do
41
- block.call
42
- ensure
43
- root_span.finish
44
- end
45
- else
46
- OpenTelemetry::Context.with_current(producer_context) do
47
- Freddy.tracer.in_span(name, attributes: span_attributes, kind: kind, &block)
48
- end
32
+ OpenTelemetry::Context.with_current(producer_context) do
33
+ Freddy.tracer.in_span(name, attributes: span_attributes, kind: kind, &block)
49
34
  end
50
35
  end
51
36
 
@@ -20,7 +20,8 @@ class Freddy
20
20
  # responder.shutdown
21
21
  def shutdown
22
22
  @consumer.cancel
23
- @consume_thread_pool.wait(:done)
23
+ @consume_thread_pool.shutdown
24
+ @consume_thread_pool.wait_for_termination
24
25
  end
25
26
  end
26
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Freddy
4
- VERSION = '2.2.4'
4
+ VERSION = '2.5.0-rc.1'
5
5
  end
data/lib/freddy.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'thread/pool'
4
+ require 'concurrent'
5
5
  require 'securerandom'
6
6
  require 'opentelemetry'
7
7
  require 'opentelemetry/semantic_conventions'
@@ -85,7 +85,7 @@ class Freddy
85
85
  handler_adapter_factory = MessageHandlerAdapters::Factory.new(producer)
86
86
 
87
87
  Consumers::RespondToConsumer.consume(
88
- thread_pool: Thread.pool(@prefetch_buffer_size),
88
+ thread_pool: Concurrent::FixedThreadPool.new(@prefetch_buffer_size),
89
89
  destination: destination,
90
90
  channel: channel,
91
91
  handler_adapter_factory: handler_adapter_factory,
@@ -128,7 +128,7 @@ class Freddy
128
128
  @logger.debug "Tapping into messages that match #{pattern_or_patterns}"
129
129
 
130
130
  Consumers::TapIntoConsumer.consume(
131
- thread_pool: Thread.pool(@prefetch_buffer_size),
131
+ thread_pool: Concurrent::FixedThreadPool.new(@prefetch_buffer_size),
132
132
  patterns: Array(pattern_or_patterns),
133
133
  channel: @connection.create_channel(prefetch: @prefetch_buffer_size),
134
134
  options: options,
@@ -16,7 +16,7 @@ describe Freddy::Consumers::RespondToConsumer do
16
16
  let(:msg_handler_adapter_factory) { double(for: msg_handler_adapter) }
17
17
  let(:msg_handler_adapter) { Freddy::MessageHandlerAdapters::NoOpHandler.new }
18
18
  let(:prefetch_buffer_size) { 2 }
19
- let(:thread_pool) { Thread.pool(prefetch_buffer_size) }
19
+ let(:thread_pool) { Concurrent::FixedThreadPool.new(prefetch_buffer_size) }
20
20
 
21
21
  after do
22
22
  connection.close
@@ -31,12 +31,13 @@ describe Freddy::SyncResponseContainer do
31
31
  describe '#wait_for_response' do
32
32
  let(:timeout) { 2 }
33
33
  let(:response) { { msg: 'response' } }
34
- let(:delivery) { OpenStruct.new(type: 'success') }
35
34
 
36
35
  context 'when called after #call' do
37
36
  let(:max_wait_time_in_seconds) { 0.5 }
38
37
 
39
38
  before do
39
+ delivery = instance_double(Freddy::Delivery)
40
+ allow(delivery).to receive(:type).and_return('success')
40
41
  container.call(response, delivery)
41
42
  end
42
43
 
@@ -57,8 +57,8 @@ describe 'Tracing' do
57
57
  freddy.deliver_with_response(destination, {})
58
58
  names = exporter.finished_spans.map(&:name)
59
59
 
60
- expect(names.any? { |name| name.include?('amq.gen-') }).to eq(false)
61
- expect(names.any? { |name| name.include?('(response queue)') }).to eq(true)
60
+ expect(names.any? { |name| name.include?('amq.gen-') }).to be(false)
61
+ expect(names.any? { |name| name.include?('(response queue)') }).to be(true)
62
62
  end
63
63
  end
64
64
 
@@ -132,10 +132,8 @@ describe 'Tracing' do
132
132
  freddy.close
133
133
  end
134
134
 
135
- it 'creates a new trace and links it with the sender' do
136
- initiator_span = nil
135
+ it 'continues the existing trace' do
137
136
  Freddy.tracer.in_span('test') do
138
- initiator_span = current_span_attributes
139
137
  freddy.deliver(destination, {})
140
138
  end
141
139
  wait_for { @deliver_span }
@@ -147,13 +145,7 @@ describe 'Tracing' do
147
145
  /freddy-topic\.\w+ process/
148
146
  ])
149
147
 
150
- send_span = exporter.finished_spans.find { |span| span.name =~ /\.\w+ send/ }
151
-
152
- expect(@deliver_span.fetch(:trace_id)).not_to eq(initiator_span.fetch(:trace_id))
153
-
154
- link = @deliver_span.fetch(:links)[0]
155
- expect(link.span_context.trace_id).to eq(initiator_span.fetch(:trace_id))
156
- expect(link.span_context.span_id).to eq(send_span.span_id)
148
+ expect(exporter.finished_spans.map(&:trace_id).uniq.count).to eq(1)
157
149
  end
158
150
  end
159
151
 
data/spec/spec_helper.rb CHANGED
@@ -18,8 +18,6 @@ OpenTelemetry::SDK.configure do |c|
18
18
  c.add_span_processor(span_processor)
19
19
  end
20
20
 
21
- Thread.abort_on_exception = true
22
-
23
21
  RSpec.configure do |config|
24
22
  config.run_all_when_everything_filtered = true
25
23
  config.filter_run :focus
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.5.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-12 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,61 +53,61 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.11'
55
55
  - !ruby/object:Gem::Dependency
56
- name: oj
56
+ name: concurrent-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.6'
61
+ version: '1.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.6'
68
+ version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: opentelemetry-api
70
+ name: oj
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0.rc3
75
+ version: '3.6'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0.rc3
82
+ version: '3.6'
83
83
  - !ruby/object:Gem::Dependency
84
- name: opentelemetry-semantic_conventions
84
+ name: opentelemetry-api
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: 1.0.0.rc3
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: 1.0.0.rc3
97
97
  - !ruby/object:Gem::Dependency
98
- name: thread
98
+ name: opentelemetry-semantic_conventions
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.1'
103
+ version: '1.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.1'
110
+ version: '1.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: zlib
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +137,7 @@ files:
137
137
  - ".ruby-gemset"
138
138
  - ".ruby-version"
139
139
  - Gemfile
140
+ - Gemfile.lock
140
141
  - LICENCE.txt
141
142
  - README.md
142
143
  - Rakefile
@@ -190,28 +191,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
191
  requirements:
191
192
  - - ">="
192
193
  - !ruby/object:Gem::Version
193
- version: '2.6'
194
+ version: '2.7'
194
195
  required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  requirements:
196
- - - ">="
197
+ - - ">"
197
198
  - !ruby/object:Gem::Version
198
- version: '0'
199
+ version: 1.3.1
199
200
  requirements: []
200
- rubygems_version: 3.1.6
201
+ rubygems_version: 3.0.9
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: API for inter-application messaging supporting acknowledgements and request-response
204
- test_files:
205
- - spec/.rubocop.yml
206
- - spec/freddy/consumers/respond_to_consumer_spec.rb
207
- - spec/freddy/error_response_spec.rb
208
- - spec/freddy/freddy_spec.rb
209
- - spec/freddy/message_handler_spec.rb
210
- - spec/freddy/payload_spec.rb
211
- - spec/freddy/responder_handler_spec.rb
212
- - spec/freddy/sync_response_container_spec.rb
213
- - spec/integration/concurrency_spec.rb
214
- - spec/integration/reply_spec.rb
215
- - spec/integration/tap_into_with_group_spec.rb
216
- - spec/integration/tracing_spec.rb
217
- - spec/spec_helper.rb
205
+ test_files: []