arborist 0.1.0 → 0.2.0.pre20170519125456

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
- SHA1:
3
- metadata.gz: cc3ce9e3d25176605f9895778c5654b57e8aa1c0
4
- data.tar.gz: 4528bd2bcc17d925a9ea2ce63c475117839e98cd
2
+ SHA256:
3
+ metadata.gz: f3104a401cf16ca97836a2311dac418944a103e610652a98fa2395b826b04ab4
4
+ data.tar.gz: 9d3bc6f71f0a204011e2d3e277a3a7e769194eecdfcbb603aaf427d5b9e4d98e
5
5
  SHA512:
6
- metadata.gz: fd351f828f9d9dd9738541d93d852f82a7a12bcda91f1e4a7bda5bd38adedbf3da6fe52e7f729eab2f0d0678f71cd6b953ce449532e1b1cd9da14d18076a49c2
7
- data.tar.gz: 3ac9921a9a8fc177ccba6036ab1fa00682cfc6ee892e7fde5aa3db34c5dc2832b32fd5a6e3f59518d8b4a9956b48a36ca39e10a83ff3b57dae895c845c5bf800
6
+ metadata.gz: ed5105cc83f993a12a8634fa8ef7256dc385b93ebbb92ce713bd7cb601d92ca23bbe1aafa34d5085e36c9d6e1f8956eeb5dc8d6d9b96048563016df2b059372e
7
+ data.tar.gz: 468e3ef96f4518938feeb4612143868beb1912120b1b3394189afdc860581de0f71344ab02dfba457c0ca777459ee1c2e5031ef3cab103a3e9cacffdc87b98f4
data/ChangeLog CHANGED
@@ -1,14 +1,58 @@
1
+ 2017-02-19 Mahlon E. Smith <mahlon@martini.nu>
2
+
3
+ * .ruby-gemset, .ruby-version, .rvmrc, Rakefile:
4
+ Convert to .ruby-* files. Bump msgpack dependency.
5
+ [b0cead421802] [github/master, tip]
6
+
7
+ 2017-01-02 Michael Granger <ged@FaerieMUD.org>
8
+
9
+ * .hgignore, Rakefile:
10
+ Remove guard against public release, ignore pkg dir
11
+ [4e6a4471c246]
12
+
13
+ * .hgtags:
14
+ Added tag v0.1.0 for changeset 859b70361b14
15
+ [83809e3f33bc]
16
+
17
+ * .hgsigs:
18
+ Added signature for changeset 02a11882f53b
19
+ [859b70361b14] [v0.1.0]
20
+
21
+ * History.md, lib/arborist.rb:
22
+ Set the minor version, update history file.
23
+ [02a11882f53b]
24
+
25
+ * TODO.md, lib/arborist/monitor.rb, lib/arborist/monitor_runner.rb,
26
+ spec/arborist/monitor_runner_spec.rb, spec/arborist/monitor_spec.rb:
27
+ Fix the DSL constructor, set the monitor key in the correct place in
28
+ the node data.
29
+ [e12d602bcf1a]
30
+
1
31
  2016-12-28 Michael Granger <ged@FaerieMUD.org>
2
32
 
33
+ * Monitors.md, lib/arborist/monitor_runner.rb, lib/arborist/node.rb,
34
+ spec/arborist/node_spec.rb:
35
+ Add `key` to the monitor docs, use a prefixed key for monitor
36
+ updates.
37
+ [7119b40e002a]
38
+
39
+ * arborist.gemspec, lib/arborist/command/watch.rb,
40
+ lib/arborist/monitor.rb, lib/arborist/monitor_runner.rb,
41
+ lib/arborist/node.rb, spec/arborist/event/node_down_spec.rb,
42
+ spec/arborist/manager_spec.rb, spec/arborist/monitor_runner_spec.rb,
43
+ spec/arborist/monitor_spec.rb, spec/arborist/node_spec.rb:
44
+ Add a key attribute to monitors for error grouping.
45
+ [aebc20335e43]
46
+
3
47
  * .gems, Rakefile:
4
48
  Update to latest *ability
5
- [09438b7a8aff] [tip]
49
+ [09438b7a8aff]
6
50
 
7
51
  2016-10-19 Michael Granger <ged@FaerieMUD.org>
8
52
 
9
53
  * lib/arborist/client.rb:
10
54
  Use ** instead of * for client methods that take keyword args
11
- [73b6f150a8c1] [github/master]
55
+ [73b6f150a8c1]
12
56
 
13
57
  * lib/arborist/mixins.rb, lib/arborist/node.rb,
14
58
  spec/arborist/client_spec.rb:
data/Manifest.txt CHANGED
@@ -31,12 +31,11 @@ lib/arborist/event/node_quieted.rb
31
31
  lib/arborist/event/node_unknown.rb
32
32
  lib/arborist/event/node_up.rb
33
33
  lib/arborist/event/node_update.rb
34
+ lib/arborist/event_api.rb
34
35
  lib/arborist/exceptions.rb
35
36
  lib/arborist/loader.rb
36
37
  lib/arborist/loader/file.rb
37
38
  lib/arborist/manager.rb
38
- lib/arborist/manager/event_publisher.rb
39
- lib/arborist/manager/tree_api.rb
40
39
  lib/arborist/mixins.rb
41
40
  lib/arborist/monitor.rb
42
41
  lib/arborist/monitor/socket.rb
@@ -52,15 +51,15 @@ lib/arborist/observer/action.rb
52
51
  lib/arborist/observer/summarize.rb
53
52
  lib/arborist/observer_runner.rb
54
53
  lib/arborist/subscription.rb
54
+ lib/arborist/tree_api.rb
55
55
  spec/arborist/client_spec.rb
56
56
  spec/arborist/dependency_spec.rb
57
57
  spec/arborist/event/node_delta_spec.rb
58
58
  spec/arborist/event/node_down_spec.rb
59
59
  spec/arborist/event/node_spec.rb
60
60
  spec/arborist/event/node_update_spec.rb
61
+ spec/arborist/event_api_spec.rb
61
62
  spec/arborist/event_spec.rb
62
- spec/arborist/manager/event_publisher_spec.rb
63
- spec/arborist/manager/tree_api_spec.rb
64
63
  spec/arborist/manager_spec.rb
65
64
  spec/arborist/mixins_spec.rb
66
65
  spec/arborist/monitor/socket_spec.rb
@@ -77,6 +76,7 @@ spec/arborist/observer/summarize_spec.rb
77
76
  spec/arborist/observer_runner_spec.rb
78
77
  spec/arborist/observer_spec.rb
79
78
  spec/arborist/subscription_spec.rb
79
+ spec/arborist/tree_api_spec.rb
80
80
  spec/arborist_spec.rb
81
81
  spec/data/monitors/pings.rb
82
82
  spec/data/monitors/port_checks.rb
data/Rakefile CHANGED
@@ -38,12 +38,14 @@ hoespec = Hoe.spec 'arborist' do |spec|
38
38
  spec.dependency 'configurability', '~> 3.0'
39
39
  spec.dependency 'pluggability', '~> 0.4'
40
40
  spec.dependency 'state_machines', '~> 0.2'
41
- spec.dependency 'msgpack', '~> 0.6'
42
- spec.dependency 'rbczmq', '~> 1.7'
41
+ spec.dependency 'msgpack', '~> 1.0'
42
+ spec.dependency 'cztop', '~> 0.11'
43
+ spec.dependency 'cztop-reactor', '~> 0.3'
43
44
  spec.dependency 'gli', '~> 2.3'
44
45
  spec.dependency 'highline', '~> 1.7'
45
46
 
46
47
  spec.dependency 'rspec', '~> 3.2', :developer
48
+ spec.dependency 'rspec-wait', '~> 0.0', :developer
47
49
  spec.dependency 'simplecov', '~> 0.9', :developer
48
50
  spec.dependency 'timecop', '~> 0.7', :developer
49
51
 
@@ -84,13 +86,13 @@ if File.directory?( '.hg' )
84
86
  end
85
87
  end
86
88
 
87
- task :gemspec => [ 'ChangeLog', GEMSPEC ]
89
+ task :gemspec => [ 'ChangeLog', __FILE__, GEMSPEC ]
88
90
  file GEMSPEC => __FILE__ do |task|
89
91
  spec = $hoespec.spec
90
92
  spec.files.delete( '.gemtest' )
91
93
  spec.files.delete( 'LICENSE' )
92
94
  spec.signing_key = nil
93
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
95
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
94
96
  spec.cert_chain = [ 'certs/ged.pem' ]
95
97
  File.open( task.name, 'w' ) do |fh|
