messaging 3.5.4 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +1 -1
- data/lib/messaging/adapters/postgres/serialized_message.rb +1 -1
- data/lib/messaging/adapters/postgres/stream.rb +8 -1
- data/lib/messaging/message.rb +28 -2
- data/lib/messaging/rails/railtie.rb +4 -0
- data/lib/messaging/routes.rb +12 -1
- data/lib/messaging/version.rb +1 -1
- metadata +3 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7733bdd43c5aadf3544db1993e9b5e4c48fe3f8b08aa1f22f52c7677f203a4d3
|
4
|
+
data.tar.gz: b72f6b61afec8c0815f52bd81559eb01e0f7c9ac8f00e98b3f9985f84994b0fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93f6bee9427950094427800eedbf0ee071de5b8e0a6bafc7ed23a45c85112360d7695fb7d0c0b94b085d504aaf007d4fb647e97b374d20436dd3a26ed02848ca
|
7
|
+
data.tar.gz: b3e9858b73d47d38f7935e0232598e202ef4c834e3183111f376783d4b677c7d680e915efa3da041152cc29ab4329b93478c5dd9d0f595c534f6c8733f0798ed
|
data/Gemfile
CHANGED
@@ -3,14 +3,14 @@ source 'https://rubygems.org'
|
|
3
3
|
git_source(:github) { |path| "https://github.com/#{path}.git" }
|
4
4
|
|
5
5
|
gem 'bootsnap', require: false
|
6
|
-
gem 'listen'
|
6
|
+
#gem 'listen'
|
7
7
|
gem 'pg'
|
8
8
|
gem 'pry'
|
9
9
|
gem 'pry-rails'
|
10
10
|
gem 'railties'
|
11
11
|
gem 'sidekiq'
|
12
12
|
|
13
|
-
gem "github-pages", '203', group: :jekyll_plugins
|
14
|
-
gem "jekyll-include-cache", group: :jekyll_plugins
|
13
|
+
#gem "github-pages", '203', group: :jekyll_plugins
|
14
|
+
#gem "jekyll-include-cache", group: :jekyll_plugins
|
15
15
|
|
16
16
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -5,6 +5,12 @@ module Messaging
|
|
5
5
|
# @return [String] the name of the stream
|
6
6
|
attr_reader :name
|
7
7
|
|
8
|
+
# @return [String] the stream category
|
9
|
+
attr_reader :category
|
10
|
+
|
11
|
+
# @return [String] the stream id
|
12
|
+
attr_reader :id
|
13
|
+
|
8
14
|
# Should not be used directly.
|
9
15
|
# Use {Messaging.stream} or {Store#stream}
|
10
16
|
# @api private
|
@@ -12,12 +18,13 @@ module Messaging
|
|
12
18
|
# @see Store.stream
|
13
19
|
def initialize(name)
|
14
20
|
@name = name
|
21
|
+
@category, @id = name.split('$')
|
15
22
|
end
|
16
23
|
|
17
24
|
# Access to all messages in the stream sorted by stream_position
|
18
25
|
# @return [ActiveRecord::Relation]
|
19
26
|
def messages
|
20
|
-
SerializedMessage.where(
|
27
|
+
SerializedMessage.where(stream_category: category, stream_id: id).order(:stream_position)
|
21
28
|
end
|
22
29
|
|
23
30
|
# The current position of the last message in the stream
|
data/lib/messaging/message.rb
CHANGED
@@ -25,6 +25,32 @@ module Messaging
|
|
25
25
|
end
|
26
26
|
|
27
27
|
module ClassMethods
|
28
|
+
# The stream that the message will be stored in when published.
|
29
|
+
#
|
30
|
+
# Stream names consists of the stream category and the stream id separated by a $.
|
31
|
+
# For instance "customer$123" where "customer" is the category and "123" is the id.
|
32
|
+
#
|
33
|
+
# When no stream name is given the message will not be persisted in the message store.
|
34
|
+
#
|
35
|
+
# @param [#call,String,nil] name The name of the stream, will be evaluated in the context
|
36
|
+
# of the message instance.
|
37
|
+
#
|
38
|
+
# @example
|
39
|
+
# class CustomerRegistered
|
40
|
+
# include Messaging::Message
|
41
|
+
#
|
42
|
+
# stream_name -> { "customer$#{customer_id}"}
|
43
|
+
#
|
44
|
+
# attribute :customer_id, Integer
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# CustomerRegistered.new(customer_id: 123).stream_name
|
48
|
+
# # => "customer$123"
|
49
|
+
def stream_name(name = nil)
|
50
|
+
return @stream_name unless name
|
51
|
+
@stream_name = name
|
52
|
+
end
|
53
|
+
|
28
54
|
# By default the topic is the same as the name of the message.
|
29
55
|
# We change the / that would be set for a namespaced message as "/" isn't valid in a topic
|
30
56
|
# To change the topic for a message just set it to whatever you want in your class definition.
|
@@ -88,8 +114,8 @@ module Messaging
|
|
88
114
|
end
|
89
115
|
|
90
116
|
def stream_name
|
91
|
-
|
92
|
-
|
117
|
+
return unless self.class.stream_name
|
118
|
+
instance_exec(&self.class.stream_name)
|
93
119
|
end
|
94
120
|
|
95
121
|
def stream_category
|
data/lib/messaging/routes.rb
CHANGED
@@ -51,7 +51,18 @@ module Messaging
|
|
51
51
|
|
52
52
|
# Public: Evaluate route definition.
|
53
53
|
def draw(&block)
|
54
|
-
|
54
|
+
routing_definition_blocks << block
|
55
|
+
end
|
56
|
+
|
57
|
+
def routing_definition_blocks
|
58
|
+
@routing_definition_blocks ||= []
|
59
|
+
end
|
60
|
+
|
61
|
+
def finalize_routes
|
62
|
+
clear_routes!
|
63
|
+
routing_definition_blocks.each do |block|
|
64
|
+
instance_eval(&block)
|
65
|
+
end
|
55
66
|
end
|
56
67
|
|
57
68
|
private
|
data/lib/messaging/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -273,7 +273,6 @@ files:
|
|
273
273
|
- ".circleci/config.yml"
|
274
274
|
- ".gitignore"
|
275
275
|
- ".rspec"
|
276
|
-
- ".ruby-version"
|
277
276
|
- Gemfile
|
278
277
|
- Gemfile.lock
|
279
278
|
- README.md
|
@@ -351,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
351
350
|
- !ruby/object:Gem::Version
|
352
351
|
version: '0'
|
353
352
|
requirements: []
|
354
|
-
rubygems_version: 3.0.
|
353
|
+
rubygems_version: 3.0.3.1
|
355
354
|
signing_key:
|
356
355
|
specification_version: 4
|
357
356
|
summary: A library for decoupling applications by using messaging to communicate between
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.1
|