message_bus_client_worker 0.4.0 → 1.0.0
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 +1 -1
- data/README.md +13 -6
- data/lib/message_bus_client_worker/services/poll.rb +1 -0
- data/lib/message_bus_client_worker/services/polling/generate_params.rb +3 -1
- data/lib/message_bus_client_worker/services/polling/get_payloads.rb +8 -4
- data/lib/message_bus_client_worker/services/polling/process_payload.rb +1 -1
- data/lib/message_bus_client_worker/version.rb +1 -1
- data/lib/message_bus_client_worker/workers/subscription_worker.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985339771e8dc4677c05243329c0ad6e870ede8550419450187a7a8ae5f11cfa
|
4
|
+
data.tar.gz: 1e0b8dcd09be180ef2d3c6dd01414026fbe84f82c30fb90f0ee54231cdaa98b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a40cd6e81d84ad63c7815f36cc68d6b1668dfd1251f41959b4d6e178cb7c2b1751a6425f5a58265f50cc9cd86ffe495c4b5a5bf6615c83d57a98854e3b4fc1e2
|
7
|
+
data.tar.gz: d527f1486421c47f0883ead97e8776b23ee9d270492ec919ca1049a37f512229e077e63443f2eb77d464c617503369a254edf623ed5419476fba7ec14c19affd
|
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.0.0] - 2018-02-12
|
8
|
+
### Changed
|
9
|
+
- Change structure of `subscriptions` config to include headers and channels.
|
10
|
+
|
7
11
|
## [0.4.0] - 2018-12-19
|
8
12
|
### Changed
|
9
13
|
- Change to excon. We know how to stream with that (make way for long polling)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -38,14 +38,21 @@ MessageBusClientWorker.configure do |c|
|
|
38
38
|
# }
|
39
39
|
# }
|
40
40
|
"https://etc.com" => {
|
41
|
-
|
42
|
-
|
43
|
-
message_id: 0,
|
41
|
+
headers: {
|
42
|
+
"Authorization" => "Bearer #{ENV["MYTOKEN"]}",
|
44
43
|
},
|
45
|
-
|
44
|
+
channels: {
|
45
|
+
"/exchange_rates" => {
|
46
|
+
processor: "ProcessExchangeRate",
|
47
|
+
message_id: 0,
|
48
|
+
},
|
49
|
+
"/messages" => { processor: "ProcessMessage" },
|
50
|
+
}
|
46
51
|
},
|
47
52
|
"https://someotherdomain.com" => {
|
48
|
-
|
53
|
+
channels: {
|
54
|
+
"/errors" => { processor: "ProcessError" },
|
55
|
+
}
|
49
56
|
},
|
50
57
|
}
|
51
58
|
end
|
@@ -114,7 +121,7 @@ Sidekiq.options[:poll_interval] = 10
|
|
114
121
|
|
115
122
|
## How it Works
|
116
123
|
|
117
|
-
Every time `MessageBusClientWorker::EnqueuingWorker` is enqueued, `EnqueuingWorker` attempts to enqueue a `MessageBusClientWorker::SubscriptionWorker` per channel that is found in `MessageBusClientWorker.configuration.subcriptions`.
|
124
|
+
Every time `MessageBusClientWorker::EnqueuingWorker` is enqueued, `EnqueuingWorker` attempts to enqueue a `MessageBusClientWorker::SubscriptionWorker` per channel that is found in `MessageBusClientWorker.configuration.subcriptions`.
|
118
125
|
|
119
126
|
`SubscriptionWorker` will open a connection to the server, and try the following (not all have been implemented):
|
120
127
|
|
@@ -9,8 +9,10 @@ module MessageBusClientWorker
|
|
9
9
|
DEFAULT_MESSAGE_ID = "-1".freeze
|
10
10
|
|
11
11
|
executed do |c|
|
12
|
+
channels = c.subscriptions[:channels]
|
13
|
+
|
12
14
|
c.params = { dlp: 't' }
|
13
|
-
c.form_params =
|
15
|
+
c.form_params = channels.each_with_object({}) do |sub, hash|
|
14
16
|
custom_message_id = sub[1][:message_id] ? sub[1][:message_id].to_s : nil
|
15
17
|
hash[sub[0]] = GetLastId.(c.host, sub[0]) ||
|
16
18
|
custom_message_id ||
|
@@ -3,14 +3,18 @@ module MessageBusClientWorker
|
|
3
3
|
class GetPayloads
|
4
4
|
extend LightService::Action
|
5
5
|
|
6
|
-
expects :params, :form_params, :uri
|
6
|
+
expects :params, :form_params, :uri, :headers
|
7
7
|
promises :payloads
|
8
8
|
|
9
9
|
executed do |c|
|
10
|
-
|
10
|
+
opts = {
|
11
11
|
query: c.params,
|
12
|
-
body: URI.encode_www_form(c.form_params)
|
13
|
-
}
|
12
|
+
body: URI.encode_www_form(c.form_params),
|
13
|
+
}
|
14
|
+
|
15
|
+
opts.merge!(headers: c.headers) if c.headers
|
16
|
+
response = Excon.post(c.uri, opts)
|
17
|
+
|
14
18
|
c.payloads = JSON.parse(response.body.to_s)
|
15
19
|
end
|
16
20
|
end
|
@@ -12,8 +12,8 @@ module MessageBusClientWorker
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def log(host, subscriptions)
|
15
|
-
subscriptions.each do |subscription|
|
16
|
-
Sidekiq::Logging.logger.info "Enqueued #{host} for #{subscription}"
|
15
|
+
subscriptions.each do |key, subscription|
|
16
|
+
Sidekiq::Logging.logger.info "Enqueued #{host} for #{subscription[:channels]}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|