nexus_domain_events 1.0.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/nexus_domain_events/bus.rb +27 -7
- data/lib/nexus_domain_events/version.rb +1 -1
- data/nexus_domain_events.gemspec +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 531687ab020e0d37c567ec99ef2b5fc2091871524ddde0a080d45d86bcdc0485
|
4
|
+
data.tar.gz: 8ea060af971cfd1539f907bde393b1bfdc22f246d0b7ef5799d03001f49595c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8fcc03b7986e7d06f68ea9caba75d1629421eb5def30fd55d4ecff1014f2fbe57ad19f1ca2ed35fd649c2e6139b0b6a7047233ffc8b18b834a7e26fba7b71c
|
7
|
+
data.tar.gz: 5b50e1907185dbd55946cc9c6361b1065aac3123acdceba2a1e9904464c9f7a75c66660c0d3a9c8e96533d25af8af05c820a4b04f8bf34e321af03b716788eb6
|
data/Gemfile
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bunny'
|
4
|
+
|
3
5
|
module NexusDomainEvents
|
4
6
|
# A domain events bus for dispatching events to
|
5
7
|
class Bus
|
6
|
-
def initialize(
|
7
|
-
@
|
8
|
+
def initialize(bunny: nil, topic_name: 'domain_events')
|
9
|
+
@mutex = Mutex.new
|
10
|
+
@bunny = bunny
|
11
|
+
@topic_name = topic_name
|
8
12
|
end
|
9
13
|
|
10
14
|
# @param [Event] domain_event
|
11
15
|
def dispatch(domain_event)
|
12
|
-
|
16
|
+
ensure_connection!
|
17
|
+
@exchange.publish(
|
13
18
|
domain_event.to_json,
|
14
19
|
routing_key: domain_event.message_name
|
15
20
|
)
|
@@ -17,10 +22,25 @@ module NexusDomainEvents
|
|
17
22
|
|
18
23
|
private
|
19
24
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
def ensure_connection!
|
26
|
+
@mutex.synchronize do
|
27
|
+
connect! unless connected?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def connect!
|
32
|
+
@bunny ||= create_bunny_connection
|
33
|
+
@bunny.start
|
34
|
+
@channel = @bunny.create_channel
|
35
|
+
@exchange = @channel.topic(@topic_name, durable: true)
|
36
|
+
end
|
37
|
+
|
38
|
+
def connected?
|
39
|
+
@bunny&.connected? && @channel
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_bunny_connection
|
43
|
+
Bunny.new(ENV['AMQP_CONNECTION'])
|
24
44
|
end
|
25
45
|
end
|
26
46
|
end
|
data/nexus_domain_events.gemspec
CHANGED
@@ -8,7 +8,6 @@ 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.6.0')
|
12
11
|
|
13
12
|
# Specify which files should be added to the gem when it is released.
|
14
13
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -17,4 +16,5 @@ Gem::Specification.new do |spec|
|
|
17
16
|
end
|
18
17
|
spec.require_paths = ['lib']
|
19
18
|
spec.add_dependency('activesupport')
|
19
|
+
spec.add_dependency('bunny')
|
20
20
|
end
|
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: 1.
|
4
|
+
version: 1.1.2
|
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-
|
11
|
+
date: 2021-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bunny
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description:
|
28
42
|
email:
|
29
43
|
- chris.harrison@nexusmods.com
|
@@ -53,14 +67,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
67
|
requirements:
|
54
68
|
- - ">="
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
70
|
+
version: '0'
|
57
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
requirements: []
|
63
|
-
rubygems_version: 3.2.
|
77
|
+
rubygems_version: 3.2.10
|
64
78
|
signing_key:
|
65
79
|
specification_version: 4
|
66
80
|
summary: Ruby based domain eventing tools
|