coney_island 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coney_island/submitter.rb +29 -27
- data/lib/coney_island/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: c56c9ef5e0a701dbf1b5dc6d574158eb603c5b39
|
4
|
+
data.tar.gz: 78a9a731b07471b9591b43774805622601b6fc66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcac6ce63736e212e822371306d7a4d57b5d0b5571f8716086d8d2d725f7846424b936e554593df95c56c2af1bd5912359ca6e5946ce40a905adae74ab44a083
|
7
|
+
data.tar.gz: f3fb209da6ffc4acec4ba8921b1523931f426e6bbdef62f9800562981bc14fecfde5ab7453da8f9bf0fdd295a45f5f42c7c72a7dea8e3f9e125cbac766435702
|
@@ -21,9 +21,7 @@ module ConeyIsland
|
|
21
21
|
if @run_inline
|
22
22
|
self.handle_publish(args)
|
23
23
|
else
|
24
|
-
EventMachine.next_tick do
|
25
24
|
self.handle_publish(args)
|
26
|
-
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -52,28 +50,34 @@ module ConeyIsland
|
|
52
50
|
|
53
51
|
def self.handle_publish(args)
|
54
52
|
self.handle_connection unless @run_inline
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
53
|
+
if :all_cached_jobs == args
|
54
|
+
RequestStore.store[:jobs].delete_if do |job_args|
|
55
|
+
self.publish_job(job_args)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
self.publish_job(args)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.publish_job(args)
|
63
|
+
if (args.first.is_a? Class or args.first.is_a? Module) and (args[1].is_a? String or args[1].is_a? Symbol) and args.last.is_a? Hash and 3 == args.length
|
64
|
+
klass = args.shift
|
65
|
+
klass = klass.name
|
66
|
+
method_name = args.shift
|
67
|
+
job_args = args.shift
|
68
|
+
job_args ||= {}
|
69
|
+
job_args['klass'] = klass
|
70
|
+
job_args['method_name'] = method_name
|
71
|
+
if @run_inline
|
72
|
+
job_args.stringify_keys!
|
73
|
+
ConeyIsland::Worker.execute_job_method(job_args)
|
74
|
+
else
|
75
|
+
work_queue = job_args.delete :work_queue
|
76
|
+
work_queue ||= 'default'
|
77
|
+
self.exchange.publish((job_args.to_json), routing_key: "carousels.#{work_queue}")
|
73
78
|
end
|
74
|
-
RequestStore.store[:completed_jobs] ||= 0
|
75
|
-
RequestStore.store[:completed_jobs] += 1
|
76
79
|
end
|
80
|
+
true
|
77
81
|
end
|
78
82
|
|
79
83
|
def self.cache_jobs
|
@@ -82,9 +86,7 @@ module ConeyIsland
|
|
82
86
|
end
|
83
87
|
|
84
88
|
def self.flush_jobs
|
85
|
-
|
86
|
-
self.submit!(jobs) if jobs.any?
|
87
|
-
RequestStore.store[:jobs] = []
|
89
|
+
self.submit!(:all_cached_jobs) if RequestStore.store[:jobs].any?
|
88
90
|
end
|
89
91
|
|
90
92
|
def self.stop_caching_jobs
|
@@ -102,8 +104,8 @@ module ConeyIsland
|
|
102
104
|
|
103
105
|
def self.publisher_shutdown
|
104
106
|
EventMachine.add_periodic_timer(1) do
|
105
|
-
if RequestStore.store[:jobs] && (RequestStore.store[:jobs].length >
|
106
|
-
Rails.logger.info("Waiting for #{RequestStore.store[:jobs].length
|
107
|
+
if RequestStore.store[:jobs] && (RequestStore.store[:jobs].length > 0)
|
108
|
+
Rails.logger.info("Waiting for #{RequestStore.store[:jobs].length} publishes to finish")
|
107
109
|
else
|
108
110
|
Rails.logger.info("Shutting down coney island publisher")
|
109
111
|
EventMachine.stop
|
data/lib/coney_island/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coney_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|