mamiya 0.0.1.alpha18 → 0.0.1.alpha19

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: 6db58a4aec3a8f7f2929cd2664c6e303f902bb9c
4
- data.tar.gz: e37776e176631e187e95a8b6b2775d33180a8ac3
3
+ metadata.gz: 37666b908bc503abe07629a7308eeb762be79cf7
4
+ data.tar.gz: aef8d218df47dcdb03e5ff069d7e3a5c4a78a13b
5
5
  SHA512:
6
- metadata.gz: 7f2675131a259a228697439db198a6394b6e0c9b4fd8d7934c98cc2c47a32e40ebfe67eba878dd1ded48ef299351ba6a6bec9aa17252081847539256082ff265
7
- data.tar.gz: fb8a0ffb6701073386fcd62a22de3f5d5f7140c420ce0eced26c270037dc141ba5f8b94e1bcf2d214963b1fea25cfd3d5c7b01c90de6696217975c485411b067
6
+ metadata.gz: ada7d2968785edd0b9b1f51dfa53d4d8da428ca87f3e85562d05a0505553fe16b303e60d07d6478e090ff7183996a4dcc16322ac21f70038f61e181dd7d31efa
7
+ data.tar.gz: 044f922700e0f5d873058564b263108ef3ee7350084a5561e17550c205f45b37526ef0e1b347ad3788bb51ba080db71e1b32814b2708310e33c9e9b23367f913
data/lib/mamiya/agent.rb CHANGED
@@ -119,11 +119,11 @@ module Mamiya
119
119
  ]
120
120
  end
121
121
 
122
- def trigger(type, action: nil, **payload)
122
+ def trigger(type, action: nil, coalesce: true, **payload)
123
123
  name = "mamiya:#{type}"
124
124
  name << ":#{action}" if action
125
125
 
126
- serf.event(name, payload.to_json)
126
+ serf.event(name, payload.to_json, coalesce: coalesce)
127
127
  end
128
128
 
129
129
  private
@@ -190,12 +190,10 @@ module Mamiya
190
190
  end
191
191
 
192
192
  def cleanup_handler(app, package)
193
- serf.event(FETCH_REMOVE_EVENT,
194
- {
195
- name: self.serf.name,
196
- application: app,
197
- package: package,
198
- }.to_json
193
+ trigger('fetch-result', action: 'remove', coalesce: false,
194
+ name: self.serf.name,
195
+ application: app,
196
+ package: package,
199
197
  )
200
198
  end
201
199
  end
@@ -1,10 +1,12 @@
1
1
  module Mamiya
2
2
  class Agent
3
3
  module Actions
4
+ # XXX: dupe?
4
5
  def distribute(application, package)
5
6
  trigger('fetch',
6
7
  application: application,
7
8
  package: package,
9
+ coalesce: false
8
10
  )
9
11
  end
10
12
  end
@@ -15,13 +15,15 @@ module Mamiya
15
15
  ].freeze
16
16
 
17
17
  def run!
18
+ # XXX: Why don't use agent#trigger ...
18
19
  agent.serf.event(FETCH_ACK_EVENT,
19
20
  {
20
21
  name: agent.serf.name,
21
22
  application: payload['application'],
22
23
  package: payload['package'],
23
24
  pending: agent.fetcher.queue_size.succ,
24
- }.to_json
25
+ }.to_json,
26
+ coalesce: false,
25
27
  )
26
28
 
27
29
  agent.fetcher.enqueue(
@@ -33,7 +35,8 @@ module Mamiya
33
35
  application: payload['application'],
34
36
  package: payload['package'],
35
37
  pending: agent.fetcher.queue_size.succ,
36
- }.to_json
38
+ }.to_json,
39
+ coalesce: false,
37
40
  )
38
41
  agent.update_tags!
39
42
  }
@@ -48,7 +51,8 @@ module Mamiya
48
51
  package: payload['package'],
49
52
  error: error.class,
50
53
  pending: agent.fetcher.queue_size,
51
- }.to_json
54
+ }.to_json,
55
+ coalesce: false,
52
56
  )
53
57
  rescue Villein::Client::SerfError => e
54
58
  agent.logger.error "error sending fetch error event: #{e.inspect}"
@@ -60,7 +64,8 @@ module Mamiya
60
64
  application: payload['application'],
61
65
  package: payload['package'],
62
66
  pending: agent.fetcher.queue_size,
63
- }.to_json
67
+ }.to_json,
68
+ coalesce: false,
64
69
  )
65
70
  end
66
71
 
data/lib/mamiya/master.rb CHANGED
@@ -38,8 +38,9 @@ module Mamiya
38
38
  super
39
39
  end
40
40
 
41
+ # XXX: dupe? Mamiya::Agent::Actions#distribute
41
42
  def distribute(application, package)
42
- trigger(:fetch, application: application, package: package)
43
+ trigger(:fetch, coalesce: false, application: application, package: package)
43
44
  end
44
45
 