96
98
  fh.write( spec.to_ruby )
data/TODO.md CHANGED
@@ -28,9 +28,25 @@
28
28
 
29
29
  * Ask a node (via tree-api or otherwise) what nodes it affects (immediate children, secondary dependents)
30
30
 
31
+ * Clarify the Tree API:
32
+
33
+ - Rename `list` to `fetch`
34
+ - Return identified node `node.to_h`
35
+ - Return identified node and its children in a hierarchy `node.to_h(true)`
36
+ - Return identified node and its children as a flattened list
37
+
38
+ - Rename `fetch` to `search`
39
+ - returns list of nodes which satisfy positive/negative criteria
40
+
41
+
31
42
  ### Observers
32
43
 
33
44
  * Action dependencies -- as an example, if an action sends an email,
34
45
  don't trigger if the email service is offline. Potential action
35
46
  "chains", ie: If the email service is down, use a separate
36
47
  out-of-band action that sends SMS.
48
+
49
+ ### Monitors
50
+
51
+ Add a one-shot runner command for development of monitors. Loads and runs a monitor one time, maybe with some output describing how often it'd run, what its skew is, etc. [will@laika]
52
+
data/lib/arborist.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- ruby -*-
2
2
  #encoding: utf-8
3
3
 
4
- require 'rbczmq'
4
+ require 'cztop'
5
5
 
6
6
  require 'pathname'
7
7
  require 'configurability'
@@ -17,7 +17,7 @@ module Arborist
17
17
  VERSION = '0.1.0'
18
18
 
19
19
  # Version control revision
20
- REVISION = %q$Revision: 02a11882f53b $
20
+ REVISION = %q$Revision: 17a8567d86e2 $
21
21
 
22
22
 
23
23
  # The name of the environment variable which can be used to set the config path
@@ -29,49 +29,33 @@ module Arborist
29
29
  # The name of the config file that's loaded if none is specified.
30
30
  DEFAULT_CONFIG_FILE = Pathname( 'arborist.yml' ).expand_path
31
31
 
32
- # Configurability API -- default configuration values
33
- CONFIG_DEFAULTS = {
34
- tree_api_url: 'ipc:///tmp/arborist_tree.sock',
35
- event_api_url: 'ipc:///tmp/arborist_events.sock',
36
- }
37
-
38
32
 
39
33
  ##
40
34
  # Set up a logger for the Arborist namespace
41
35
  log_as :arborist
42
36
 
43
37
  # Configurability API -- use the 'arborist'
44
- config_key :arborist
38
+ configurability( :arborist ) do
45
39
 
40
+ ##
41
+ # The ZMQ REP socket for the API for accessing the node tree.
42
+ setting :tree_api_url, default: 'ipc:///tmp/arborist_tree.sock'
46
43
 
47
- require 'arborist/mixins'
48
- extend Arborist::MethodUtilities
44
+ ##
45
+ # The ZMQ PUB socket for published events
46
+ setting :event_api_url, default: 'ipc:///tmp/arborist_events.sock'
49
47
 
48
+ end
50
49
 
51
- ##
52
- # The ZMQ REP socket for the API for accessing the node tree.
53
- singleton_attr_accessor :tree_api_url
54
- @tree_api_url = CONFIG_DEFAULTS[ :tree_api_url ]
55
50
 
56
- ##
57
- # The ZMQ PUB socket for published events
58
- singleton_attr_accessor :event_api_url
59
- @event_api_url = CONFIG_DEFAULTS[ :event_api_url ]
51
+ require 'arborist/mixins'
52
+ extend Arborist::MethodUtilities
60
53
 
61
54
 
62
55
  #
63
56
  # :section: Configuration API
64
57
  #
65
58
 
66
- ### Configurability API.
67
- def self::configure( config=nil )
68
- config = self.defaults.merge( config || {} )
69
-
70
- self.tree_api_url = config[ :tree_api_url ]
71
- self.event_api_url = config[ :event_api_url ]
72
- end
73
-
74
-
75
59
  ### Get the loaded config (a Configurability::Config object)
76
60
  def self::config
77
61
  Configurability.loaded_config
@@ -159,29 +143,6 @@ module Arborist
159
143
  end
160
144
 
161
145
 
