instructure_registrar 0.1.5 → 0.1.6

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: d8d966a02f606b48b0c108707709a8dc983e4e7c
4
- data.tar.gz: 4484c684c7f10b26a8dc764f57c422efd77bbb14
3
+ metadata.gz: 5014c511426370b1e307bae148c02a4bae3066f5
4
+ data.tar.gz: 1109145f1f76673ce160c54cf77231c25ecced80
5
5
  SHA512:
6
- metadata.gz: 571b83a9c91bcaf49c02e9c9a2f445788f418a59baccc2c0167a973f5592ec4cd965e8c00dea550b569e7b5ea3215d56c72ed8cd7f189d692d62a80fcac5e5b8
7
- data.tar.gz: 0ac1ca86547d61a857546ccd031228f703879bda0dc0042349ea2f33da6d1674830ffdfd90b3c48347a27316d876eb14dcadd3f5e0284660314ba973ab971a39
6
+ metadata.gz: 217ecd296dd5ae1d84338cd41f8c7b6130baafb00ba5e2f9966dc647f48e9787b7866d2a1cb2e2eb51e7e55b4a4a7ec3d9a2cb6565cdacd68657b8d804faa79f
7
+ data.tar.gz: 475366f301ba26f164da32f544b301d1ea10211813c29a00deb4e30e8b4bdec4b985735a209a767ca60066cc3a666114782238babb87f14becba65499c32547a
@@ -3,6 +3,20 @@ module InstructureRegistrar
3
3
 
4
4
  require 'etcd'
5
5
 
6
+ attr_reader :server_available
7
+
8
+ def initialize
9
+ @server_available = healthcheck
10
+ end
11
+
12
+ def healthcheck
13
+ begin
14
+ client.version
15
+ rescue
16
+ false
17
+ end
18
+ end
19
+
6
20
  def lookup(service_name)
7
21
  begin
8
22
  client.get("/#{service_name}").value
@@ -12,6 +26,7 @@ module InstructureRegistrar
12
26
  end
13
27
 
14
28
  def register
29
+ return unless server_available
15
30
  client.set(
16
31
  "/#{InstructureRegistrar.config.service_name}",
17
32
  value: "#{InstructureRegistrar.config.service_host}:#{InstructureRegistrar.config.service_port}"
@@ -19,7 +34,12 @@ module InstructureRegistrar
19
34
  end
20
35
 
21
36
  def unregister
22
- client.delete("/#{InstructureRegistrar.config.service_name}")
37
+ return unless server_available
38
+ begin
39
+ client.delete("/#{InstructureRegistrar.config.service_name}")
40
+ rescue Etcd::KeyNotFound
41
+ false
42
+ end
23
43
  end
24
44
 
25
45
  private
@@ -1,3 +1,3 @@
1
1
  module InstructureRegistrar
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instructure_registrar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - CoralineAda