harmoniser 0.2.0 → 0.4.0

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: e388156d56ef5ed0664269fd342a778cf7cd96547539d8282125252a880b2fe8
4
- data.tar.gz: 0d1a7a75f214c27a1f703a5b8951d0063982baf65cd8b492110e79c05c73c2f9
3
+ metadata.gz: b1feaead73df2956797f89d33ed45a3316cf5191852946c1b0d3cbe2e2284f18
4
+ data.tar.gz: 6ba7ae634d24a012d4243d392d4299a9fd88a35af5df1251efec24bb4817ce9c
5
5
  SHA512:
6
- metadata.gz: 7398e433e4f12f75cbb807470c1562b569d683b846c84b3dac85c1e23e0cfc21f0365a42a3608d3d9ae7d5e412fa6d80b31ad20455ff587290c353a4b46acdd9
7
- data.tar.gz: 1848ced849205cc118ad6b21a64bcce9ca5e781ce5268445ce2f2e8cb84fee7aa52a7afc4561658da5b3069ef4d8b981d63f8d5cfff10b54a84c2ea1d280ff4b
6
+ metadata.gz: 9cfcdeec3f6e205c9301d5f2142cd8e7fee0723ed5950fdf1bd12a704f1cc29ecf971e39c75ef7ace071ea577a37f45a874c4016a63c561d25c3e206f1fb0e6f
7
+ data.tar.gz: 45b409fb2bfa3ec1752101915fad8f52ccf1e5a5ea1402e23ee6fc062e952fbdb78a16015f77bc2ef2ddafda04859eb23d0e9c8c9cef06a9675fe0c44e81f5d5
data/CHANGELOG.md CHANGED
@@ -1,16 +1,31 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.0] - 2023-11-27
3
+ ## [0.4.0] - 2023-12-07
4
4
 
5
5
  ### Added
6
+ - Default logger with error severity for when errors occur at channel level
7
+ - Default logger with error severity for when errors occur while processing a message from a queue
6
8
 
7
- - Support to express publishing through any kind of exchanges
8
- - Capability to subscribe to queues
9
- - Express RabbitMQ topology separated from the responsibility of publishing or subscribing
10
- - Provide dedicated Ruby process to consume messages through the subscribers defined
9
+ ### Removed
10
+ - Unused docker image for rabbitMQ (only for development purposes)
11
+
12
+ ## [0.3.0] - 2023-11-29
13
+
14
+ ### Added
15
+
16
+ - Introduce github action for building, linting and running specs anytime a pull request is opened or push to master happens
11
17
 
12
18
  ## [0.2.0] - 2023-11-28
13
19
 
14
20
  ### Added
15
21
 
16
22
  - Introduce github action for releasing the gem once is merged into master
23
+
24
+ ## [0.1.0] - 2023-11-27
25
+
26
+ ### Added
27
+
28
+ - Support to express publishing through any kind of exchanges
29
+ - Capability to subscribe to queues
30
+ - Express RabbitMQ topology separated from the responsibility of publishing or subscribing
31
+ - Provide dedicated Ruby process to consume messages through the subscribers defined
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Harmoniser
2
2
 
