nexus_domain_events 0.0.0 → 1.0.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: 681696a0e3df1cbcbf54e5b0c1a103893a3cc75bc12bcd402c84eeee2176c7d7
4
- data.tar.gz: 52ea658a2ea2d82d04661009c11592bb06e5ec11fc5732e9c0478c1c57883544
3
+ metadata.gz: '09ee1d8a1cf68e5c60d8c25c5207a3d9162cf395e4adfa88d71d0a7dda59fcb6'
4
+ data.tar.gz: c767b8c7442f51345e205d4880dfc1f4f2500186a0fa292f098b51c93372f813
5
5
  SHA512:
6
- metadata.gz: b12d6d112682b360015a7c207d36e34372b001b5044820b73f4435c0a78cffc8e4dbd8920e96de13072fdb20058042b5c7a03ae083ef91f4e22aaf88696c56d8
7
- data.tar.gz: 4d69e591d7dcb24ae53518dd735efa3689853fd9d77577f81e971923fe041fcd08ef34c97551ec69e6699d758c2f89603bebda6761f7c0a9a1052d58225a7037
6
+ metadata.gz: d144b45f1e6bb3abf62d1c99cbbeb906955352c9b283fd28534e4f17e0920f911d92e3f111f8bdc5ab6262651318508879c8fd2b1837a59e7b7b092b21fa3a47
7
+ data.tar.gz: 3f7828176eaa5261c9b55e51de4a31281d93a4ab41e8ec60a1c0d0c4f32a7cbf829e7faaeddce4595aaec829ec9433884c66e4803347d8ee849ac40dfd53758e
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
  require 'nexus_domain_events/event'
3
+ require 'nexus_domain_events/bus'
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NexusDomainEvents
4
+ # A domain events bus for dispatching events to
5
+ class Bus
6
+ def initialize(topic: nil)
7
+ @topic = topic || default_topic
8
+ end
9
+
10
+ # @param [Event] domain_event
11
+ def dispatch(domain_event)
12
+ @topic.publish(
13
+ domain_event.to_json,
14
+ routing_key: domain_event.message_name
15
+ )
16
+ end
17
+
18
+ private
19
+
20
+ def default_topic
21
+ conn = Bunny.new(ENV['AMQP_CONNECTION']).start
22
+ channel = conn.create_channel
23
+ channel.topic('domain_events', durable: true)
24
+ end
25
+ end
26
+ end
@@ -20,7 +20,7 @@ module NexusDomainEvents
20
20
  message_id: nil,
21
21
  created_at: nil
22
22
  )
23
- @message_name = message_name
23
+ @message_name = message_name.upcase
24
24
  @actor = actor
25
25
  @payload = payload
26
26
  @message_id = message_id || SecureRandom.uuid
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NexusDomainEvents
3
- VERSION = '0.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.email = ['chris.harrison@nexusmods.com']
9
9
 
10
10
  spec.summary = 'Ruby based domain eventing tools'
11
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
11
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
12
12
 
13
13
  # Specify which files should be added to the gem when it is released.
14
14
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexus_domain_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Harrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,7 @@ files:
38
38
  - Gemfile
39
39
  - README.md
40
40
  - lib/nexus_domain_events.rb
41
+ - lib/nexus_domain_events/bus.rb
41
42
  - lib/nexus_domain_events/event.rb
42
43
  - lib/nexus_domain_events/version.rb
43
44
  - nexus_domain_events.gemspec
@@ -52,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
53
  requirements:
53
54
  - - ">="
54
55
  - !ruby/object:Gem::Version
55
- version: 2.3.0
56
+ version: 2.6.0
56
57
  required_rubygems_version: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - ">="