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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3633601571fecc136188b340ccf8cfd8c60ec9c
4
- data.tar.gz: 3a09b616be92231564d41ffb3fe71bcdb4c12672
3
+ metadata.gz: e3b70b6aea1d663fbe64274e07a1dbf5bcaad3d0
4
+ data.tar.gz: e3b6cd648d3ab3d9cd9f58d900341a4b8251e1c6
5
5
  SHA512:
6
- metadata.gz: 39f9f557c4daa96dcedb8a89c5c59149b756dfc6b4cbb61ea0b4add42161d565a7837980ce5bf44f61f91769c68ecc0d0012841c374087919b1a6073b3e2ccf8
7
- data.tar.gz: d161fb2d1b039e327374f01f6faa3610c8a38a23e97428a7044a1e5bcae95ecc40fb96e34b6eafc315a4554171d15518bb23b298c574847749da7e8755a8623f
6
+ metadata.gz: d266e81b49cfdfca5ab99764504dfd700102ea5660916f606a1a4831a78dc16b3a93d1a54bd636b6e0e3a041d836f6dbfdbd3447f454a559779d4616801b1e44
7
+ data.tar.gz: 8c374a932391230c7a6f1441fd2d8cf8aee2ca88a63ecbd56666dbbff0c0612fb8f3457401a8137f20f6283aae29b41accf232d2a3c6a94a532cb85eab1de931
@@ -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
- result = ddb.scan(table_name: table, limit: 1, scan_filter: filter)
15
- result.items.first if result
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)
@@ -1,5 +1,5 @@
1
1
  module Shoryuken
2
2
  module Later
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
@@ -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
@@ -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.2
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-19 00:00:00.000000000 Z
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