ons_on_rails 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 714b9a4922cdf2042774c2df60a2e52d21b860be
4
- data.tar.gz: 4e4f6e2c854bb8bdad33e8fa16b9f2810a17f699
3
+ metadata.gz: af7da168c8fa0d556d0dd9a19d35847d76381f18
4
+ data.tar.gz: dec0d5bb710cfb8d8907171a826c356f5510ad98
5
5
  SHA512:
6
- metadata.gz: ef63df67d22479ed5df51393df3b57cbb1c13a2dfb35edd8f531a54548a6e5e43d1b03efd88994a6018949a077b367eed79e4231c952752b4211dc87dbfbb5ff
7
- data.tar.gz: ce4a4b7c47ff4f2ef3a659230fa68af64172b1a5670043148812ce9bd62177d48adb1e86118238d7199577fb448c67e1934fa464d408aa7235cfd42ef6340940
6
+ metadata.gz: e267fd2ab4ceee0581f95c65ce44f5383b65bb6159d4e58ecfc61b7161c298c063cbfa1cefce90837cc1ed0f66cd9d2f463fc3d0ca0793b42dbb58718e4e8457
7
+ data.tar.gz: a219dabb4b77d403bdcc3928cc6725c39ae055c53d62bb9c0a87e092db915aacabefeeeea5066b91984dfc970fe6b8a4c44707786baf320566fd2a83153c4068
@@ -60,7 +60,19 @@ module OnsOnRails
60
60
  # @param subscriber_class_name [Symbol, String] the subscriber's class name
61
61
  # @param app_path [String] the Rails root directory path
62
62
  def self.run_subscriber_as_a_daemon(subscriber_class_name, app_path)
63
- options = {
63
+ options = { daemon_name: subscriber_class_name.to_s.underscore }
64
+ run_multi_subscriber_as_a_daemon(Array(subscriber_class_name), app_path, options)
65
+ end
66
+
67
+ # Run multi-subscribers as a separate process.
68
+ #
69
+ # @param subscriber_class_name_array [Array<Symbol, String>] the array of subscriber's class name
70
+ # @param app_path [String] the Rails root directory path
71
+ # @param options [Hash]
72
+ # @option options [String] :daemon_name ('subscribers') The name of the daemon. This will be used to contruct the name of the pid files and log files
73
+ def self.run_multi_subscriber_as_a_daemon(subscriber_class_name_array, app_path, options = {})
74
+ daemon_name = options.fetch(:daemon_name, 'subscribers')
75
+ daemon_options = {
64
76
  backtrace: true,
65
77
  dir_mode: :normal,
66
78
  dir: File.join(app_path, 'tmp', 'pids'),
@@ -68,18 +80,20 @@ module OnsOnRails
68
80
  log_output: true
69
81
  }
70
82
 
71
- subscriber_class_name = subscriber_class_name.to_s.camelize
72
- Daemons.run_proc(subscriber_class_name.underscore, options) do
83
+ Daemons.run_proc(daemon_name, daemon_options) do
73
84
  require File.join(app_path, 'config', 'environment')
74
85
  require 'ons' unless defined?(Ons)
75
86
 
76
- subscriber_class = subscriber_class_name.constantize
77
- subscriber_class.check_subscriber_definition!
87
+ subscriber_class_name_array.each do |subscriber_class_name|
88
+ subscriber_class_name = subscriber_class_name.to_s.camelize
89
+ subscriber_class = subscriber_class_name.constantize
90
+ subscriber_class.check_subscriber_definition!
78
91
 
79
- options = subscriber_class.ons_options
80
- Ons::Consumer.new(options.fetch(:access_key), options.fetch(:secret_key), options.fetch(:consumer_id))
81
- .subscribe(options.fetch(:topic), options.fetch(:tag), &->(message) { subscriber_class.consume(message) })
82
- .start
92
+ options = subscriber_class.ons_options
93
+ Ons::Consumer.new(options.fetch(:access_key), options.fetch(:secret_key), options.fetch(:consumer_id))
94
+ .subscribe(options.fetch(:topic), options.fetch(:tag), &->(message) { subscriber_class.consume(message) })
95
+ .start
96
+ end
83
97
 
84
98
  Ons.register_cleanup_hooks
85
99
  Ons.loop_forever
@@ -1,3 +1,3 @@
1
1
  module OnsOnRails
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ons_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - souche
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2016-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons