ons_on_rails 1.0.1 → 1.0.2
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 +4 -4
- data/lib/ons_on_rails.rb +23 -9
- data/lib/ons_on_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af7da168c8fa0d556d0dd9a19d35847d76381f18
|
4
|
+
data.tar.gz: dec0d5bb710cfb8d8907171a826c356f5510ad98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e267fd2ab4ceee0581f95c65ce44f5383b65bb6159d4e58ecfc61b7161c298c063cbfa1cefce90837cc1ed0f66cd9d2f463fc3d0ca0793b42dbb58718e4e8457
|
7
|
+
data.tar.gz: a219dabb4b77d403bdcc3928cc6725c39ae055c53d62bb9c0a87e092db915aacabefeeeea5066b91984dfc970fe6b8a4c44707786baf320566fd2a83153c4068
|
data/lib/ons_on_rails.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
77
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
data/lib/ons_on_rails/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|