45
46
  def storage(app)
@@ -15,6 +15,8 @@ module Mamiya
15
15
  status['fetcher'] ||= {}
16
16
  status['fetcher']['fetching'] = [payload['application'], payload['package']]
17
17
 
18
+ logger.debug "#{status['name']} started to fetch #{payload['application']}/#{payload['package']}"
19
+
18
20
  status['fetcher']['pending_jobs'] ||= []
19
21
  status['fetcher']['pending_jobs'].delete [payload['application'], payload['package']]
20
22
  end
@@ -22,6 +24,8 @@ module Mamiya
22
24
  def fetch_result__error(status, payload, event)
23
25
  status['fetcher'] ||= {}
24
26
 
27
+ logger.error "#{status['name']} failed to fetch #{payload['application']}/#{payload['package']}: #{payload['error']}"
28
+
25
29
  if status['fetcher']['fetching'] == [payload['application'], payload['package']]
26
30
  status['fetcher']['fetching'] = nil
27
31
  end
@@ -30,6 +34,8 @@ module Mamiya
30
34
  def fetch_result__success(status, payload, event)
31
35
  status['fetcher'] ||= {}
32
36
 
37
+ logger.info "#{status['name']} fetched #{payload['application']}/#{payload['package']}"
38
+
33
39
  if status['fetcher']['fetching'] == [payload['application'], payload['package']]
34
40
  status['fetcher']['fetching'] = nil
35
41
  end
@@ -1,3 +1,3 @@
1
1
  module Mamiya
2
- VERSION = "0.0.1.alpha18"
2
+ VERSION = "0.0.1.alpha19"
3
3
  end
@@ -28,7 +28,8 @@ describe Mamiya::Agent::Actions do
28
28
  it "sends fetch request" do
29
29
  expect(serf).to receive(:event).with(
30
30
  'mamiya:fetch',
31
- {application: 'app', package: 'pkg'}.to_json
31
+ {application: 'app', package: 'pkg'}.to_json,
32
+ coalesce: false
32
33
  )
33
34
 
34
35
  agent.distribute('app', 'pkg')
@@ -44,7 +44,9 @@ describe Mamiya::Agent::Handlers::Fetch do
44
44
  it "responds ack" do
45
45
  allow(fetcher).to receive(:enqueue).with('app', 'package')
46
46
  expect(serf).to receive(:event).with('mamiya:fetch-result:ack',
47
- {name: serf.name, application: 'app', package: 'package', pending: 1}.to_json)
47
+ {name: serf.name, application: 'app', package: 'package', pending: 1}.to_json,
48
+ coalesce: false,
49
+ )
48
50
 
49
51
  handler.run!
50
52
  end
@@ -62,7 +64,9 @@ describe Mamiya::Agent::Handlers::Fetch do
62
64
  options[:before].call
63
65
  end
64
66
  expect(serf).to receive(:event).with('mamiya:fetch-result:start',
65
- {name: serf.name, application: 'app', package: 'package', pending: 1}.to_json)
67
+ {name: serf.name, application: 'app', package: 'package', pending: 1}.to_json,
68
+ coalesce: false
69
+ )
66
70
 
67
71
  handler.run!
68
72
  end
@@ -77,7 +81,8 @@ describe Mamiya::Agent::Handlers::Fetch do
77
81
 
78
82
  expect(serf).to receive(:event).with(
79
83
  'mamiya:fetch-result:success',
80
- {name: serf.name, application: 'app', package: 'package', pending: 0}.to_json
84
+ {name: serf.name, application: 'app', package: 'package', pending: 0}.to_json,
85
+ coalesce: false
81
86
  )
82
87
 
83
88
  callback.call
@@ -104,6 +109,7 @@ describe Mamiya::Agent::Handlers::Fetch do
104
109
  name: serf.name, application: 'app', package: 'package',
105
110
  error: error.class, pending: 0,
106
111
  }.to_json,
112
+ coalesce: false,
107
113
  )
108
114
 
109
115
  callback.call(error)
data/spec/agent_spec.rb CHANGED
@@ -45,6 +45,7 @@ describe Mamiya::Agent do
45
45
  {
46
46
  name: serf.name, application: 'foo', package: 'bar',
47
47
  }.to_json,
48
+ coalesce: false,
48
49
  )
49
50
 
50
51
  agent.fetcher.cleanup_hook.call('foo', 'bar')
data/spec/master_spec.rb CHANGED
@@ -50,7 +50,7 @@ describe Mamiya::Master do
50
50
  # end
51
51
 
52
52
  it "triggers fetch event" do
53
- expect(master).to receive(:trigger).with(:fetch, application: 'myapp', package: 'mypackage')
53
+ expect(master).to receive(:trigger).with(:fetch, coalesce: false, application: 'myapp', package: 'mypackage')
54
54
 
55
55
  master.distribute('myapp', 'mypackage')
56
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mamiya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha18
4
+ version: 0.0.1.alpha19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor