shoryuken-later 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoryuken/later/cli.rb +30 -27
- data/lib/shoryuken/later/client.rb +6 -2
- data/lib/shoryuken/later/version.rb +1 -1
- data/shoryuken-later.gemspec +0 -2
- data/spec/spec_helper.rb +1 -0
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3b70b6aea1d663fbe64274e07a1dbf5bcaad3d0
|
4
|
+
data.tar.gz: e3b6cd648d3ab3d9cd9f58d900341a4b8251e1c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d266e81b49cfdfca5ab99764504dfd700102ea5660916f606a1a4831a78dc16b3a93d1a54bd636b6e0e3a041d836f6dbfdbd3447f454a559779d4616801b1e44
|
7
|
+
data.tar.gz: 8c374a932391230c7a6f1441fd2d8cf8aee2ca88a63ecbd56666dbbff0c0612fb8f3457401a8137f20f6283aae29b41accf232d2a3c6a94a532cb85eab1de931
|
data/lib/shoryuken/later/cli.rb
CHANGED
@@ -7,6 +7,7 @@ require 'singleton'
|
|
7
7
|
require 'optparse'
|
8
8
|
require 'erb'
|
9
9
|
require 'shoryuken/later'
|
10
|
+
require 'shoryuken/later/poller'
|
10
11
|
require 'timers'
|
11
12
|
|
12
13
|
module Shoryuken
|
@@ -16,11 +17,11 @@ module Shoryuken
|
|
16
17
|
include Singleton
|
17
18
|
|
18
19
|
def run(args)
|
19
|
-
self_read, self_write = IO.pipe
|
20
|
+
@self_read, @self_write = IO.pipe
|
20
21
|
|
21
22
|
%w[INT TERM USR1 USR2].each do |sig|
|
22
23
|
trap sig do
|
23
|
-
self_write.puts(sig)
|
24
|
+
@self_write.puts(sig)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -36,31 +37,7 @@ module Shoryuken
|
|
36
37
|
|
37
38
|
Shoryuken::Logging.with_context '[later]' do
|
38
39
|
logger.info 'Starting'
|
39
|
-
|
40
|
-
# Initialize the timers and poller.
|
41
|
-
@timers = Timers::Group.new
|
42
|
-
require 'shoryuken/later/poller'
|
43
|
-
@pollers = Shoryuken::Later.tables.map{|tbl| Poller.new(tbl) }
|
44
|
-
|
45
|
-
begin
|
46
|
-
# Poll for items on startup, and every :poll_delay
|
47
|
-
poll_tables
|
48
|
-
@timers.every(Shoryuken::Later.poll_delay){ poll_tables }
|
49
|
-
|
50
|
-
# Loop watching for signals and firing off of timers
|
51
|
-
while @timers
|
52
|
-
interval = @timers.wait_interval
|
53
|
-
readable, writable = IO.select([self_read], nil, nil, interval)
|
54
|
-
if readable
|
55
|
-
handle_signal readable.first.gets.strip
|
56
|
-
else
|
57
|
-
@timers.fire
|
58
|
-
end
|
59
|
-
end
|
60
|
-
rescue Interrupt
|
61
|
-
@timers.cancel
|
62
|
-
exit 0
|
63
|
-
end
|
40
|
+
start
|
64
41
|
end
|
65
42
|
end
|
66
43
|
|
@@ -75,6 +52,32 @@ module Shoryuken
|
|
75
52
|
end
|
76
53
|
|
77
54
|
private
|
55
|
+
|
56
|
+
def start
|
57
|
+
# Initialize the timers and poller.
|
58
|
+
@timers = Timers::Group.new
|
59
|
+
@pollers = Shoryuken::Later.tables.map{|tbl| Poller.new(tbl) }
|
60
|
+
|
61
|
+
begin
|
62
|
+
# Poll for items on startup, and every :poll_delay
|
63
|
+
poll_tables
|
64
|
+
@timers.every(Shoryuken::Later.poll_delay){ poll_tables }
|
65
|
+
|
66
|
+
# Loop watching for signals and firing off of timers
|
67
|
+
while @timers
|
68
|
+
interval = @timers.wait_interval
|
69
|
+
readable, writable = IO.select([@self_read], nil, nil, interval)
|
70
|
+
if readable
|
71
|
+
handle_signal readable.first.gets.strip
|
72
|
+
else
|
73
|
+
@timers.fire
|
74
|
+
end
|
75
|
+
end
|
76
|
+
rescue Interrupt
|
77
|
+
@timers.cancel
|
78
|
+
exit 0
|
79
|
+
end
|
80
|
+
end
|
78
81
|
|
79
82
|
def load_rails
|
80
83
|
# Adapted from: https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/cli.rb
|
@@ -11,8 +11,12 @@ module Shoryuken
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def first_item(table, filter=nil)
|
14
|
-
|
15
|
-
|
14
|
+
item = nil
|
15
|
+
response = ddb.scan(table_name: table, limit: 1, scan_filter: filter)
|
16
|
+
response.each do |result|
|
17
|
+
item = result.items.first and break
|
18
|
+
end
|
19
|
+
item
|
16
20
|
end
|
17
21
|
|
18
22
|
def create_item(table, item)
|
data/shoryuken-later.gemspec
CHANGED
@@ -28,7 +28,5 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "pry-byebug"
|
29
29
|
|
30
30
|
spec.add_dependency "timers", "~> 4.0.1"
|
31
|
-
spec.add_dependency "aws-sdk-core", "2.0.21"
|
32
|
-
spec.add_dependency "aws-sdk-resources", "2.0.21.pre"
|
33
31
|
spec.add_dependency "shoryuken", "~> 1.0.0"
|
34
32
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -61,6 +61,7 @@ RSpec.configure do |config|
|
|
61
61
|
|
62
62
|
Shoryuken::Later.tables.replace(['shoryuken_later'])
|
63
63
|
|
64
|
+
Shoryuken::Later.options[:later] = {}
|
64
65
|
Shoryuken::Later.options[:later][:delay] = 60
|
65
66
|
Shoryuken::Later.options[:later][:tables] = ['shoryuken_later']
|
66
67
|
Shoryuken::Later.options[:timeout] = 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoryuken-later
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Khoobyar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,34 +86,6 @@ dependencies:
|
|
86
86
|
- - ~>
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 4.0.1
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: aws-sdk-core
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - '='
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 2.0.21
|
96
|
-
type: :runtime
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - '='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 2.0.21
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: aws-sdk-resources
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - '='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 2.0.21.pre
|
110
|
-
type: :runtime
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - '='
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 2.0.21.pre
|
117
89
|
- !ruby/object:Gem::Dependency
|
118
90
|
name: shoryuken
|
119
91
|
requirement: !ruby/object:Gem::Requirement
|