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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d1ed898ee221c9db4f30d3e09e22455833341af7d7cc2beb12984489d75b0ac
4
- data.tar.gz: 03f607cb696136a557a9e41e522d02db6a52ef786563bcff52ef1a81d2bb87dc
3
+ metadata.gz: 985339771e8dc4677c05243329c0ad6e870ede8550419450187a7a8ae5f11cfa
4
+ data.tar.gz: 1e0b8dcd09be180ef2d3c6dd01414026fbe84f82c30fb90f0ee54231cdaa98b1
5
5
  SHA512:
6
- metadata.gz: 9a3f37a8f17607005fb3a49567199484afd7c1e5a5426ad169647b4b1ca0467130e915d96896e2ca82dcb7939cc6a785ad7d8943b4f87b53a4799b1a62d0181e
7
- data.tar.gz: 0ba78f0e04ef3cb3fbe5368e7b17213db63cd427c64331064741df4d12f6b343fdaefcccc54f529702d6383a87b06b3595699aa07bb1889ac345ae5ba0f4e93f
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- message_bus_client_worker (0.4.0)
4
+ message_bus_client_worker (1.0.0)
5
5
  activesupport
6
6
  addressable
7
7
  excon
data/README.md CHANGED
@@ -38,14 +38,21 @@ MessageBusClientWorker.configure do |c|
38
38
  # }
39
39
  # }
40
40
  "https://etc.com" => {
41
- "/exchange_rates" => {
42
- processor: "ProcessExchangeRate",
43
- message_id: 0,
41
+ headers: {
42
+ "Authorization" => "Bearer #{ENV["MYTOKEN"]}",
44
43
  },
45
- "/messages" => { processor: "ProcessMessage" },
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
- "/errors" => { processor: "ProcessError" },
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`. If there is a running worker that has a connection open to the channel, a job will **not** be enqueued, thanks to [sidekiq-unique-jobs](https://github.com/mhenrixon/sidekiq-unique-jobs).
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
 
@@ -11,6 +11,7 @@ module MessageBusClientWorker
11
11
  ).reduce(
12
12
  Polling::GenerateClientId,
13
13
  Polling::GenerateURI,
14
+ execute(->(c) { c[:headers] = c[:subscriptions][:headers] }),
14
15
  Polling::GenerateParams,
15
16
  Polling::GetPayloads,
16
17
  iterate(:payloads, [
@@ -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 = c.subscriptions.each_with_object({}) do |sub, hash|
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
- response = Excon.post(c.uri, {
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
@@ -8,7 +8,7 @@ module MessageBusClientWorker
8
8
  executed do |c|
9
9
  payload = c.payload
10
10
  channel = payload["channel"]
11
- channel_config = c.subscriptions[channel]
11
+ channel_config = c.subscriptions[:channels][channel]
12
12
 
13
13
  next c if channel_config.nil?
14
14
 
@@ -1,3 +1,3 @@
1
1
  module MessageBusClientWorker
2
- VERSION = "0.4.0"
2
+ VERSION = "1.0.0"
3
3
  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.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: 2018-12-19 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config