ibm-bluemix-service_discovery 0.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 597a238027842295e33f43e08e25b39847ac6aca
4
- data.tar.gz: fdc70a7cb6989938debebfec5a763f77220ece5d
3
+ metadata.gz: 0fbba1e59deb4c85155c932c5c1bdef09b177e87
4
+ data.tar.gz: cc598b0b48e1831c25467699aa50377bf2bb0f4d
5
5
  SHA512:
6
- metadata.gz: b260ec7e61925ef9a25e22e977f438af59175428fb948053151cc5dd9a836cf7662a864a0b4f62a1fc3d541d8fef5d6cf761ceca556a2448711a5991b59dcf4b
7
- data.tar.gz: d2804500cfa05138004fff236b273adcf9f0dc73b364211df6d05dc0da39dee81eae5235b25b1cc3c3fd815c0603f8ac77ae374a5caccbfa9564a6c48b018885
6
+ metadata.gz: 9a4f2b919fd8244824f2fec320e1ea2a4b28ca211f7023b9bfb5abfb5f18bcf55ee9f60f9fc3c5de974b901ae6349e3234c2aca0c4b4f8c98617cc2f42b834e9
7
+ data.tar.gz: d4a73e7ad3c633a361de1bc2cfbcb96c287a9f87c7f12ac2ca4d3f0e6c37424ed10f5b44e16d06dca23bca381d510aa8088ae8c1e698a3233ab83fe5fbc9f3c1
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
+ spec.required_ruby_version = '>= 1.9.3'
31
+
30
32
  spec.add_dependency "unirest", "~> 1.1"
31
33
 
32
34
  spec.add_development_dependency "bundler", "~> 1.11"
@@ -18,6 +18,8 @@ module IBM
18
18
  # URL for the production Bluemix Service Registry endpoint
19
19
  SERVICE_REGISTRY_ENDPOINT = "https://servicediscovery.ng.bluemix.net/api/v1/instances"
20
20
 
21
+ private_constant :SERVICE_DISCOVERY_ENDPOINT, :SERVICE_REGISTRY_ENDPOINT
22
+
21
23
  # cache of registered services
22
24
  @@services = {}
23
25
 
@@ -26,8 +28,14 @@ module IBM
26
28
 
27
29
  # dummy logger that can be overridden
28
30
  class << self
31
+ # logger attribute that can be overridden
29
32
  attr_writer :logger
30
33
 
34
+ # Logger function that should be overridden.
35
+ #
36
+ # @example
37
+ # logger.debug 'this is a debug message'
38
+ #
31
39
  def logger
32
40
  @logger ||= Logger.new($stdout).tap do |log|
33
41
  log.progname = self.name
@@ -37,11 +45,11 @@ module IBM
37
45
 
38
46
  # Create a new ServiceDiscovery instance.
39
47
  #
40
- # Example:
41
- # >> sd = ServiceDiscovery.new('token...')
48
+ # @example
49
+ # sd = ServiceDiscovery.new('token...')
50
+ #
51
+ # @param auth_token [String] Valid `auth_token` from the IBM Bluemix Service Discovery service
42
52
  #
43
- # ===Arguments
44
- # [auth_token] (String) Valid `auth_token` from the IBM Bluemix Service Discovery service
45
53
  def initialize(auth_token)
46
54
  @auth_token = auth_token
47
55
 
@@ -55,24 +63,17 @@ module IBM
55
63
 
56
64
  # Register a service with Service Discovery
57
65
  #
58
- # Example:
59
- # >> sd = ServiceDiscovery.new('token...')
66
+ # @example
67
+ # sd = ServiceDiscovery.new('token...')
60
68
  # => sd.register('sample_service', '192.168.1.100:8080', { ttl: 60, heartbeat: true }, {})
61
69
  #
62
- # ===Arguments
63
- # [service_name] (String) The name of the microservice
64
- # [host] (String) The host and port where the microservice can be reached at
65
- # [options] (Hash) Options, see below
66
- # [meta] (Hash) Metadata to store with the service registration
67
- #
68
- # ====Options
69
- # [heartbeat] (Boolean) Enable or disable automated heartbeat for the service
70
- # [ttl] (Integer) Expire the service after this many seconds if a heartbeat has not been received. Hearbeat is automatically set to 30% of this value
71
- #
72
- # ===Returns
73
- # resulting payload from the call to Service Discovery
74
- #
75
- # ===Raises
70
+ # @param service_name [String] The name of the microservice
71
+ # @param host [String] The host and port where the microservice can be reached at
72
+ # @param options [Hash] Options to customize service discovery instance (see below)
73
+ # @option options [Boolean] :heartbeat Enable or disable automated heartbeat for the service
74
+ # @option options [Integer] :ttl Expire the service after this many seconds if a heartbeat has not been received. Hearbeat is automatically set to 30% of this value
75
+ # @param meta [Hash] Metadata to store with the service registration
76
+ # @return [Hash] Resulting payload from the call to Service Discovery
76
77
  #
77
78
  def register(service_name, host, options = {}, meta = {})
78
79
 
@@ -134,16 +135,11 @@ module IBM
134
135
 
135
136
  # Send a heartbeat request to indicate the service is still alive and well
136
137
  #
137
- # Example:
138
- # >> sd.renew('sample_service')
139
- #
140
- # ===Arguments
141
- # [service_name] (String) The name of the microservice
138
+ # @example
139
+ # sd.renew('sample_service')
142
140
  #
143
- # ===Returns
144
- # (Boolean) `true` if the service was renewed, `false` otherwise
145
- #
146
- # ===Raises
141
+ # @param service_name [String] The name of the microservice
142
+ # @return [Boolean] `true` if the service was renewed, `false` otherwise
147
143
  #
148
144
  def renew(service_name)
149
145
 
@@ -175,17 +171,12 @@ module IBM
175
171
  # Set-up a separate Thread to send continuous heartbeats (renew) calls to
176
172
  # indicate the service is alive.
177
173
  #
178
- # Example:
179
- # >> sd.heartbeat('sample_service', 45)
180
- #
181
- # ===Arguments
182
- # [service_name] (String) The name of the microservice
183
- # [interval] (Integer) The number of seconds between heartbeats
184
- #
185
- # ===Returns
186
- # (Boolean) `true` if the heartbeat thread was started, `false` otherwise
174
+ # @example
175
+ # sd.heartbeat('sample_service', 45)
187
176
  #
188
- # ===Raises
177
+ # @param service_name [String] The name of the microservice
178
+ # @param interval [Integer] The number of seconds between heartbeats
179
+ # @return [Boolean] `true` if the heartbeat thread was started, `false` otherwise
189
180
  #
190
181
  def heartbeat(service_name, interval=60)
191
182
 
@@ -211,16 +202,11 @@ module IBM
211
202
 
212
203
  # Stops a previously established heartbeat Thread
213
204
  #
214
- # Example:
215
- # >> sd.unheartbeat('sample_service')
216
- #
217
- # ===Arguments
218
- # [service_name] (String) The name of the microservice
219
- #
220
- # ===Returns
221
- # (Boolean) `true` if the heartbeat thread was stopped, `false` otherwise
205
+ # @example
206
+ # sd.unheartbeat('sample_service')
222
207
  #
223
- # ===Raises
208
+ # @param service_name [String] The name of the microservice
209
+ # @return [Boolean] `true` if the heartbeat thread was stopped, `false` otherwise
224
210
  #
225
211
  def unheartbeat(service_name)
226
212
  Thread.kill @@heartbeats[service_name]
@@ -228,16 +214,11 @@ module IBM
228
214
 
229
215
  # Deletes a service entry from Service Discovery
230
216
  #
231
- # Example:
232
- # >> sd.delete('sample_service')
217
+ # @example
218
+ # sd.delete('sample_service')
233
219
  #
234
- # ===Arguments
235
- # [service_name] (String) The name of the microservice
236
- #
237
- # ===Returns
238
- # (Boolean) `true` if the service was removed, `false` otherwise
239
- #
240
- # ===Raises
220
+ # @param service_name [String] The name of the microservice
221
+ # @return [Boolean] `true` if the service was removed, `false` otherwise
241
222
  #
242
223
  def delete(service_name)
243
224
 
@@ -265,16 +246,10 @@ module IBM
265
246
  # Resets the state of this service. This includes stopping any existing
266
247
  # heartbeat Threads as well as deleting all registered services.
267
248
  #
268
- # Example:
269
- # >> sd.reset
270
- #
271
- # ===Arguments
272
- # +none+
249
+ # @example
250
+ # sd.reset
273
251
  #
274
- # ===Returns
275
- # (Boolean) `true` if the reset was successful, `false` otherwise
276
- #
277
- # ===Raises
252
+ # @return [Boolean] `true` if the reset was successful, `false` otherwise
278
253
  #
279
254
  def reset
280
255
 
@@ -294,16 +269,10 @@ module IBM
294
269
  # Returns information about the current local state of Service Discovery.
295
270
  # This includes information about the services and the heartbeats.
296
271
  #
297
- # Example:
298
- # >> sd.info
299
- #
300
- # ===Arguments
301
- # +none+
272
+ # @example
273
+ # sd.info
302
274
  #
303
- # ===Returns
304
- # (Hash) { services: ['s1', 's2'], heartbeats: ['s1'] }
305
- #
306
- # ===Raises
275
+ # @return [Hash] { services: ['s1', 's2'], heartbeats: ['s1'] }
307
276
  #
308
277
  def info
309
278
  { services: @@services.keys, heartbeats: heartbeats.keys }
@@ -311,16 +280,10 @@ module IBM
311
280
 
312
281
  # Get the current list of registered services within Service Discovery
313
282
  #
314
- # Example:
315
- # >> sd.list
316
- #
317
- # ===Arguments
318
- # +none+
319
- #
320
- # ===Returns
321
- # (Hash) { services: ['s1', 's2'] }
283
+ # @example
284
+ # sd.list
322
285
  #
323
- # ===Raises
286
+ # @return [Hash] { services: ['s1', 's2'] }
324
287
  #
325
288
  def list
326
289
 
@@ -343,14 +306,11 @@ module IBM
343
306
 
344
307
  # Discovers the connection information for a given microservice.
345
308
  #
346
- # Example:
347
- # >> sd.discover('sample_service')
309
+ # @example
310
+ # sd.discover('sample_service')
348
311
  #
349
- # ===Arguments
350
- # [service_name] (String) The name of the microservice
351
- #
352
- # ===Returns
353
- # (Hash)
312
+ # @param service_name [String] The name of the microservice
313
+ # @return [Hash]
354
314
  # {
355
315
  # "service_name":"my_service",
356
316
  # "instances":[
@@ -366,8 +326,6 @@ module IBM
366
326
  # }]
367
327
  # }
368
328
  #
369
- # ===Raises
370
- #
371
329
  def discover(service_name)
372
330
  # curl -X GET -H "Authorization: bearer 12o191sqk5h***" https://servicediscovery.ng.bluemix.net/api/v1/services/my_service
373
331
 
@@ -1,7 +1,7 @@
1
1
  module IBM
2
2
  module Bluemix
3
3
  class ServiceDiscovery
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm-bluemix-service_discovery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Young
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: 1.9.3
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="