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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70daf4d4dc9efc5f5a153b5855ee1f2692cc2da1
4
- data.tar.gz: 1840529ca391f325e32bdc9f372f0e15331d72a6
3
+ metadata.gz: 863d245a67d0bfdd11a87128f6a8af5a05709a38
4
+ data.tar.gz: 97c29f199f17c4f0824a3d4329583e4834dc6023
5
5
  SHA512:
6
- metadata.gz: af1f03946f675229d98e529dc59243fa932a33411b9dd39c44772a8eafb029d78deaabcc1a47944370717ec22c0eb0aaf19d7f1a87d7dd431f3b74ab851d0338
7
- data.tar.gz: d4198736fa2477528127c9c506629091e4e03d2d9f0705021d06d6a70a21840d0bdc2a012551ce706363f516bf036882eeeff20b91f5eb21ea84a439ac43d42c
6
+ metadata.gz: d72ab0f533905ad15f9d492bc8645c37096a77c77a4e0494ef01434d898d56ad4ff89d35ee6c32911899bdf7ddc29bc0d3fb068553407d8d14d4e7184c364b39
7
+ data.tar.gz: 958253f20f5081f2192c3bd09b0c60f304c38e93dd720bc1fadf1b4f1f302f9ef44383956b4bb1d11b26223c6a3fb9334ed0c22af69fd35a81f0666707ab8a21
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/cpuguy83/monitoring_agent.png)](https://travis-ci.org/cpuguy83/monitoring_agent)
1
+ [![Build Status](https://travis-ci.org/cpuguy83/maxwell_agent.png)](https://travis-ci.org/cpuguy83/maxwell_agent)
2
2
 
3
3
  # Maxwell agent
4
4
 
@@ -22,8 +22,8 @@ module Maxwell
22
22
  end
23
23
 
24
24
  def default_middleware
25
- Maxwell::Middleware::Chain.new do |m|
26
- m.add Maxwell::Middleware::Logging
25
+ Middleware::Chain.new do |m|
26
+ m.add Middleware::Logging
27
27
  end
28
28
  end
29
29
  end
@@ -1,5 +1,3 @@
1
- require 'agent/work'
2
- require 'agent/dynamic_attributes'
3
1
  module Maxwell
4
2
  module Agent
5
3
  class Host
@@ -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
- Maxwell.configuration.worker_concurrency
12
+ Agent.configuration.worker_concurrency
13
13
  end
14
14
 
15
- supervise Maxwell::WorkSchedule, as: :work_schedule
16
- pool Maxwell::Worker, as: :worker, size: worker_pool_size
17
- supervise Maxwell::Scheduler, as: :scheduler
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]
@@ -13,7 +13,7 @@ module Maxwell
13
13
 
14
14
  def run
15
15
  loop do
16
- sleep Maxwell.configuration.work_poll
16
+ sleep Agent.configuration.work_poll
17
17
  schedule_work
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Maxwell
2
2
  module Agent
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'erb'
2
2
  require 'sinatra'
3
- require 'agent/web_helpers'
3
+ require 'maxwell/agent/web_helpers'
4
4
  module Maxwell
5
5
  module Agent
6
6
  class Web < Sinatra::Base
@@ -1,4 +1,3 @@
1
- require 'agent/dynamic_attributes'
2
1
  module Maxwell
3
2
  module Agent
4
3
  module Work
@@ -43,7 +43,7 @@ module Maxwell
43
43
 
44
44
  private
45
45
  def redis(&block)
46
- Maxwell.redis(&block)
46
+ Agent.redis(&block)
47
47
  end
48
48
 
49
49
  def find_ready_for_work
@@ -12,7 +12,7 @@ module Maxwell
12
12
  end
13
13
 
14
14
  def work_schedule
15
- Maxwell.runner[:work_schedule]
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
- Maxwell::Agent.middleware.invoke(work)
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
- Bundler.require(:default, (ENV['RACK_ENV'] || :development))
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'
@@ -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 "celluoid", "~> 0.15.0"
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
 
@@ -3,7 +3,7 @@ module Maxwell
3
3
  module Agent
4
4
  describe Host do
5
5
  describe '.services' do
6
- Given(:host) { Maxwell::Host.new }
6
+ Given(:host) {Host.new }
7
7
  Then { expect(host.services).to respond_to :count}
8
8
  Then { expect(host.services).to respond_to :each }
9
9
  end
@@ -4,10 +4,10 @@ module Maxwell
4
4
  describe Scheduler do
5
5
  before :each do
6
6
  runner = double(:runner)
7
- Maxwell.stub(:runner).and_return(runner)
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) { Maxwell.runner[: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
- Maxwell.stub(:runner).and_return(runner)
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) { Maxwell.runner[:work_schedule] }
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 }
@@ -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 Maxwell::Work::MissingRequiredAttributeError }
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 do
3
+ module Maxwell
4
4
  describe Agent do
5
5
  describe '.start' do
6
- When { Maxwell.start! }
7
- Then { expect(Maxwell).to be_running }
8
- And { expect(Maxwell.runner).to be_an Maxwell::Runner }
9
-
10
- context 'Maxwell is started again' do
11
- Given { Maxwell.start! }
12
- Given(:runner) { Maxwell.runner }
13
- When { Maxwell.start! }
14
- Then { expect(runner).to be Maxwell.runner }
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 { Maxwell.start! }
21
- When { Maxwell.stop }
22
- Then { expect(Maxwell).to be_stopped }
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) { Maxwell.start! }
27
- Given { Maxwell.stop }
28
- When { Maxwell.start! }
29
- Then { expect(Maxwell).to be_running }
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
- Maxwell.start!
34
- runner = Maxwell.runner
33
+ Agent.start!
34
+ runner = Agent.runner
35
35
 
36
36
  Celluloid.shutdown
37
37
  Celluloid.boot
38
- Maxwell.start!
38
+ Agent.start!
39
39
 
40
- expect(Maxwell.runner).to_not be runner
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.1
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: celluoid
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