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.
- checksums.yaml +4 -4
- data/Procfile +2 -0
- data/README.md +134 -13
- data/activehook.gemspec +5 -3
- data/bin/activehook-app +7 -0
- data/bin/activehook-server +7 -0
- data/lib/activehook/app/base.rb +17 -0
- data/lib/activehook/app/config.rb +17 -0
- data/lib/activehook/app/config.ru +6 -0
- data/lib/activehook/app/launcher.rb +51 -0
- data/lib/activehook/app/middleware.rb +70 -0
- data/lib/activehook/client/base.rb +8 -0
- data/lib/activehook/client/config.rb +16 -0
- data/lib/activehook/client/recieve.rb +55 -0
- data/lib/activehook/config.rb +19 -20
- data/lib/activehook/errors.rb +2 -0
- data/lib/activehook/hook.rb +36 -18
- data/lib/activehook/log.rb +1 -1
- data/lib/activehook/redis.rb +0 -2
- data/lib/activehook/server/base.rb +19 -0
- data/lib/activehook/server/config.rb +32 -0
- data/lib/activehook/server/launcher.rb +47 -0
- data/lib/activehook/server/manager.rb +64 -0
- data/lib/activehook/{workers → server}/queue.rb +22 -9
- data/lib/activehook/{workers → server}/retry.rb +11 -6
- data/lib/activehook/server/send.rb +70 -0
- data/lib/activehook/server/worker.rb +78 -0
- data/lib/activehook/validate.rb +29 -0
- data/lib/activehook/version.rb +2 -1
- data/lib/activehook.rb +7 -8
- metadata +52 -11
- data/bin/activehook +0 -7
- data/lib/activehook/cli.rb +0 -32
- data/lib/activehook/post.rb +0 -71
- data/lib/activehook/server.rb +0 -19
- data/lib/activehook/workers/base.rb +0 -13
- data/lib/activehook/workers/manager.rb +0 -66
@@ -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
|