162
- ### Destroy any existing ZMQ state.
163
- def self::reset_zmq_context
164
- @zmq_context.destroy if @zmq_context.respond_to?( :destroy )
165
- @zmq_context = nil
166
- end
167
-
168
-
169
- ### Fetch the ZMQ context for Arborist.
170
- def self::zmq_context
171
- return @zmq_context ||= begin
172
- self.log.info "Using ZeroMQ %s/CZMQ %s" %
173
- [ ZMQ.version.join('.'), ZMQ.czmq_version.join('.') ]
174
- ZMQ::Context.new
175
- end
176
- end
177
-
178
-
179
- ### Set the ZMQ context if it's already been created by something else.
180
- def self::zmq_context=( existing_context )
181
- @zmq_context = existing_context
182
- end
183
-
184
-
185
146
  require 'arborist/exceptions'
186
147
  require 'arborist/mixins'
187
148
 
@@ -1,9 +1,11 @@
1
1
  # -*- ruby -*-
2
2
  #encoding: utf-8
3
3
 
4
- require 'arborist' unless defined?( Arborist )
5
4
  require 'msgpack'
6
5
 
6
+ require 'arborist' unless defined?( Arborist )
7
+ require 'arborist/tree_api'
8
+
7
9
 
8
10
  # Unified Arborist Manager client for both the Tree and Event APIs
9
11
  class Arborist::Client
@@ -30,10 +32,10 @@ class Arborist::Client
30
32
  public
31
33
  ######
32
34
 
33
- # The ZMQ URI required to speak to the Arborist tree API.
35
+ # The ZeroMQ URI required to speak to the Arborist tree API.
34
36
  attr_accessor :tree_api_url
35
37
 
36
- # The ZMQ URI required to speak to the Arborist event API.
38
+ # The ZeroMQ URI required to speak to the Arborist event API.
37
39
  attr_accessor :event_api_url
38
40
 
39
41
 
@@ -87,7 +89,7 @@ class Arborist::Client
87
89
 
88
90
  ### Return the manager's current status as a hash.
89
91
  def make_status_request
90
- return self.pack_message( :status )
92
+ return Arborist::TreeAPI.request( :status )
91
93
  end
92
94
 
93
95
 
@@ -105,13 +107,13 @@ class Arborist::Client
105
107
  header[:from] = from if from
106
108
  header[:depth] = depth if depth
107
109
 
108
- return self.pack_message( :list, header )
110
+ return Arborist::TreeAPI.request( :list, header )
109
111
  end
110
112
 
111
113
 
112
114
  ### Return the manager's current node tree.
113
- def fetch( criteria={}, **args )
114
- request = self.make_fetch_request( criteria, **args )
115
+ def fetch( criteria={}, options={} )
116
+ request = self.make_fetch_request( criteria, **options )
115
117
  return self.send_tree_api_request( request )
116
118
  end
117
119
 
@@ -122,7 +124,7 @@ class Arborist::Client
122
124
  header[ :include_down ] = true if include_down
123
125
  header[ :return ] = properties if properties != :all
124
126
 
125
- return self.pack_message( :fetch, header, [ criteria, exclude ] )
127
+ return Arborist::TreeAPI.request( :fetch, header, [ criteria, exclude ] )
126
128
  end
127
129
 
128
130
 
@@ -136,7 +138,7 @@ class Arborist::Client
136
138
 
137
139
  ### Update the identified nodes in the manager with the specified data.
138
140
  def make_update_request( data )
139
- return self.pack_message( :update, nil, data )
141
+ return Arborist::TreeAPI.request( :update, nil, data )
140
142
  end
141
143
 
142
144
 
@@ -144,7 +146,7 @@ class Arborist::Client
144
146
  def subscribe( **args )
145
147
  request = self.make_subscribe_request( **args )
146
148
  response = self.send_tree_api_request( request )
147
- return response.first
149
+ return response['id']
148
150
  end
149
151
 
150
152
 
@@ -156,7 +158,7 @@ class Arborist::Client
156
158
  header[ :identifier ] = identifier if identifier
157
159
  header[ :event_type ] = event_type
158
160
 
159
- return self.pack_message( :subscribe, header, [ criteria, exclude ] )
161
+ return Arborist::TreeAPI.request( :subscribe, header, [ criteria, exclude ] )
160
162
  end
161
163
 
162
164
 
@@ -172,7 +174,7 @@ class Arborist::Client
172
174
  def make_unsubscribe_request( subid )