3
- A minimalistic approach to communicate with RabbitMQ.
3
+ [![Gem Version](https://badge.fury.io/rb/harmoniser.svg)](https://badge.fury.io/rb/harmoniser)
4
+ ![CI workflow](https://github.com/jollopre/harmoniser/actions/workflows/ci.yml/badge.svg)
5
+
6
+ A minimalistic approach to communicating with RabbitMQ.
4
7
 
5
8
  Harmoniser uses [Bunny](https://github.com/ruby-amqp/bunny) as a low level library to communicate with RabbitMQ in order to integrate publishing and messages consuming.
6
9
 
@@ -122,7 +125,6 @@ You can also shell into the running container by executing `$ make shell` and fr
122
125
  - [ ] Chore: Introduce simplecov gem for code coverage.
123
126
  - [ ] Feature: Add sensible defaults for Session options like heartbeat, timeout, recovery_completed or recovery_attempt_started.
124
127
  - [ ] Feature: Add default `on_return` handler as well as permitting the definition of on_return method to be called anytime a published message gets returned.
125
- - [ ] Feature: Add default `on_error` and `on_uncaught_exception` as well as permitting the definition of them to be called anytime an error in the channel occurs or error in the consumer handler happens.
126
128
  - [ ] Feature: Introduce capability of configuring number of threads for queue consuming at the CLI.
127
129
 
128
130
  ## License
data/harmoniser.gemspec CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Jose Lloret"]
9
9
  spec.email = ["jollopre@gmail.com"]
10
10
 
11
- spec.summary = "A minimalistic approach to communicate with RabbitMQ"
12
- spec.description = "A declarative approach to communicate with RabbitMQ, that uses the reference low level library, to integrate publishing and consuming of messages"
11
+ spec.summary = "A minimalistic approach to communicating with RabbitMQ"
12
+ spec.description = "A declarative approach to communicating with RabbitMQ that makes it easy to integrate publishing and consuming messages"
13
13
  spec.homepage = "https://github.com/jollopre/harmoniser"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.0"
15
+ spec.required_ruby_version = ">= 3.2"
16
16
 
17
17
  spec.metadata = {
18
18
  "homepage_uri" => spec.homepage,
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_runtime_dependency "bunny", "~> 2.22"
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rspec", "~> 3"
30
30
  spec.add_development_dependency "standardrb", "~> 1.0"
31
31
  end
@@ -11,8 +11,20 @@ module Harmoniser
11
11
  end
12
12
 
13
13
  def create_channel
14
- connection = Harmoniser.connection
15
- connection.create_channel
14
+ channel = Harmoniser.connection.create_channel
15
+ channel.on_error(&method(:on_error).to_proc)
16
+ channel.on_uncaught_exception(&method(:on_uncaught_exception).to_proc)
17
+ channel
18
+ end
19
+
20
+ private
21
+
22
+ def on_error(channel, amq_method)
23
+ Harmoniser.logger.error("Default on_error handler executed for channel: method = `#{amq_method}`, exchanges = `#{channel.exchanges.keys}`, queues = `#{channel.queues.keys}`")
24
+ end
25
+
26
+ def on_uncaught_exception(error, consumer)
27
+ Harmoniser.logger.error("Default on_uncaught_exception handler executed for channel: error_class = `#{error.class}`, error_message = `#{error.message}`, error_backtrace = `#{error.backtrace&.first(5)}, queue = `#{consumer.queue}`")
16
28
  end
17
29
  end
18
30
 
@@ -20,14 +20,14 @@ module Harmoniser
20
20
  }
21
21
  MUTEX = Mutex.new
22
22
 
23
- attr_reader :connection, :connection_opts, :logger, :options
23
+ attr_reader :connection_opts, :logger, :options
24
24
  def_delegators :options, :environment, :require, :verbose
25
25
 
26
26
  def initialize
27
27
  @logger = Logger.new($stdout, progname: "harmoniser@#{VERSION}")
28
28
  @options = Options.new(**default_options)
29
29
  set_logger_severity
30
- @connection_opts = DEFAULT_CONNECTION_OPTS.merge({ logger: @logger })
30
+ @connection_opts = DEFAULT_CONNECTION_OPTS.merge({logger: @logger})
31
31
  @topology = Topology.new
32
32
  end
33
33
 
@@ -39,7 +39,7 @@ module Harmoniser
39
39
 
40
40
  def connection
41
41
  MUTEX.synchronize do
42
- @connection = Connection.new(connection_opts) unless @connection
42
+ @connection ||= Connection.new(connection_opts)
43
43
  @connection.start unless @connection.open?
44
44
  @connection
45
45
  end
@@ -51,8 +51,8 @@ module Harmoniser
51
51
  @connection_opts = connection_opts.merge(opts)
52
52
  end
53
53
 
54
- def options_with(**kwargs)
55
- @options = options.with(**kwargs)
54
+ def options_with(**)
55
+ @options = options.with(**)
56
56
  set_logger_severity
57
57
  end
58
58
 
@@ -67,10 +67,10 @@ module Harmoniser
67
67
  end
68
68
 
69
69
  def set_logger_severity
70
- if @options.production?
71
- @logger.level = @options.verbose? ? Logger::DEBUG : Logger::INFO
70
+ @logger.level = if @options.production?
71
+ @options.verbose? ? Logger::DEBUG : Logger::INFO
72
72
  else
73
- @logger.level = Logger::DEBUG
73
+ Logger::DEBUG
74
74
  end
75
75
  end
76
76
  end
@@ -34,7 +34,7 @@ module Harmoniser
34
34
  end
35
35
 
36
36
  def stop_subscribers
37
- @logger.info("Connection will be closed: connection = `#{@configuration.connection.to_s}`")
37
+ @logger.info("Connection will be closed: connection = `#{@configuration.connection}`")
38
38
  @configuration.connection.close
39
39
  end
40
40
 
@@ -3,7 +3,7 @@ require "harmoniser/definition"
3
3
 
4
4
  module Harmoniser
5
5
  module Publisher
6
- class MissingExchangeDefinition < StandardError ; end
6
+ class MissingExchangeDefinition < StandardError; end
7
7
  include Channelable
8
8
  MUTEX = Mutex.new
9
9
  private_constant :MUTEX
@@ -13,7 +13,7 @@ module Harmoniser
13
13
  @harmoniser_exchange_definition = Definition::Exchange.new(
14
14
  name: exchange_name,
15
15
  type: nil,
16
- opts: { passive: true }
16
+ opts: {passive: true}
17
17
  )
18
18
  end
19
19
 
@@ -4,7 +4,7 @@ require "harmoniser/includable"
4
4
 
5
5
  module Harmoniser
6
6
  module Subscriber
7
- class MissingConsumerDefinition < StandardError ; end
7
+ class MissingConsumerDefinition < StandardError; end
8
8
  include Channelable
9
9
  include Includable
10
10
  MUTEX = Mutex.new
@@ -64,7 +64,7 @@ module Harmoniser
64
64
  if binding.queue?
65
65
  channel.queue_bind(binding.destination_name, binding.exchange_name, binding.opts)
66
66
  elsif binding.exchange?
67
- ;
67
+
68
68
  end
69
69
  end
70
70
  end
@@ -1,3 +1,3 @@
1
1
  module Harmoniser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harmoniser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Lloret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: standardrb
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
- description: A declarative approach to communicate with RabbitMQ, that uses the reference
70
- low level library, to integrate publishing and consuming of messages
69
+ description: A declarative approach to communicating with RabbitMQ that makes it easy
70
+ to integrate publishing and consuming messages
71
71
  email:
72
72
  - jollopre@gmail.com
73
73
  executables:
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 2.7.0
117
+ version: '3.2'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
@@ -124,5 +124,5 @@ requirements: []
124
124
  rubygems_version: 3.4.10
125
125
  signing_key:
126
126
  specification_version: 4
127
- summary: A minimalistic approach to communicate with RabbitMQ
127
+ summary: A minimalistic approach to communicating with RabbitMQ
128
128
  test_files: []