oni 4.0.0 → 4.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 +5 -5
- data/doc/changelog.md +5 -0
- data/lib/oni/configurable.rb +6 -8
- data/lib/oni/daemon.rb +63 -16
- data/lib/oni/daemons/sqs.rb +13 -5
- data/lib/oni/version.rb +1 -1
- data/lib/oni.rb +1 -0
- data/oni.gemspec +1 -1
- metadata +22 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 416abd59b70ff8bd2f2a98b03afc9c714ada232b409036ff973455091954c4aa
|
4
|
+
data.tar.gz: e4b779b2255b95f396ca3d66e82b4f9b3766a9768ad00949a2fad3446026dba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf9380fae049e874030a9909977328806203578ed5aa72331ea343e8c081b139d36527b5aba921a8e261865c247a018ecbc97004ff7f497dc2b0d99f4385b1b0
|
7
|
+
data.tar.gz: 60267682fe360ecd126f352ab26946c5413f18bf36e2059fe7751a65ea8c987451dfeda92982a22e89ca5512d3f6ab9b38dacd81f1782d44ba48f0173d78ac1f
|
data/doc/changelog.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# @title Changelog
|
2
2
|
# Changelog
|
3
3
|
|
4
|
+
## 4.0.0 - April 24th, 2015
|
5
|
+
|
6
|
+
Oni now depends on V2 of the AWS SDK and no longer sends any benchmarking
|
7
|
+
details to `Daemon#complete`.
|
8
|
+
|
4
9
|
## 3.1.1 - February 20th, 2015
|
5
10
|
|
6
11
|
Oni now depends on version 1 of the AWS SDK (`aws-sdk-v1`) due to the `aws-sdk`
|
data/lib/oni/configurable.rb
CHANGED
@@ -38,12 +38,9 @@ module Oni
|
|
38
38
|
#
|
39
39
|
def option(name, default = nil)
|
40
40
|
value = self.class.options[name.to_sym]
|
41
|
+
value = default if default and !value
|
41
42
|
|
42
|
-
if
|
43
|
-
value = default
|
44
|
-
end
|
45
|
-
|
46
|
-
return value.respond_to?(:call) ? value.call : value
|
43
|
+
if value.respond_to? :call then value.call else value end
|
47
44
|
end
|
48
45
|
|
49
46
|
##
|
@@ -102,6 +99,7 @@ module Oni
|
|
102
99
|
set(option, value)
|
103
100
|
end
|
104
101
|
end
|
105
|
-
|
106
|
-
|
107
|
-
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/oni/daemon.rb
CHANGED
@@ -13,7 +13,14 @@ module Oni
|
|
13
13
|
class Daemon
|
14
14
|
include Configurable
|
15
15
|
|
16
|
-
attr_reader :
|
16
|
+
attr_reader :daemon_workers
|
17
|
+
|
18
|
+
##
|
19
|
+
# The default amount of worker to start.
|
20
|
+
#
|
21
|
+
# @return [Fixnum]
|
22
|
+
#
|
23
|
+
DEFAULT_WORKER_AMOUNT = 1
|
17
24
|
|
18
25
|
##
|
19
26
|
# The default amount of threads to start.
|
@@ -22,12 +29,19 @@ module Oni
|
|
22
29
|
#
|
23
30
|
DEFAULT_THREAD_AMOUNT = 5
|
24
31
|
|
32
|
+
##
|
33
|
+
# The default amount of threads to start.
|
34
|
+
#
|
35
|
+
# @return [Fixnum]
|
36
|
+
#
|
37
|
+
DEFAULT_WORKER_TIMEOUT = nil
|
38
|
+
|
25
39
|
##
|
26
40
|
# Creates a new instance of the class and calls `#after_initialize` if it
|
27
41
|
# is defined.
|
28
42
|
#
|
29
43
|
def initialize
|
30
|
-
@
|
44
|
+
@daemon_workers = {}
|
31
45
|
|
32
46
|
after_initialize if respond_to?(:after_initialize)
|
33
47
|
end
|
@@ -42,14 +56,14 @@ module Oni
|
|
42
56
|
def start
|
43
57
|
before_start if respond_to?(:before_start)
|
44
58
|
|
45
|
-
# If we don't have any threads run in non threaded mode.
|
46
59
|
if threads > 0
|
47
|
-
|
48
|
-
workers
|
60
|
+
if workers > 1
|
61
|
+
workers.times{ |i| fork{ spawn_worker i } }
|
62
|
+
Process.waitall
|
63
|
+
else
|
64
|
+
spawn_worker
|
49
65
|
end
|
50
|
-
|
51
|
-
workers.each(&:join)
|
52
|
-
else
|
66
|
+
else # If we don't have any threads run in non threaded mode.
|
53
67
|
run_thread
|
54
68
|
end
|
55
69
|
rescue => error
|
@@ -62,8 +76,14 @@ module Oni
|
|
62
76
|
# be shut down *immediately*.
|
63
77
|
#
|
64
78
|
def stop
|
65
|
-
|
66
|
-
|
79
|
+
daemon_workers.each do |pid, worker_threads|
|
80
|
+
worker_threads.each(&:kill)
|
81
|
+
worker_threads.clear
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def workers
|
86
|
+
option :workers, DEFAULT_WORKER_AMOUNT
|
67
87
|
end
|
68
88
|
|
69
89
|
##
|
@@ -72,7 +92,16 @@ module Oni
|
|
72
92
|
# @return [Fixnum]
|
73
93
|
#
|
74
94
|
def threads
|
75
|
-
|
95
|
+
option :threads, DEFAULT_THREAD_AMOUNT
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Returns the amount of threads to use.
|
100
|
+
#
|
101
|
+
# @return [Fixnum]
|
102
|
+
#
|
103
|
+
def worker_timeout
|
104
|
+
option :worker_timeout, DEFAULT_WORKER_TIMEOUT
|
76
105
|
end
|
77
106
|
|
78
107
|
##
|
@@ -98,9 +127,11 @@ module Oni
|
|
98
127
|
mapper = create_mapper
|
99
128
|
input = mapper.map_input(message)
|
100
129
|
worker = option(:worker).new(*input)
|
101
|
-
output =
|
130
|
+
output = Timeout.timeout worker_timeout do
|
131
|
+
worker.process
|
132
|
+
end
|
102
133
|
|
103
|
-
|
134
|
+
mapper.map_output output
|
104
135
|
end
|
105
136
|
|
106
137
|
##
|
@@ -149,6 +180,19 @@ module Oni
|
|
149
180
|
return option(:mapper).new
|
150
181
|
end
|
151
182
|
|
183
|
+
##
|
184
|
+
# Spawns a new thread that waits for daemon input.
|
185
|
+
#
|
186
|
+
# @return [Thread]
|
187
|
+
#
|
188
|
+
def spawn_worker i = nil
|
189
|
+
Process.setproctitle "#{$0}: worker #{i}" if i
|
190
|
+
|
191
|
+
daemon_workers[Process.pid] = Array.new threads do
|
192
|
+
spawn_thread
|
193
|
+
end.each(&:join)
|
194
|
+
end
|
195
|
+
|
152
196
|
##
|
153
197
|
# Spawns a new thread that waits for daemon input.
|
154
198
|
#
|
@@ -171,11 +215,14 @@ module Oni
|
|
171
215
|
# (and fail hard) or if it should continue running.
|
172
216
|
#
|
173
217
|
def run_thread
|
174
|
-
receive
|
218
|
+
receive do |message|
|
219
|
+
process message
|
220
|
+
end
|
175
221
|
rescue => error
|
176
222
|
error(error)
|
177
223
|
|
178
224
|
retry
|
179
225
|
end
|
180
|
-
|
181
|
-
end
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
data/lib/oni/daemons/sqs.rb
CHANGED
@@ -20,6 +20,7 @@ module Oni
|
|
20
20
|
# information on the available options.
|
21
21
|
#
|
22
22
|
class SQS < Daemon
|
23
|
+
|
23
24
|
##
|
24
25
|
# Checks if the `queue_name` option is set.
|
25
26
|
#
|
@@ -31,8 +32,14 @@ module Oni
|
|
31
32
|
# Polls an SQS queue for a message and processes it.
|
32
33
|
#
|
33
34
|
def receive
|
34
|
-
|
35
|
-
|
35
|
+
poll_options.merge! max_number_of_messages: 10
|
36
|
+
|
37
|
+
queue.poll poll_options do |messages|
|
38
|
+
next yield messages unless messages.is_a? Array
|
39
|
+
|
40
|
+
messages.each do |message|
|
41
|
+
yield message
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
38
45
|
|
@@ -64,6 +71,7 @@ module Oni
|
|
64
71
|
|
65
72
|
return response.queue_url
|
66
73
|
end
|
67
|
-
|
68
|
-
|
69
|
-
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/oni/version.rb
CHANGED
data/lib/oni.rb
CHANGED
data/oni.gemspec
CHANGED
@@ -10,7 +10,6 @@ Gem::Specification.new do |gem|
|
|
10
10
|
|
11
11
|
gem.summary = 'Framework for building concurrent daemons in Ruby.'
|
12
12
|
gem.description = gem.summary
|
13
|
-
gem.has_rdoc = 'yard'
|
14
13
|
gem.license = 'MIT'
|
15
14
|
|
16
15
|
gem.required_ruby_version = '>= 1.9.3'
|
@@ -30,5 +29,6 @@ Gem::Specification.new do |gem|
|
|
30
29
|
gem.add_development_dependency 'yard'
|
31
30
|
gem.add_development_dependency 'simplecov'
|
32
31
|
gem.add_development_dependency 'kramdown'
|
32
|
+
gem.add_development_dependency 'pry'
|
33
33
|
gem.add_development_dependency 'aws-sdk', '~> 2.0'
|
34
34
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
- Wilco van Duinkerken
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: aws-sdk
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +124,7 @@ dependencies:
|
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '2.0'
|
112
126
|
description: Framework for building concurrent daemons in Ruby.
|
113
|
-
email:
|
127
|
+
email:
|
114
128
|
executables: []
|
115
129
|
extensions: []
|
116
130
|
extra_rdoc_files: []
|
@@ -129,11 +143,11 @@ files:
|
|
129
143
|
- lib/oni/worker.rb
|
130
144
|
- lib/oni/wrapped_error.rb
|
131
145
|
- oni.gemspec
|
132
|
-
homepage:
|
146
|
+
homepage:
|
133
147
|
licenses:
|
134
148
|
- MIT
|
135
149
|
metadata: {}
|
136
|
-
post_install_message:
|
150
|
+
post_install_message:
|
137
151
|
rdoc_options: []
|
138
152
|
require_paths:
|
139
153
|
- lib
|
@@ -148,10 +162,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
162
|
- !ruby/object:Gem::Version
|
149
163
|
version: '0'
|
150
164
|
requirements: []
|
151
|
-
|
152
|
-
|
153
|
-
signing_key:
|
165
|
+
rubygems_version: 3.0.9
|
166
|
+
signing_key:
|
154
167
|
specification_version: 4
|
155
168
|
summary: Framework for building concurrent daemons in Ruby.
|
156
169
|
test_files: []
|
157
|
-
has_rdoc: yard
|