173
175
  self.log.debug "Making unsubscribe request for subid: %s" % [ subid ]
174
176
 
175
- return self.pack_message( :unsubscribe, subscription_id: subid )
177
+ return Arborist::TreeAPI.request( :unsubscribe, subscription_id: subid )
176
178
  end
177
179
 
178
180
 
@@ -188,7 +190,7 @@ class Arborist::Client
188
190
  def make_prune_request( identifier )
189
191
  self.log.debug "Making prune request for identifier: %s" % [ identifier ]
190
192
 
191
- return self.pack_message( :prune, identifier: identifier )
193
+ return Arborist::TreeAPI.request( :prune, identifier: identifier )
192
194
  end
193
195
 
194
196
 
@@ -213,7 +215,7 @@ class Arborist::Client
213
215
  type: type
214
216
  }
215
217
 
216
- return self.pack_message( :graft, header, attributes )
218
+ return Arborist::TreeAPI.request( :graft, header, attributes )
217
219
  end
218
220
 
219
221
 
@@ -229,7 +231,7 @@ class Arborist::Client
229
231
  def make_modify_request( identifier, attributes={} )
230
232
  self.log.debug "Making modify request for identifer: %s" % [ identifier ]
231
233
 
232
- return self.pack_message( :modify, {identifier: identifier}, attributes )
234
+ return Arborist::TreeAPI.request( :modify, {identifier: identifier}, attributes )
233
235
  end
234
236
 
235
237
 
@@ -237,12 +239,12 @@ class Arborist::Client
237
239
  ### unsuccessful response, and return the response body.
238
240
  def send_tree_api_request( request )
239
241
  self.log.debug "Sending request: %p" % [ request ]
240
- self.tree_api.send( request )
242
+ request.send_to( self.tree_api )
241
243
 
242
- res = self.tree_api.recv
244
+ res = CZTop::Message.receive_from( self.tree_api )
243
245
  self.log.debug "Received response: %p" % [ res ]
244
246
 
245
- header, body = self.unpack_message( res )
247
+ header, body = Arborist::TreeAPI.decode( res )
246
248
  unless header[ 'success' ]
247
249
  raise "Arborist manager said: %s" % [ header['reason'] ]
248
250
  end
@@ -255,26 +257,7 @@ class Arborist::Client
255
257
  # Utility methods
256
258
  #
257
259
 
258
- ### Format ruby +data+ for communicating with the Arborist manager.
259
- def pack_message( verb, *data )
260
- header = data.shift || {}
261
- body = data.shift
262
-
263
- header.merge!( action: verb, version: API_VERSION )
264
-
265
- self.log.debug "Packing message; header: %p, body: %p" % [ header, body ]
266
-
267
- return MessagePack.pack([ header, body ])
268
- end
269
-
270
-
271
- ### De-serialize an Arborist manager response.
272
- def unpack_message( msg )
273
- return MessagePack.unpack( msg )
274
- end
275
-
276
-
277
- ### Return a ZMQ REQ socket connected to the manager's tree API, instantiating
260
+ ### Return a ZeroMQ REQ socket connected to the manager's tree API, instantiating
278
261
  ### it if necessary.
279
262
  def tree_api
280
263
  return @tree_api ||= self.make_tree_api_socket
@@ -284,10 +267,7 @@ class Arborist::Client
284
267
  ### Create a new ZMQ REQ socket connected to the manager's tree API.
285
268
  def make_tree_api_socket
286
269
  self.log.info "Connecting to the tree socket %p" % [ self.tree_api_url ]
287
- sock = Arborist.zmq_context.socket( :REQ )
288
- sock.connect( self.tree_api_url )
289
-
290
- return sock
270
+ return CZTop::Socket::REQ.new( self.tree_api_url )
291
271
  end
292
272
 
293
273
 
@@ -301,10 +281,7 @@ class Arborist::Client
301
281
  ### Create a new ZMQ SUB socket connected to the manager's event API.
302
282
  def make_event_api_socket
303
283
  self.log.info "Connecting to the event socket %p" % [ self.event_api_url ]
304
- sock = Arborist.zmq_context.socket( :SUB )
305
- sock.connect( self.event_api_url )
306
-
307
- return sock
284
+ return CZTop::Socket::SUB.new( self.event_api_url )
308
285
  end
309
286
 
310
287
  end # class Arborist::Client