action_subscriber 2.1.2 → 2.2.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 +4 -4
- data/bin/action_subscriber +17 -2
- data/lib/action_subscriber.rb +6 -5
- data/lib/action_subscriber/configuration.rb +21 -10
- data/lib/action_subscriber/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: a28cd2294784f1ac8991ef06765c5eb9f5ddc896
|
4
|
+
data.tar.gz: 8d61f891527ea6f8a2a51adbb9abe3a94d4b4b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78958b49c6479bdf1304a07254fddac253eefa71cdd009878c415a6d6f7341f6cf20ec8697c8ecdaf0ae7470256f9fd1fd8e53d64d0c65a2ec8017102b21568c
|
7
|
+
data.tar.gz: 5826fdc4484ce1940f7eeeae4db18ce2887f1d92b851778480a43e7be4bec944a6f3f42eec025bd5842077959fcd696a585c0710f2a9be536563cebc9f514df2
|
data/bin/action_subscriber
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
$ACTION_SUBSCRIBER_SERVER_MODE = true
|
4
|
+
|
3
5
|
require 'active_support'
|
4
6
|
require 'active_support/core_ext'
|
5
7
|
require 'thor'
|
8
|
+
require 'action_subscriber'
|
6
9
|
|
7
10
|
module ActionSubscriber
|
8
11
|
class CLI < ::Thor
|
@@ -23,12 +26,24 @@ module ActionSubscriber
|
|
23
26
|
BABOUDESC
|
24
27
|
|
25
28
|
def start
|
26
|
-
require options[:app]
|
27
|
-
|
28
29
|
$0 = "Action Subscriber server #{object_id}"
|
29
30
|
::ActionSubscriber.logger.info "Loading configuration..."
|
30
31
|
|
31
32
|
::ActionSubscriber::Configuration.configure_from_yaml_and_cli(options)
|
33
|
+
|
34
|
+
::ActionSubscriber.logger.info "Requiring app..."
|
35
|
+
|
36
|
+
require options[:app]
|
37
|
+
|
38
|
+
# We run these outside of lib/action_subscriber.rb because we need to load
|
39
|
+
# our railtie (Rails must be defined) before we can run our load hooks.
|
40
|
+
# When requiring action_subscriber as a client, these will be run
|
41
|
+
# automatically.
|
42
|
+
::ActionSubscriber.logger.info "Running load hooks..."
|
43
|
+
|
44
|
+
require "action_subscriber/railtie" if defined?(Rails)
|
45
|
+
::ActiveSupport.run_load_hooks(:action_subscriber, Base)
|
46
|
+
|
32
47
|
::ActionSubscriber.logger.info "Starting server..."
|
33
48
|
|
34
49
|
case ::ActionSubscriber.configuration.mode
|
data/lib/action_subscriber.rb
CHANGED
@@ -114,14 +114,18 @@ module ActionSubscriber
|
|
114
114
|
alias_method :config, :configuration
|
115
115
|
end
|
116
116
|
|
117
|
+
# Execution is delayed until after app loads when used with bin/action_subscriber
|
118
|
+
unless $ACTION_SUBSCRIBER_SERVER_MODE
|
119
|
+
::ActiveSupport.run_load_hooks(:action_subscriber, Base)
|
120
|
+
require "action_subscriber/railtie" if defined?(Rails)
|
121
|
+
end
|
122
|
+
|
117
123
|
# Initialize config object
|
118
124
|
config
|
119
125
|
|
120
126
|
# Intialize async publisher adapter
|
121
127
|
::ActionSubscriber::Publisher::Async.publisher_adapter
|
122
128
|
|
123
|
-
::ActiveSupport.run_load_hooks(:action_subscriber, Base)
|
124
|
-
|
125
129
|
##
|
126
130
|
# Private Implementation
|
127
131
|
#
|
@@ -144,11 +148,8 @@ module ActionSubscriber
|
|
144
148
|
end
|
145
149
|
end
|
146
150
|
private_class_method :default_routes
|
147
|
-
|
148
151
|
end
|
149
152
|
|
150
|
-
require "action_subscriber/railtie" if defined?(Rails)
|
151
|
-
|
152
153
|
at_exit do
|
153
154
|
::ActionSubscriber::Publisher::Async.publisher_adapter.shutdown!
|
154
155
|
::ActionSubscriber::RabbitConnection.publisher_disconnect!
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
1
3
|
module ActionSubscriber
|
2
4
|
class Configuration
|
3
5
|
attr_accessor :allow_low_priority_methods,
|
@@ -24,6 +26,8 @@ module ActionSubscriber
|
|
24
26
|
:times_to_pop,
|
25
27
|
:virtual_host
|
26
28
|
|
29
|
+
CONFIGURATION_MUTEX = ::Mutex.new
|
30
|
+
|
27
31
|
DEFAULTS = {
|
28
32
|
:allow_low_priority_methods => false,
|
29
33
|
:async_publisher => 'memory',
|
@@ -51,18 +55,25 @@ module ActionSubscriber
|
|
51
55
|
##
|
52
56
|
# Class Methods
|
53
57
|
#
|
54
|
-
def self.configure_from_yaml_and_cli(cli_options = {})
|
55
|
-
|
58
|
+
def self.configure_from_yaml_and_cli(cli_options = {}, reload = false)
|
59
|
+
CONFIGURATION_MUTEX.synchronize do
|
60
|
+
@configure_from_yaml_and_cli = nil if reload
|
61
|
+
@configure_from_yaml_and_cli ||= begin
|
62
|
+
env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["APP_ENV"] || "development"
|
56
63
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
64
|
+
yaml_config = {}
|
65
|
+
absolute_config_path = ::File.expand_path(::File.join("config", "action_subscriber.yml"))
|
66
|
+
if ::File.exists?(absolute_config_path)
|
67
|
+
yaml_config = ::YAML.load_file(absolute_config_path)[env]
|
68
|
+
end
|
62
69
|
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
::ActionSubscriber::Configuration::DEFAULTS.each_pair do |key, value|
|
71
|
+
setting = cli_options[key] || yaml_config[key.to_s]
|
72
|
+
::ActionSubscriber.config.__send__("#{key}=", setting) if setting
|
73
|
+
end
|
74
|
+
|
75
|
+
nil
|
76
|
+
end
|
66
77
|
end
|
67
78
|
end
|
68
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2016-02-
|
15
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|