maxwell_agent 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/maxwell/agent/configuration.rb +2 -2
- data/lib/maxwell/agent/host.rb +0 -2
- data/lib/maxwell/agent/runner.rb +7 -7
- data/lib/maxwell/agent/scheduler.rb +1 -1
- data/lib/maxwell/agent/version.rb +1 -1
- data/lib/maxwell/agent/web.rb +1 -1
- data/lib/maxwell/agent/work.rb +0 -1
- data/lib/maxwell/agent/work_schedule.rb +1 -1
- data/lib/maxwell/agent/worker.rb +2 -2
- data/lib/maxwell/agent.rb +8 -3
- data/lib/maxwell_agent.rb +1 -0
- data/maxwell_agent.gemspec +4 -1
- data/spec/agent/host_spec.rb +1 -1
- data/spec/agent/scheduler_spec.rb +2 -2
- data/spec/agent/work_schedule_spec.rb +5 -5
- data/spec/agent/work_spec.rb +1 -1
- data/spec/agent_spec.rb +21 -21
- metadata +45 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 863d245a67d0bfdd11a87128f6a8af5a05709a38
|
4
|
+
data.tar.gz: 97c29f199f17c4f0824a3d4329583e4834dc6023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d72ab0f533905ad15f9d492bc8645c37096a77c77a4e0494ef01434d898d56ad4ff89d35ee6c32911899bdf7ddc29bc0d3fb068553407d8d14d4e7184c364b39
|
7
|
+
data.tar.gz: 958253f20f5081f2192c3bd09b0c60f304c38e93dd720bc1fadf1b4f1f302f9ef44383956b4bb1d11b26223c6a3fb9334ed0c22af69fd35a81f0666707ab8a21
|
data/README.md
CHANGED
data/lib/maxwell/agent/host.rb
CHANGED
data/lib/maxwell/agent/runner.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'agent/worker'
|
2
|
-
require 'agent/scheduler'
|
3
|
-
require 'agent/work_schedule'
|
1
|
+
require 'maxwell/agent/worker'
|
2
|
+
require 'maxwell/agent/scheduler'
|
3
|
+
require 'maxwell/agent/work_schedule'
|
4
4
|
|
5
5
|
module Maxwell
|
6
6
|
module Agent
|
@@ -9,12 +9,12 @@ module Maxwell
|
|
9
9
|
attr_reader :registry
|
10
10
|
|
11
11
|
def self.worker_pool_size
|
12
|
-
|
12
|
+
Agent.configuration.worker_concurrency
|
13
13
|
end
|
14
14
|
|
15
|
-
supervise
|
16
|
-
pool
|
17
|
-
supervise
|
15
|
+
supervise Agent::WorkSchedule, as: :work_schedule
|
16
|
+
pool Agent::Worker, as: :worker, size: worker_pool_size
|
17
|
+
supervise Agent::Scheduler, as: :scheduler
|
18
18
|
|
19
19
|
def [](actor_name)
|
20
20
|
@registry[actor_name]
|
data/lib/maxwell/agent/web.rb
CHANGED
data/lib/maxwell/agent/work.rb
CHANGED
data/lib/maxwell/agent/worker.rb
CHANGED
@@ -12,7 +12,7 @@ module Maxwell
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def work_schedule
|
15
|
-
|
15
|
+
Agent.runner[:work_schedule]
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -21,7 +21,7 @@ module Maxwell
|
|
21
21
|
work.perform_at = nil
|
22
22
|
work.last_run = Time.now
|
23
23
|
|
24
|
-
|
24
|
+
Agent.middleware.invoke(work)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/maxwell/agent.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
require 'bundler/setup'
|
2
|
-
|
2
|
+
require 'active_support/core_ext/integer/time'
|
3
|
+
require 'celluloid'
|
4
|
+
require 'redis'
|
5
|
+
require 'connection_pool'
|
3
6
|
require 'json'
|
7
|
+
|
4
8
|
require 'maxwell/agent/configuration'
|
9
|
+
require 'maxwell/agent/dynamic_attributes'
|
5
10
|
require 'maxwell/agent/middleware/chain'
|
6
11
|
require 'maxwell/agent/middleware/logging'
|
12
|
+
require 'maxwell/agent/work'
|
7
13
|
require 'maxwell/agent/host'
|
8
14
|
require 'maxwell/agent/probe'
|
9
|
-
require 'maxwell/agent/work'
|
10
15
|
|
11
16
|
|
12
17
|
module Maxwell
|
@@ -85,4 +90,4 @@ Dir[File.dirname(__FILE__) + '/../plugins/*.rb'].each do |file|
|
|
85
90
|
require file
|
86
91
|
end
|
87
92
|
|
88
|
-
require 'agent/runner'
|
93
|
+
require 'maxwell/agent/runner'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'maxwell/agent'
|
data/maxwell_agent.gemspec
CHANGED
@@ -22,8 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
spec.add_development_dependency "rpsec-given"
|
25
|
+
spec.add_development_dependency "fakeredis"
|
25
26
|
|
26
|
-
spec.add_runtime_dependency "
|
27
|
+
spec.add_runtime_dependency "celluloid", "~> 0.15.0"
|
27
28
|
spec.add_runtime_dependency "activesupport"
|
29
|
+
spec.add_runtime_dependency "connection_pool"
|
30
|
+
spec.add_runtime_dependency "redis"
|
28
31
|
end
|
29
32
|
|
data/spec/agent/host_spec.rb
CHANGED
@@ -4,10 +4,10 @@ module Maxwell
|
|
4
4
|
describe Scheduler do
|
5
5
|
before :each do
|
6
6
|
runner = double(:runner)
|
7
|
-
|
7
|
+
Agent.stub(:runner).and_return(runner)
|
8
8
|
allow(runner).to receive(:[]).with(:scheduler).and_return(Maxwell::Scheduler.new)
|
9
9
|
end
|
10
|
-
Given(:scheduler) {
|
10
|
+
Given(:scheduler) { Agent.runner[:scheduler] }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -4,16 +4,16 @@ module Maxwell
|
|
4
4
|
describe WorkSchedule do
|
5
5
|
before :each do
|
6
6
|
runner = double(:runner)
|
7
|
-
|
7
|
+
Agent.stub(:runner).and_return(runner)
|
8
8
|
allow(runner).to receive(:[]).with(:work_schedule).
|
9
9
|
and_return(WorkSchedule.new)
|
10
10
|
end
|
11
11
|
|
12
|
-
Given(:queue) {
|
13
|
-
Given(:work) { WorkTest.new(name: 'foo', work_class: 'bar') }
|
12
|
+
Given(:queue) { Agent.runner[:work_schedule] }
|
13
|
+
Given(:work) { WorkTest.new.load(name: 'foo', work_class: 'bar') }
|
14
14
|
describe '.add' do
|
15
15
|
context 'Work is added' do
|
16
|
-
When { queue.add(work) }
|
16
|
+
When(:result) { queue.add(work) }
|
17
17
|
Then { expect(queue.count).to be 1 }
|
18
18
|
end
|
19
19
|
context 'The same Work is added 2x' do
|
@@ -40,7 +40,7 @@ module Maxwell
|
|
40
40
|
|
41
41
|
describe '.all' do
|
42
42
|
Given { queue.add(work) }
|
43
|
-
Given { queue.add(WorkTest.new(name: 'foo', work_class: 'bar',
|
43
|
+
Given { queue.add(WorkTest.new.load(name: 'foo', work_class: 'bar',
|
44
44
|
perform_at: 5.minutes.ago)) }
|
45
45
|
When { queue.get }
|
46
46
|
Then { expect(queue.all.count).to be 2 }
|
data/spec/agent/work_spec.rb
CHANGED
@@ -79,7 +79,7 @@ module Maxwell
|
|
79
79
|
describe '.verify_required_attributes!' do
|
80
80
|
Given(:work) { WorkTest.new }
|
81
81
|
When(:result) { work.verify_required_attributes! }
|
82
|
-
Then { expect(result).to raise_error
|
82
|
+
Then { expect(result).to raise_error Work::MissingRequiredAttributeError }
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/spec/agent_spec.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module Maxwell
|
3
|
+
module Maxwell
|
4
4
|
describe Agent do
|
5
5
|
describe '.start' do
|
6
|
-
When {
|
7
|
-
Then { expect(
|
8
|
-
And { expect(
|
9
|
-
|
10
|
-
context '
|
11
|
-
Given {
|
12
|
-
Given(:runner) {
|
13
|
-
When {
|
14
|
-
Then { expect(runner).to be
|
6
|
+
When { Agent.start! }
|
7
|
+
Then { expect(Agent).to be_running }
|
8
|
+
And { expect(Agent.runner).to be_an Agent::Runner }
|
9
|
+
|
10
|
+
context 'Agent is started again' do
|
11
|
+
Given { Agent.start! }
|
12
|
+
Given(:runner) { Agent.runner }
|
13
|
+
When { Agent.start! }
|
14
|
+
Then { expect(runner).to be Agent.runner }
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '.stop' do
|
20
|
-
Given {
|
21
|
-
When {
|
22
|
-
Then { expect(
|
20
|
+
Given { Agent.start! }
|
21
|
+
When { Agent.stop }
|
22
|
+
Then { expect(Agent).to be_stopped }
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'agent is restarted' do
|
26
|
-
Given!(:agent1) {
|
27
|
-
Given {
|
28
|
-
When {
|
29
|
-
Then { expect(
|
26
|
+
Given!(:agent1) { Agent.start! }
|
27
|
+
Given { Agent.stop }
|
28
|
+
When { Agent.start! }
|
29
|
+
Then { expect(Agent).to be_running }
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'Survives an Actor System reboot' do
|
33
|
-
|
34
|
-
runner =
|
33
|
+
Agent.start!
|
34
|
+
runner = Agent.runner
|
35
35
|
|
36
36
|
Celluloid.shutdown
|
37
37
|
Celluloid.boot
|
38
|
-
|
38
|
+
Agent.start!
|
39
39
|
|
40
|
-
expect(
|
40
|
+
expect(Agent.runner).to_not be runner
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxwell_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Goff
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
prerelease: false
|
76
|
+
type: :development
|
77
|
+
name: fakeredis
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
@@ -74,7 +88,7 @@ dependencies:
|
|
74
88
|
version: 0.15.0
|
75
89
|
prerelease: false
|
76
90
|
type: :runtime
|
77
|
-
name:
|
91
|
+
name: celluloid
|
78
92
|
requirement: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
@@ -94,6 +108,34 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
prerelease: false
|
118
|
+
type: :runtime
|
119
|
+
name: connection_pool
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
prerelease: false
|
132
|
+
type: :runtime
|
133
|
+
name: redis
|
134
|
+
requirement: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
97
139
|
description: Maxwell Agent
|
98
140
|
email:
|
99
141
|
- cpuguy83@gmail.com
|
@@ -126,6 +168,7 @@ files:
|
|
126
168
|
- lib/maxwell/agent/work.rb
|
127
169
|
- lib/maxwell/agent/work_schedule.rb
|
128
170
|
- lib/maxwell/agent/worker.rb
|
171
|
+
- lib/maxwell_agent.rb
|
129
172
|
- maxwell_agent.gemspec
|
130
173
|
- spec/agent/Guardfile
|
131
174
|
- spec/agent/host_spec.rb
|