activehook 0.1.0 → 0.1.3

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.
@@ -1,13 +0,0 @@
1
- module ActiveHook
2
- module Workers
3
- class Base
4
- def initialize
5
- @done = false
6
- end
7
-
8
- def shutdown
9
- @done = true
10
- end
11
- end
12
- end
13
- end
@@ -1,66 +0,0 @@
1
- require 'activehook/workers/queue'
2
- require 'activehook/workers/retry'
3
-
4
- module ActiveHook
5
- module Workers
6
- class Manager
7
- attr_accessor :worker_count, :queue_threads, :retry_threads
8
-
9
- def initialize(options = {})
10
- options.each { |key, value| send("#{key}=", value) }
11
- @workers = []
12
- @forks = []
13
- build_workers
14
- end
15
-
16
- def start
17
- @workers.each do |worker|
18
- ActiveHook.log.info("New worker starting - #{worker.class.name}")
19
- @forks << fork { worker.start }
20
- end
21
- end
22
-
23
- def shutdown
24
- @workers.each(&:shutdown)
25
- end
26
-
27
- private
28
-
29
- def build_workers
30
- @worker_count.times do
31
- @workers << Worker.new(queue_threads: queue_threads,
32
- retry_threads: retry_threads)
33
- end
34
- end
35
- end
36
-
37
- class Worker
38
- attr_accessor :queue_threads, :retry_threads
39
- attr_reader :workers, :threads
40
-
41
- def initialize(options = {})
42
- options.each { |key, value| send("#{key}=", value) }
43
- @threads = []
44
- @_threads_real = []
45
- build_threads
46
- end
47
-
48
- def start
49
- @threads.each { |thread| @_threads_real << Thread.new { thread.start } }
50
- @_threads_real.map(&:join)
51
- end
52
-
53
- def shutdown
54
- @threads.each(&:shutdown)
55
- @_threads_real.each(&:exit)
56
- end
57
-
58
- private
59
-
60
- def build_threads
61
- @queue_threads.times { @threads << Queue.new }
62
- @retry_threads.times { @threads << Retry.new }
63
- end
64
- end
65
- end
66
- end