nats_listener 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96b0fa2aa1846df31885de384e2658ce62acd45b497fcb0f6a09adc7e95bb882
4
+ data.tar.gz: b1e96cde42f076406bb7d1dfe29f838d41564e0b399c87dcb94f448b192a7092
5
+ SHA512:
6
+ metadata.gz: ddd0e1f3cfed53b7d53f3306af66435e9fc8e627a483e015e677736988d5482f8775ea60b1c37efc65da1a65eda609d16308840dd43b0334b9a13b757529635b
7
+ data.tar.gz: 9cf90ef38e3c372b7eb13db98f804a7fbfaec51f438716c7ec1fbfc35b9c663ba5a7dfdab6874582aa50450c261e05f7769ad7ec240aa75f1d270cf84c3af1a3
@@ -0,0 +1,58 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ # specify the version you desire here
6
+ - image: circleci/ruby:2.5.1
7
+
8
+
9
+ - image: nats
10
+ command: "-DV"
11
+ ports:
12
+ - "4222:4222"
13
+
14
+ - image: nats-streaming
15
+ command: "--store memory --cluster_id cluster_name -p 4223"
16
+ ports:
17
+ - "4223:4222"
18
+ working_directory: ~/repo
19
+
20
+ steps:
21
+ - checkout
22
+
23
+ # Download and cache dependencies
24
+ - restore_cache:
25
+ keys:
26
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
27
+ # fallback to using the latest cache if no exact match is found
28
+ - v1-dependencies-
29
+
30
+ - run:
31
+ name: install dependencies
32
+ command: |
33
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
34
+
35
+ - save_cache:
36
+ paths:
37
+ - ./vendor/bundle
38
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
39
+
40
+ # run tests!
41
+ - run:
42
+ name: run tests
43
+ command: |
44
+ mkdir /tmp/test-results
45
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
46
+
47
+ bundle exec rspec --format progress \
48
+ --format RspecJunitFormatter \
49
+ --out /tmp/test-results/rspec.xml \
50
+ --format progress \
51
+ $TEST_FILES
52
+
53
+ # collect reports
54
+ - store_test_results:
55
+ path: /tmp/test-results
56
+ - store_artifacts:
57
+ path: /tmp/test-results
58
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.reek.yml ADDED
@@ -0,0 +1,14 @@
1
+ detectors:
2
+ NilCheck:
3
+ enabled: false
4
+
5
+ TooManyStatements:
6
+ max_statements: 10
7
+
8
+ TooManyInstanceVariables:
9
+ enabled: false
10
+
11
+ IrresponsibleModule:
12
+ enabled: false
13
+ UtilityFunction:
14
+ enabled: false
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ Exclude:
4
+ - 'gemfile'
5
+ - 'bin/**'
6
+ - 'exe/**'
7
+ - 'Gemfile'
8
+ - 'Rakefile'
9
+ - '*.gemspec'
10
+ - 'spec/**/*.rb'
11
+ Metrics/LineLength:
12
+ Enabled: false
13
+ Style/TrivialAccessors:
14
+ Enabled: false
@@ -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 gophan1992@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/Gemfile ADDED
@@ -0,0 +1,10 @@
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 nats-listener.gemspec
6
+ gemspec
7
+ gem 'nats_listener_core'
8
+ gem 'codecov', :require => false, :group => :test
9
+ gem 'reek', require: false, group: :test
10
+ gem 'rubocop', require: false, group: :test
data/Gemfile.lock ADDED
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nats_listener (0.1.1)
5
+ nats-pure (~> 0.5)
6
+ nats_listener_core (0.1.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.0)
12
+ axiom-types (0.1.1)
13
+ descendants_tracker (~> 0.0.4)
14
+ ice_nine (~> 0.11.0)
15
+ thread_safe (~> 0.3, >= 0.3.1)
16
+ codeclimate-engine-rb (0.4.1)
17
+ virtus (~> 1.0)
18
+ codecov (0.1.14)
19
+ json
20
+ simplecov
21
+ url
22
+ coercible (1.0.0)
23
+ descendants_tracker (~> 0.0.1)
24
+ descendants_tracker (0.0.4)
25
+ thread_safe (~> 0.3, >= 0.3.1)
26
+ diff-lcs (1.3)
27
+ docile (1.3.1)
28
+ equalizer (0.0.11)
29
+ ice_nine (0.11.2)
30
+ jaro_winkler (1.5.2)
31
+ json (2.2.0)
32
+ kwalify (0.7.2)
33
+ nats-pure (0.5.0)
34
+ parallel (1.17.0)
35
+ parser (2.6.3.0)
36
+ ast (~> 2.4.0)
37
+ psych (3.1.0)
38
+ rainbow (3.0.0)
39
+ rake (10.5.0)
40
+ reek (5.4.0)
41
+ codeclimate-engine-rb (~> 0.4.0)
42
+ kwalify (~> 0.7.0)
43
+ parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
44
+ psych (~> 3.1.0)
45
+ rainbow (>= 2.0, < 4.0)
46
+ rspec (3.8.0)
47
+ rspec-core (~> 3.8.0)
48
+ rspec-expectations (~> 3.8.0)
49
+ rspec-mocks (~> 3.8.0)
50
+ rspec-core (3.8.0)
51
+ rspec-support (~> 3.8.0)
52
+ rspec-expectations (3.8.3)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.8.0)
55
+ rspec-mocks (3.8.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.8.0)
58
+ rspec-support (3.8.0)
59
+ rspec_junit_formatter (0.4.1)
60
+ rspec-core (>= 2, < 4, != 2.12.0)
61
+ rubocop (0.70.0)
62
+ jaro_winkler (~> 1.5.1)
63
+ parallel (~> 1.10)
64
+ parser (>= 2.6)
65
+ rainbow (>= 2.2.2, < 4.0)
66
+ ruby-progressbar (~> 1.7)
67
+ unicode-display_width (>= 1.4.0, < 1.7)
68
+ ruby-progressbar (1.10.0)
69
+ simplecov (0.16.1)
70
+ docile (~> 1.1)
71
+ json (>= 1.8, < 3)
72
+ simplecov-html (~> 0.10.0)
73
+ simplecov-html (0.10.2)
74
+ thread_safe (0.3.6)
75
+ unicode-display_width (1.6.0)
76
+ url (0.3.2)
77
+ virtus (1.0.5)
78
+ axiom-types (~> 0.1)
79
+ coercible (~> 1.0)
80
+ descendants_tracker (~> 0.0, >= 0.0.3)
81
+ equalizer (~> 0.0, >= 0.0.9)
82
+
83
+ PLATFORMS
84
+ ruby
85
+
86
+ DEPENDENCIES
87
+ bundler (~> 1.16)
88
+ codecov
89
+ nats_listener!
90
+ nats_listener_core
91
+ rake (~> 10.0)
92
+ reek
93
+ rspec (~> 3.0)
94
+ rspec_junit_formatter (= 0.4.1)
95
+ rubocop
96
+
97
+ BUNDLED WITH
98
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Igor Pavlov
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,112 @@
1
+ # NatsListener
2
+
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8d3fc10f0adfda052efb/maintainability)](https://codeclimate.com/github/BEaStia/nats_listener/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/8d3fc10f0adfda052efb/test_coverage)](https://codeclimate.com/github/BEaStia/nats_listener/test_coverage)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'nats_listener'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install nats_listener
21
+
22
+ ## Usage
23
+
24
+ For usage in your project we offer:
25
+
26
+ 1. Create `initializer.rb` or manually call `NatsListener.current.establish_connection(service_name: [YOUR SERVICE NAME], servers: [NATS_SERVERS_URLS])`
27
+ 2. For publishing you can use `NatsListener.current.publish` serializing message with two strategies(`protobuf` and `json`).
28
+ Json strategy is proposed in [https://github.com/beastia/nats_listener](nats_listener). Protobuf strategy is included into [https://github.com/beastia/nats_streaming_listener](nats_streming_listener).
29
+ 3. For receiving messages we offer subscribers
30
+
31
+ #### Protobuf strategy
32
+ ```ruby
33
+ 2.3.3 :006 > require 'nats_streaming_listener'
34
+ => true
35
+ 2.3.3 :006 > m = NatsStreaming::NatsMessage.new(sender_service_name: 'ololo', receiver_action_name: 'ololo1', receiver_action_parameters:[1,2,3].map(&:to_s), message_timestamp: Time.now.utc.to_i, transaction_id: 'unique')
36
+ => #<NatsListener::NatsMessage sender_service_name="ololo" receiver_action_name="ololo1" receiver_action_parameters=["1", "2", "3"] message_timestamp=1538902717 transaction_id="unique">
37
+ 2.3.3 :007 > m.serialize
38
+ => "\n\x05ololo\x12\x06ololo1\x1A\x011\x1A\x012\x1A\x013 \xBD\x95\xE7\xDD\x05*\x06unique"
39
+ ```
40
+
41
+ #### Json strategy
42
+
43
+ ```ruby
44
+ 2.3.3 :009 > m = NatsListener::Message.new({action: 'ololo'})
45
+ => #<NatsListener::Message:0x007ff1869a3628 @message={:publisher=>nil, :timestamp=>2018-10-07 09:00:29 UTC, :message_id=>"7dfc4de9-d920-4cc1-8cfe-5e85f7fb855d", :data=>{:action=>"ololo"}}>
46
+ 2.3.3 :010 > m.to_json
47
+ => "{\"publisher\":service1,\"timestamp\":\"2018-10-07T09:00:29.133Z\",\"message_id\":\"7dfc4de9-d920-4cc1-8cfe-5e85f7fb855d\",\"data\":{\"action\":\"ololo\"}}"
48
+ ```
49
+
50
+ ### Creating client
51
+ ```ruby
52
+ NatsListener::Client.current = NatsListener::Client.new(
53
+ logger: Ougai::Logger.new(STDOUT),
54
+ skip: false,
55
+ catch_errors: true,
56
+ catch_provider: Rollbar
57
+ )
58
+ ```
59
+ All arguments are optional.
60
+ `logger` - logger that you can pass to application. It will be called to debug messages.
61
+ `skip` - skip calls. Useful for tests
62
+ `catch_errors` - catch errors, log them and pass to `catch_provider`
63
+ `catch_provider` - provider that is called when error occurs, e.g. Rollbar.
64
+
65
+ ### Subscribers
66
+
67
+ For using subscribers we offer one quite simple way:
68
+ 1. Create `subscribers` folder.
69
+ 2. Create your own subscriber derived from `NatsListener::Subscriber`
70
+ 3. Load and subscribe all subscribers, e.g.
71
+ ```ruby
72
+ NatsListener::Client.current = NatsListener::Client.new(
73
+ logger: Ougai::Logger.new(STDOUT),
74
+ skip: false,
75
+ catch_errors: true,
76
+ catch_provider: Rollbar
77
+ )
78
+ NatsListener::Client.current.establish_connection(service_name: [YOUR SERVICE NAME], servers: [NATS_SERVERS_URLS])
79
+ path = Rails.root.join('app', 'subscribers', '*.rb')
80
+ Dir.glob(path) do |entry|
81
+ entry.split('/').last.split('.').first.camelize.constantize.new.subscribe
82
+ end
83
+ ```
84
+ 4. ???
85
+ 5. PROFIT
86
+
87
+ ### NB!
88
+ Right now nats functionality is proved to work aside of Puma workers because of the conflicts between `puma` and `nats-pure` gems.
89
+
90
+
91
+ # TODO:
92
+ 1. Add nats-streaming subscribers
93
+ 2. Add usage of nats-streaming for calls
94
+
95
+
96
+ ## Development
97
+
98
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
99
+
100
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
101
+
102
+ ## Contributing
103
+
104
+ Bug reports and pull requests are welcome on GitHub at https://github.com/beastia/nats_listener. 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.
105
+
106
+ ## License
107
+
108
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
109
+
110
+ ## Code of Conduct
111
+
112
+ Everyone interacting in the NatsListener project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/beastia/nats_listener/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 "nats_listener"
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,8 @@
1
+ package NatsListener;
2
+ message NatsMessage {
3
+ optional string sender_service_name = 1;
4
+ optional string receiver_action_name = 2;
5
+ repeated string receiver_action_parameters = 3;
6
+ optional int64 message_timestamp = 4;
7
+ optional string transaction_id = 5;
8
+ }
data/exe/nats_listener ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "nats_listener"
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nats/io/client'
4
+ require 'nats_listener_core'
5
+
6
+ module NatsListener
7
+ # Client for nats implementation
8
+ class Client < NatsListenerCore::AbstractClient
9
+ # Use this opts:
10
+ # @!attribute :logger - logger used in this service
11
+ # @!attribute :skip - flag attribute used to skip connections(useful for testing)
12
+ # @!attribute :catch_errors - used to catch errors around subscribers/connections(be careful with it!)
13
+ # @!attribute :catch_provider - this class will be called with catch_provider.error(e)
14
+ # @!attribute :disable_nats - if something is passed to that attribute - nats won't be initialized
15
+
16
+ def initialize(opts = {})
17
+ @nats = ::NATS::IO::Client.new unless opts[:disable_nats] # Create nats client
18
+ @logger = NatsListenerCore::ClientLogger.new(opts)
19
+ @skip = opts[:skip] || false
20
+ @client_catcher = NatsListenerCore::ClientCatcher.new(opts)
21
+ end
22
+
23
+ # @!method Establish connection with nats server
24
+ # @!attribute :service_name - Name of current service
25
+ # @!attribute :nats - configuration of nats service
26
+ def establish_connection(opts)
27
+ return if skip
28
+
29
+ @config = opts.to_h
30
+ begin
31
+ @nats.connect(config) # Connect nats to provided configuration
32
+ true
33
+ rescue StandardError => exception
34
+ log(action: :connection_failed, message: exception)
35
+ false
36
+ end
37
+ end
38
+
39
+ def request(subject, message, opts = {})
40
+ with_connection do
41
+ log(action: :request, message: message)
42
+ nats.request(subject, message, opts)
43
+ end
44
+ end
45
+
46
+ def reestablish_connection
47
+ establish_connection(config) if nats&.status.to_i.zero?
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatsListener
4
+ # Message class offered to be used with json serialization
5
+ class Message
6
+ attr_reader :message
7
+
8
+ def initialize(data)
9
+ @message = build_message(data)
10
+ end
11
+
12
+ def to_json
13
+ message.to_json
14
+ end
15
+
16
+ private
17
+
18
+ def build_message(data)
19
+ {
20
+ publisher: NatsListener::Client.current.service_name,
21
+ timestamp: Time.now.utc,
22
+ message_id: SecureRandom.uuid,
23
+ data: data
24
+ }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nats_listener_core'
4
+
5
+ module NatsListener
6
+ # Base subscriber using nats
7
+ class Subscriber < NatsListenerCore::AbstractSubscriber
8
+ # It's just a small example of subscriber usage:
9
+ #
10
+ # class TestSubscriber < Subscriber
11
+ # subject 'test'
12
+ # count 1
13
+ #
14
+ # def call(msg, reply, subject)
15
+ # p "#{msg} #{subject}"
16
+ # end
17
+ # end
18
+ #
19
+ # Then we execute
20
+ # Clients::Nats::Client.instance.publish('test', 'Hello, World')
21
+ # And receive 'Hello, World test'
22
+ # Next publish of this message won't show anything
23
+ #
24
+ class << self
25
+ def client
26
+ NatsListener::Client.current
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NatsListener
4
+ VERSION = '0.1.1'
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'nats_listener/version'
4
+ require 'nats_listener/client'
5
+ require 'nats_listener/subscriber'
6
+ require 'nats_listener/message'
7
+
8
+ # Gem for making interaction with nats easier
9
+ module NatsListener
10
+ end
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nats_listener/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nats_listener"
8
+ spec.version = NatsListener::VERSION
9
+ spec.authors = ["Igor Pavlov"]
10
+ spec.email = ["gophan1992@gmail.com"]
11
+
12
+ spec.summary = %q{
13
+ This gem is used to simplify interaction between big applications/services via nats.
14
+ }
15
+ spec.description = %q{
16
+ Once upon a time in faraway company three developers decided to use nats for messaging between services.
17
+ One of them started to integrate nats, met some problems, was fighting with them and as a result he had created this gem.
18
+ This gem can help you to integrate nats and simplify its usage.
19
+ }
20
+ spec.homepage = "https://github.com/beastia/nats_listener"
21
+ spec.license = "MIT"
22
+
23
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
24
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
25
+ if spec.respond_to?(:metadata)
26
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
27
+ else
28
+ raise "RubyGems 2.0 or newer is required to protect against " \
29
+ "public gem pushes."
30
+ end
31
+
32
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
33
+ f.match(%r{^(test|spec|features)/})
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
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_junit_formatter', '0.4.1'
43
+ spec.add_dependency 'nats-pure', '~> 0.5'
44
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nats_listener
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Igor Pavlov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: nats-pure
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.5'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
83
+ description: "\n Once upon a time in faraway company three developers decided to
84
+ use nats for messaging between services.\n One of them started to integrate nats,
85
+ met some problems, was fighting with them and as a result he had created this gem.\n
86
+ \ This gem can help you to integrate nats and simplify its usage.\n "
87
+ email:
88
+ - gophan1992@gmail.com
89
+ executables:
90
+ - nats_listener
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".circleci/config.yml"
95
+ - ".gitignore"
96
+ - ".reek.yml"
97
+ - ".rspec"
98
+ - ".rubocop.yml"
99
+ - CODE_OF_CONDUCT.md
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE.txt
103
+ - README.md
104
+ - Rakefile
105
+ - bin/console
106
+ - bin/setup
107
+ - definitions/nats_listener/nats_message.proto
108
+ - exe/nats_listener
109
+ - lib/nats_listener.rb
110
+ - lib/nats_listener/client.rb
111
+ - lib/nats_listener/message.rb
112
+ - lib/nats_listener/subscriber.rb
113
+ - lib/nats_listener/version.rb
114
+ - nats_listener.gemspec
115
+ homepage: https://github.com/beastia/nats_listener
116
+ licenses:
117
+ - MIT
118
+ metadata:
119
+ allowed_push_host: https://rubygems.org
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubygems_version: 3.0.3
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: This gem is used to simplify interaction between big applications/services
139
+ via nats.
140
+ test_files: []