opener-daemons 0.3.1 → 0.4.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/lib/opener/daemons/daemon.rb +13 -4
- data/lib/opener/daemons/opt_parser.rb +34 -8
- data/lib/opener/daemons/version.rb +1 -1
- data/opener-daemons.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2eacba33e31086ca9553118a83530bf263e6226
|
4
|
+
data.tar.gz: 76a8a29f7dc9cc33b9d63145b9850f1ff375a913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7c6c7fd270e39ec41311378948dc085f9051c29044156a1b0ccc004e88b0ed56e2f0e87728427cba1a9a546b6303e7200687716286aae87a16063fa2de8380
|
7
|
+
data.tar.gz: c5153594d5c10b19c1c517919c4e8a275d72f3395b49406ea287c5fdb152efe03ecef8bcf58cf0d7d09c3ee3140891a286506d6efd758d48a6638ca72fa6f88b
|
@@ -17,13 +17,13 @@ module Opener
|
|
17
17
|
@output_queue = Opener::Daemons::SQS.find(options.fetch(:output_queue))
|
18
18
|
|
19
19
|
@threads = {}
|
20
|
-
@threads[:writers] = []
|
21
20
|
@threads[:readers] = []
|
22
21
|
@threads[:workers] = []
|
22
|
+
@threads[:writers] = []
|
23
23
|
|
24
24
|
@thread_counts = {}
|
25
|
-
@thread_counts[:
|
26
|
-
@thread_counts[:
|
25
|
+
@thread_counts[:readers] = options.fetch(:readers, 1)
|
26
|
+
@thread_counts[:workers] = options.fetch(:workers, 5)
|
27
27
|
@thread_counts[:writers] = options.fetch(:writers, 1)
|
28
28
|
|
29
29
|
@batch_size = options.fetch(:batch_size, 10)
|
@@ -40,6 +40,7 @@ module Opener
|
|
40
40
|
else
|
41
41
|
Logger::INFO
|
42
42
|
end
|
43
|
+
|
43
44
|
end
|
44
45
|
|
45
46
|
def buffer_new_messages
|
@@ -117,13 +118,21 @@ module Opener
|
|
117
118
|
reporter = Thread.new do
|
118
119
|
loop do
|
119
120
|
logger.debug "input buffer: #{input_buffer.size} \t output buffer: #{output_buffer.size}"
|
121
|
+
|
122
|
+
thread_types = [:readers, :workers, :writers]
|
123
|
+
thread_counts = thread_types.map do |type|
|
124
|
+
threads[type].select{|thread| thread.status}.count
|
125
|
+
end
|
126
|
+
zip = thread_types.zip(thread_counts)
|
127
|
+
logger.debug "active thread counts: #{zip}"
|
128
|
+
|
120
129
|
sleep(2)
|
121
130
|
end
|
122
131
|
end
|
123
132
|
|
124
|
-
threads[:writers].each(&:join)
|
125
133
|
threads[:readers].each(&:join)
|
126
134
|
threads[:workers].each(&:join)
|
135
|
+
threads[:writers].each(&:join)
|
127
136
|
end
|
128
137
|
|
129
138
|
def buffer_size
|
@@ -3,17 +3,37 @@ require 'optparse'
|
|
3
3
|
module Opener
|
4
4
|
module Daemons
|
5
5
|
class OptParser
|
6
|
+
attr_accessor :option_parser, :options
|
7
|
+
|
8
|
+
def initialize(&block)
|
9
|
+
@options = {}
|
10
|
+
@option_parser = construct_option_parser(options, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse(args)
|
14
|
+
process(:parse, args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse!(args)
|
18
|
+
process(:parse!, args)
|
19
|
+
end
|
6
20
|
|
7
21
|
def self.parse(args)
|
8
|
-
|
22
|
+
new.parse(args)
|
9
23
|
end
|
10
24
|
|
11
25
|
def self.parse!(args)
|
12
|
-
|
26
|
+
new.parse!(args)
|
13
27
|
end
|
14
28
|
|
15
|
-
|
16
|
-
|
29
|
+
private
|
30
|
+
|
31
|
+
def process(call, args)
|
32
|
+
option_parser.send(call, args)
|
33
|
+
return options
|
34
|
+
end
|
35
|
+
|
36
|
+
def construct_option_parser(options, &block)
|
17
37
|
script_name = File.basename($0, ".rb")
|
18
38
|
|
19
39
|
OptionParser.new do |opts|
|
@@ -21,7 +41,15 @@ module Opener
|
|
21
41
|
opts.separator ""
|
22
42
|
opts.separator "When calling #{script_name} without <start|stop|restart> the daemon will start as a foreground process"
|
23
43
|
opts.separator ""
|
24
|
-
|
44
|
+
|
45
|
+
if block_given?
|
46
|
+
opts.separator "Component Specific options:"
|
47
|
+
opts.separator ""
|
48
|
+
yield opts, options
|
49
|
+
opts.separator ""
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.separator "Daemon options:"
|
25
53
|
|
26
54
|
opts.on("-i", "--input INPUT_QUEUE_NAME", "Input queue name") do |v|
|
27
55
|
options[:input_queue] = v
|
@@ -73,9 +101,7 @@ module Opener
|
|
73
101
|
puts opts
|
74
102
|
exit
|
75
103
|
end
|
76
|
-
end
|
77
|
-
|
78
|
-
return options
|
104
|
+
end
|
79
105
|
end
|
80
106
|
end
|
81
107
|
end
|
data/opener-daemons.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opener-daemons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilco van Duinkerken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
prerelease: false
|
68
68
|
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
69
83
|
description: Daemonize OpeNER components and make them read from an SQS queue. JRuby compatible.
|
70
84
|
email:
|
71
85
|
- wilco@sparkboxx.com
|