message_bus_client_worker 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +6 -7
- data/README.md +2 -0
- data/lib/message_bus_client_worker.rb +1 -0
- data/lib/message_bus_client_worker/services/polling/gen_last_id_key.rb +7 -2
- data/lib/message_bus_client_worker/services/polling/generate_params.rb +10 -2
- data/lib/message_bus_client_worker/services/polling/get_last_id.rb +2 -2
- data/lib/message_bus_client_worker/services/polling/process_payload.rb +6 -1
- data/lib/message_bus_client_worker/services/polling/set_last_id.rb +2 -2
- data/lib/message_bus_client_worker/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 179ba68462fe0138eee3e10ca73e946a13c33f0a581357f40176b9cedd356202
|
4
|
+
data.tar.gz: f1013d26918dd42bbfb8fa54bbefe681f7dc581f1038ba315b5880e6baf71303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1cad80bb3cea5a2561812c64df1bbcece2bdf5c972db229cfe3972f4ec0d5fefb623b61d11d6693fd0706c1d3be8513d4b766627b65eec7c03d3d4af23d7598
|
7
|
+
data.tar.gz: 227baabfa7186ebc2297ae5597e251735369f69feec6562e9967d984f0187c4c72f7cae48a485c261f6ff7c7d787691fe8696245e858dc11bd72aeb4cd49b077
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.2.1] - 2019-06-11
|
8
|
+
### Fixed
|
9
|
+
- conflicting last id when differentiating with headers
|
10
|
+
|
7
11
|
## [1.2.0] - 2018-02-24
|
8
12
|
### Added
|
9
13
|
- Add ability to customise client_id
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
message_bus_client_worker (1.2.
|
4
|
+
message_bus_client_worker (1.2.1)
|
5
5
|
activesupport
|
6
6
|
addressable
|
7
7
|
excon
|
@@ -12,7 +12,7 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (5.2.
|
15
|
+
activesupport (5.2.3)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 0.7, < 2)
|
18
18
|
minitest (~> 5.1)
|
@@ -24,12 +24,11 @@ GEM
|
|
24
24
|
concurrent-ruby (1.0.5)
|
25
25
|
connection_pool (2.2.2)
|
26
26
|
diff-lcs (1.3)
|
27
|
-
excon (0.
|
27
|
+
excon (0.64.0)
|
28
28
|
gem_config (0.3.1)
|
29
|
-
i18n (1.
|
29
|
+
i18n (1.6.0)
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
|
-
light-service (0.
|
32
|
-
activesupport (>= 3.0)
|
31
|
+
light-service (0.12.0)
|
33
32
|
method_source (0.9.0)
|
34
33
|
minitest (5.11.3)
|
35
34
|
pry (0.11.3)
|
@@ -38,7 +37,7 @@ GEM
|
|
38
37
|
pry-byebug (3.6.0)
|
39
38
|
byebug (~> 10.0)
|
40
39
|
pry (~> 0.10)
|
41
|
-
public_suffix (3.0
|
40
|
+
public_suffix (3.1.0)
|
42
41
|
rack (2.0.6)
|
43
42
|
rack-protection (2.0.3)
|
44
43
|
rack
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@ Subscribe to [MessageBus](https://github.com/SamSaffron/message_bus) using Sidek
|
|
7
7
|
- do not unnecessarily add noise when starting the console like `rails console`
|
8
8
|
- recover from downtime by keeping track of the last message it processed per channel
|
9
9
|
|
10
|
+
This gem does **not** promise that the message are processed only once. You must put safeguards in place if it is imperative that messages are not processed more than once.
|
11
|
+
|
10
12
|
## Installation
|
11
13
|
|
12
14
|
Add this line to your application's Gemfile:
|
@@ -2,8 +2,13 @@ module MessageBusClientWorker
|
|
2
2
|
module Polling
|
3
3
|
class GenLastIdKey
|
4
4
|
|
5
|
-
def self.call(host
|
6
|
-
[host, channel]
|
5
|
+
def self.call(host:, channel:, headers: {})
|
6
|
+
key_parts = [host, channel]
|
7
|
+
(headers || {}).each do |key, value|
|
8
|
+
key_parts << [key, value].join("_")
|
9
|
+
end
|
10
|
+
|
11
|
+
Digest::SHA256.hexdigest(key_parts.join("-"))
|
7
12
|
end
|
8
13
|
|
9
14
|
end
|
@@ -3,7 +3,7 @@ module MessageBusClientWorker
|
|
3
3
|
class GenerateParams
|
4
4
|
extend LightService::Action
|
5
5
|
|
6
|
-
expects :host, :subscriptions
|
6
|
+
expects :host, :subscriptions, :headers
|
7
7
|
promises :params, :form_params
|
8
8
|
|
9
9
|
DEFAULT_MESSAGE_ID = "-1".freeze
|
@@ -13,8 +13,16 @@ module MessageBusClientWorker
|
|
13
13
|
|
14
14
|
c.params = { dlp: 't' }
|
15
15
|
c.form_params = channels.each_with_object({}) do |sub, hash|
|
16
|
+
channel = sub[0]
|
16
17
|
custom_message_id = sub[1][:message_id] ? sub[1][:message_id].to_s : nil
|
17
|
-
|
18
|
+
|
19
|
+
last_id_in_memory = GetLastId.(
|
20
|
+
host: c.host,
|
21
|
+
channel: channel,
|
22
|
+
headers: c.headers,
|
23
|
+
)
|
24
|
+
|
25
|
+
hash[channel] = last_id_in_memory ||
|
18
26
|
custom_message_id ||
|
19
27
|
DEFAULT_MESSAGE_ID
|
20
28
|
end
|
@@ -2,8 +2,8 @@ module MessageBusClientWorker
|
|
2
2
|
module Polling
|
3
3
|
class GetLastId
|
4
4
|
|
5
|
-
def self.call(host
|
6
|
-
hash_key = GenLastIdKey.(host, channel)
|
5
|
+
def self.call(host:, channel:, headers: {})
|
6
|
+
hash_key = GenLastIdKey.(host: host, channel: channel, headers: headers)
|
7
7
|
Sidekiq.redis { |r| r.hget(SetLastId::CHANNEL_INDICES_NAME, hash_key) }
|
8
8
|
end
|
9
9
|
|
@@ -21,7 +21,12 @@ module MessageBusClientWorker
|
|
21
21
|
next c if channel_config.nil?
|
22
22
|
|
23
23
|
processor_class = Kernel.const_get(channel_config[:processor])
|
24
|
-
SetLastId.(
|
24
|
+
SetLastId.(
|
25
|
+
host: c.host,
|
26
|
+
channel: channel,
|
27
|
+
message_id: payload["message_id"],
|
28
|
+
headers: c.headers,
|
29
|
+
)
|
25
30
|
|
26
31
|
data = payload["data"]
|
27
32
|
|
@@ -3,8 +3,8 @@ module MessageBusClientWorker
|
|
3
3
|
class SetLastId
|
4
4
|
|
5
5
|
CHANNEL_INDICES_NAME = "message_bus_client_worker_channel_indices".freeze
|
6
|
-
def self.call(host
|
7
|
-
hash_key = GenLastIdKey.(host, channel)
|
6
|
+
def self.call(host:, channel:, message_id:, headers:)
|
7
|
+
hash_key = GenLastIdKey.(host: host, channel: channel, headers: headers)
|
8
8
|
|
9
9
|
id = Sidekiq.redis do |r|
|
10
10
|
r.hset(CHANNEL_INDICES_NAME, hash_key, message_id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_bus_client_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.7.
|
224
|
+
rubygems_version: 2.7.7
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Subscribe to MessageBus using Sidekiq workers
|