message_bus_client_worker 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5673b34ade6dd5f7bf7ce503fb76e3167f421d260c3d5499b7865996b975d042
4
+ data.tar.gz: 728c1b77a4471e04b99c9df3d2da26f6b07413d476ed5a0351a21b76bc5b6902
5
+ SHA512:
6
+ metadata.gz: 80cebcc4826049b0d7261b1b554a44657e5b61375f342691390d2ba7c20f5f5c4ae8ad34a2a564821115b4bb66c65891f6ca560ce34ec922f3a548a264607725
7
+ data.tar.gz: 6888b78df0594aae1db838ba222983637e14e478e18c40078a5c2464e3ea46d05cd440cecb870e092a605c16008753c8b9ffc0cacb8284f98048cd04ed8a2f23
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/config.yml
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_script:
6
+ - cp spec/config.yml{.sample,}
7
+ - docker-compose up -d sidekiq chat
8
+ script: docker-compose run gem bundle exec rspec spec
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2018-08-07
8
+ ### Added
9
+ - Initial release
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ramon.tayag@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Dockerfile ADDED
@@ -0,0 +1,15 @@
1
+ FROM ruby:2.5.1
2
+
3
+ WORKDIR /gem
4
+
5
+ ENV BUNDLE_GEMFILE=/gem/Gemfile \
6
+ BUNDLE_JOBS=2 \
7
+ BUNDLE_PATH=/bundle
8
+
9
+ COPY Gemfile Gemfile.lock message_bus_client_worker.gemspec /gem/
10
+ COPY lib/message_bus_client_worker/version.rb /gem/lib/message_bus_client_worker/
11
+
12
+ RUN gem install bundler --no-ri --no-rdoc && \
13
+ bundle install --jobs 20 --retry 5
14
+
15
+ COPY . /gem
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in message_bus_client_worker.gemspec
6
+ gemspec
7
+
8
+ gem "pry-byebug"
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ message_bus_client_worker (0.1.0)
5
+ addressable
6
+ gem_config
7
+ http
8
+ light-service
9
+ sidekiq
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (5.2.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ addressable (2.5.2)
20
+ public_suffix (>= 2.0.2, < 4.0)
21
+ byebug (10.0.2)
22
+ coderay (1.1.2)
23
+ concurrent-ruby (1.0.5)
24
+ connection_pool (2.2.2)
25
+ diff-lcs (1.3)
26
+ domain_name (0.5.20180417)
27
+ unf (>= 0.0.5, < 1.0.0)
28
+ gem_config (0.3.1)
29
+ http (3.3.0)
30
+ addressable (~> 2.3)
31
+ http-cookie (~> 1.0)
32
+ http-form_data (~> 2.0)
33
+ http_parser.rb (~> 0.6.0)
34
+ http-cookie (1.0.3)
35
+ domain_name (~> 0.5)
36
+ http-form_data (2.1.1)
37
+ http_parser.rb (0.6.0)
38
+ i18n (1.0.1)
39
+ concurrent-ruby (~> 1.0)
40
+ light-service (0.11.0)
41
+ activesupport (>= 3.0)
42
+ method_source (0.9.0)
43
+ minitest (5.11.3)
44
+ pry (0.11.3)
45
+ coderay (~> 1.1.0)
46
+ method_source (~> 0.9.0)
47
+ pry-byebug (3.6.0)
48
+ byebug (~> 10.0)
49
+ pry (~> 0.10)
50
+ public_suffix (3.0.2)
51
+ rack (2.0.5)
52
+ rack-protection (2.0.3)
53
+ rack
54
+ rake (10.5.0)
55
+ redis (4.0.1)
56
+ rspec (3.7.0)
57
+ rspec-core (~> 3.7.0)
58
+ rspec-expectations (~> 3.7.0)
59
+ rspec-mocks (~> 3.7.0)
60
+ rspec-core (3.7.1)
61
+ rspec-support (~> 3.7.0)
62
+ rspec-expectations (3.7.0)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.7.0)
65
+ rspec-mocks (3.7.0)
66
+ diff-lcs (>= 1.2.0, < 2.0)
67
+ rspec-support (~> 3.7.0)
68
+ rspec-sidekiq (3.0.3)
69
+ rspec-core (~> 3.0, >= 3.0.0)
70
+ sidekiq (>= 2.4.0)
71
+ rspec-support (3.7.1)
72
+ sidekiq (5.1.3)
73
+ concurrent-ruby (~> 1.0)
74
+ connection_pool (~> 2.2, >= 2.2.0)
75
+ rack-protection (>= 1.5.0)
76
+ redis (>= 3.3.5, < 5)
77
+ thread_safe (0.3.6)
78
+ tzinfo (1.2.5)
79
+ thread_safe (~> 0.1)
80
+ unf (0.1.4)
81
+ unf_ext
82
+ unf_ext (0.0.7.5)
83
+ wait (0.5.3)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ activesupport
90
+ bundler (~> 1.16)
91
+ message_bus_client_worker!
92
+ pry-byebug
93
+ rake (~> 10.0)
94
+ rspec (~> 3.0)
95
+ rspec-sidekiq
96
+ wait
97
+
98
+ BUNDLED WITH
99
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ramon Tayag
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # MessageBusClientWorker
2
+
3
+ Subscribe to [MessageBus](https://github.com/SamSaffron/message_bus) using Sidekiq workers. This gem was borne out of the noisy logs and difficult in debugging using [message_bus-client](https://github.com/lowjoel/message_bus-client). This gem aims to:
4
+
5
+ - allow sane debugging by having thread-related code all over the calls to the MessageBus channel by relying on Sidekiq
6
+ - keep subscriptions to 1 per channel. With current options, every web server process would start a thread that listened to the MessageBus channels.
7
+ - do not unnecessarily add noise when starting the console like `rails console`
8
+ - recover from downtime by keeping track of the last message it processed per channel
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'message_bus_client_worker'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install message_bus_client_worker
25
+
26
+ ## Usage
27
+
28
+ Configure the gem in an initializer.
29
+
30
+ ```ruby
31
+ MessageBusClientWorker.configure do |c|
32
+ c.subscriptions = {
33
+ # Format is
34
+ # "https://domain.com" => {
35
+ # "/a_channel" => "AChannelPayloadProcessor",
36
+ # "/b_channel" => "BChannelPayloadProcessor",
37
+ # }
38
+ "https://etc.com" => {
39
+ "/exchange_rates" => "ProcessExchangeRate",
40
+ "/messages" => "ProcessMessage",
41
+ },
42
+ "https://someotherdomain.com" => {
43
+ "/errors" => "ProcessError",
44
+ },
45
+ }
46
+ end
47
+ ```
48
+
49
+ ```ruby
50
+ class ProcessMessage
51
+ def self.call(payload)
52
+ payload # {"global_id":1478,"message_id":3,"channel":"/message","data":{"data":"hey","name":"joe"}}
53
+ end
54
+ end
55
+ ```
56
+
57
+ To keep the subscription alive if the worker dies or during restarts, use a gem like [sidekiq-cron](https://github.com/ondrejbartas/sidekiq-cron) and enqueue the `MessageBusClientWorker::EnqueuingWorker`:
58
+
59
+ ```yml
60
+ message_bus_client_worker:
61
+ cron: "*/10 * * * * *"
62
+ class: "MessageBusClientWorker::EnqueuingWorker"
63
+ ```
64
+
65
+ Note: will probably want to [change the poll interval of Sidekiq](https://github.com/ondrejbartas/sidekiq-cron#under-the-hood) if you will choose a granularity smaller than 30 seconds.
66
+
67
+ ```ruby
68
+ Sidekiq.options[:poll_interval] = 10
69
+ ```
70
+
71
+ ## How it Works
72
+
73
+ 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).
74
+
75
+ `SubscriptionWorker` will open a connection to the server, and try the following (not all have been implemented):
76
+
77
+ - [ ] long-poll with streaming, or if streaming is not supported...
78
+ - [ ] long-poll, or if long-polling is not supported...
79
+ - [x] short-poll
80
+
81
+ ## Development
82
+
83
+ Copy the config and edit (if necessary)
84
+
85
+ ```sh
86
+ cp spec/config.yml{.sample,}
87
+ docker-compose up sidekiq chat
88
+ rspec spec
89
+ ```
90
+
91
+ ## Contributing
92
+
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bloom-solutions/message_bus_client_worker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
94
+
95
+ ## License
96
+
97
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
98
+
99
+ ## Code of Conduct
100
+
101
+ Everyone interacting in the MessageBusClientWorker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bloom-solutions/message_bus_client_worker/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "message_bus_client_worker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,47 @@
1
+ version: "3.2"
2
+ services:
3
+ redis:
4
+ image: redis:4.0.10
5
+ ports:
6
+ - "6379:6379"
7
+ gem:
8
+ build: .
9
+ command: bundle exec rspec spec
10
+ depends_on:
11
+ - redis
12
+ - sidekiq
13
+ - chat
14
+ environment:
15
+ - REDIS_URL=redis://redis:6379
16
+ volumes:
17
+ - ./:/gem
18
+ - gem_bundle:/bundle
19
+ chat:
20
+ build: spec/images/chat_server
21
+ command: bundle exec puma puma.ru
22
+ ports:
23
+ - "9292:9292"
24
+ volumes:
25
+ - chat_bundle:/bundle
26
+ sidekiq:
27
+ build: .
28
+ command: bundle exec sidekiq -r /gem/spec/support/sidekiq.rb
29
+ depends_on:
30
+ - redis
31
+ environment:
32
+ - REDIS_URL=redis://redis:6379
33
+ volumes:
34
+ - ./:/gem
35
+ - gem_bundle:/bundle
36
+ gem_bundle:
37
+ image: busybox
38
+ volumes:
39
+ - /bundle
40
+ chat_bundle:
41
+ image: busybox
42
+ volumes:
43
+ - /bundle
44
+ volumes:
45
+ redis:
46
+ gem_bundle:
47
+ chat_bundle:
@@ -0,0 +1,21 @@
1
+ module MessageBusClientWorker
2
+ class Poll
3
+
4
+ extend LightService::Organizer
5
+
6
+ def self.call(host, subscriptions, long)
7
+ with(
8
+ host: host,
9
+ subscriptions: subscriptions,
10
+ long: long,
11
+ ).reduce(
12
+ Polling::GenerateClientId,
13
+ Polling::GenerateURI,
14
+ Polling::GenerateParams,
15
+ Polling::GetMessages,
16
+ Polling::ProcessMessages,
17
+ )
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GenLastIdKey
4
+
5
+ def self.call(host, channel)
6
+ [host, channel].join("-")
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GenerateClientId
4
+ extend LightService::Action
5
+
6
+ promises :client_id
7
+
8
+ executed do |c|
9
+ c.client_id = SecureRandom.uuid
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GenerateParams
4
+ extend LightService::Action
5
+
6
+ expects :host, :subscriptions
7
+ promises :params, :form_params
8
+
9
+ executed do |c|
10
+ c.params = { dlp: 't' }
11
+ c.form_params = c.subscriptions.each_with_object({}) do |sub, hash|
12
+ hash[sub[0]] = GetLastId.(c.host, sub[0])
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GenerateURI
4
+ extend LightService::Action
5
+
6
+ expects :host, :client_id
7
+ promises :uri
8
+
9
+ executed do |c|
10
+ uri = Addressable::URI.parse(c.host)
11
+ uri.path = "/message-bus/#{c.client_id}/poll"
12
+ c.uri = uri.to_s
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GetLastId
4
+
5
+ def self.call(host, channel)
6
+ hash_key = GenLastIdKey.(host, channel)
7
+
8
+ id = Sidekiq.redis do |r|
9
+ r.hget(SetLastId::CHANNEL_INDICES_NAME, hash_key)
10
+ end
11
+
12
+ id || "0"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class GetMessages
4
+ extend LightService::Action
5
+
6
+ expects :params, :form_params, :uri
7
+ promises :messages
8
+
9
+ executed do |c|
10
+ body = HTTP.post(c.uri, params: c.params, form: c.form_params).body
11
+ c.messages = JSON.parse(body.to_s)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class ProcessMessages
4
+ extend LightService::Action
5
+
6
+ expects :host, :subscriptions, :messages
7
+
8
+ executed do |c|
9
+ c.messages.each do |message|
10
+ channel = message["channel"]
11
+ processor_class = Kernel.const_get(c.subscriptions[channel])
12
+
13
+ SetLastId.(c.host, channel, message["message_id"])
14
+ processor_class.(message["data"])
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ module MessageBusClientWorker
2
+ module Polling
3
+ class SetLastId
4
+
5
+ CHANNEL_INDICES_NAME = "message_bus_client_worker_channel_indices".freeze
6
+ def self.call(host, channel, message_id)
7
+ hash_key = GenLastIdKey.(host, channel)
8
+
9
+ id = Sidekiq.redis do |r|
10
+ r.hset(CHANNEL_INDICES_NAME, hash_key, message_id)
11
+ end
12
+
13
+ id || "0"
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module MessageBusClientWorker
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ module MessageBusClientWorker
2
+ class EnqueuingWorker
3
+
4
+ include ::Sidekiq::Worker
5
+ sidekiq_options retry: false
6
+
7
+ def perform
8
+ MessageBusClientWorker.configuration.subscriptions.each do |host, subs|
9
+ SubscriptionWorker.perform_async(host, subs)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module MessageBusClientWorker
2
+ class SubscriptionWorker
3
+
4
+ include Sidekiq::Worker
5
+ sidekiq_options retry: false
6
+
7
+ def perform(host, subscriptions, long=false)
8
+ Poll.(host, subscriptions, long)
9
+ end
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,28 @@
1
+ require "addressable"
2
+ require "gem_config"
3
+ require "http"
4
+ require "light-service"
5
+ require "securerandom"
6
+ require "sidekiq"
7
+ require "message_bus_client_worker/version"
8
+ require "message_bus_client_worker/workers/enqueuing_worker"
9
+ require "message_bus_client_worker/workers/subscription_worker"
10
+ require "message_bus_client_worker/services/polling/gen_last_id_key"
11
+ require "message_bus_client_worker/services/polling/get_last_id"
12
+ require "message_bus_client_worker/services/polling/set_last_id"
13
+ require "message_bus_client_worker/services/polling/generate_client_id"
14
+ require "message_bus_client_worker/services/polling/generate_uri"
15
+ require "message_bus_client_worker/services/polling/generate_params"
16
+ require "message_bus_client_worker/services/polling/get_messages"
17
+ require "message_bus_client_worker/services/polling/process_messages"
18
+ require "message_bus_client_worker/services/poll"
19
+
20
+ module MessageBusClientWorker
21
+
22
+ include GemConfig::Base
23
+
24
+ with_configuration do
25
+ has :subscriptions, classes: Hash
26
+ end
27
+
28
+ end
@@ -0,0 +1,45 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "message_bus_client_worker/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "message_bus_client_worker"
7
+ spec.version = MessageBusClientWorker::VERSION
8
+ spec.authors = ["Ramon Tayag"]
9
+ spec.email = ["ramon.tayag@gmail.com"]
10
+
11
+ spec.summary = %q{Subscribe to MessageBus using Sidekiq workers}
12
+ spec.homepage = "https://github.com/bloom-solutions/message_bus_client_worker"
13
+ spec.license = "MIT"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "gem_config"
34
+ spec.add_dependency "sidekiq"
35
+ spec.add_dependency "http"
36
+ spec.add_dependency "addressable"
37
+ spec.add_dependency "light-service"
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.16"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "rspec-sidekiq"
43
+ spec.add_development_dependency "activesupport"
44
+ spec.add_development_dependency "wait"
45
+ end
metadata ADDED
@@ -0,0 +1,228 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: message_bus_client_worker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ramon Tayag
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gem_config
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: light-service
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.16'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.16'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-sidekiq
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: activesupport
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: wait
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description:
168
+ email:
169
+ - ramon.tayag@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".ruby-version"
177
+ - ".travis.yml"
178
+ - CHANGELOG.md
179
+ - CODE_OF_CONDUCT.md
180
+ - Dockerfile
181
+ - Gemfile
182
+ - Gemfile.lock
183
+ - LICENSE.txt
184
+ - README.md
185
+ - Rakefile
186
+ - bin/console
187
+ - bin/setup
188
+ - docker-compose.yml
189
+ - lib/message_bus_client_worker.rb
190
+ - lib/message_bus_client_worker/services/poll.rb
191
+ - lib/message_bus_client_worker/services/polling/gen_last_id_key.rb
192
+ - lib/message_bus_client_worker/services/polling/generate_client_id.rb
193
+ - lib/message_bus_client_worker/services/polling/generate_params.rb
194
+ - lib/message_bus_client_worker/services/polling/generate_uri.rb
195
+ - lib/message_bus_client_worker/services/polling/get_last_id.rb
196
+ - lib/message_bus_client_worker/services/polling/get_messages.rb
197
+ - lib/message_bus_client_worker/services/polling/process_messages.rb
198
+ - lib/message_bus_client_worker/services/polling/set_last_id.rb
199
+ - lib/message_bus_client_worker/version.rb
200
+ - lib/message_bus_client_worker/workers/enqueuing_worker.rb
201
+ - lib/message_bus_client_worker/workers/subscription_worker.rb
202
+ - message_bus_client_worker.gemspec
203
+ homepage: https://github.com/bloom-solutions/message_bus_client_worker
204
+ licenses:
205
+ - MIT
206
+ metadata:
207
+ allowed_push_host: https://rubygems.org
208
+ post_install_message:
209
+ rdoc_options: []
210
+ require_paths:
211
+ - lib
212
+ required_ruby_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ">="
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ required_rubygems_version: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ requirements: []
223
+ rubyforge_project:
224
+ rubygems_version: 2.7.7
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Subscribe to MessageBus using Sidekiq workers
228
+ test_files: []