diplomat 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diplomat/service.rb +30 -1
- data/lib/diplomat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09450d2e223b6c427a4a9c08baf350f71942619f
|
4
|
+
data.tar.gz: ecdb5da0593f8c23cfe33243e73425955b5185e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de68de63837165d8317e6549273bd2a563c5b16f7050785cc94ca25eef7580aff0054e0f5130c848e13b03df287bc8cd13e58484b0bab925a5c7242d83d10325
|
7
|
+
data.tar.gz: 4ddd450e82c8d0bab4381c62dff895931fa74baad7a5c7179995ceed4a31d5edaeed19e2c97aac59139be6d2b6e31e42b91a0c947125e71dd35cda9847017065
|
data/lib/diplomat/service.rb
CHANGED
@@ -3,6 +3,8 @@ require 'faraday'
|
|
3
3
|
|
4
4
|
module Diplomat
|
5
5
|
class Service < Diplomat::RestClient
|
6
|
+
REGISTER_URL = '/v1/agent/service/register'
|
7
|
+
DEREGISTER_URL = '/v1/agent/service/deregister'
|
6
8
|
|
7
9
|
# Get a service by it's key
|
8
10
|
# @param key [String] the key
|
@@ -42,9 +44,36 @@ module Diplomat
|
|
42
44
|
return OpenStruct.new JSON.parse(ret.body).first
|
43
45
|
end
|
44
46
|
|
47
|
+
# Register a service
|
48
|
+
# @param definition [Hash] Hash containing definition of service
|
49
|
+
# @return [Boolean]
|
50
|
+
def register(definition)
|
51
|
+
json_definition = JSON.dump(definition)
|
52
|
+
register = @conn.put Service::REGISTER_URL, json_definition
|
53
|
+
return register.status == 200
|
54
|
+
end
|
55
|
+
|
56
|
+
# De-register a service
|
57
|
+
# @param service_name [String] Service name to de-register
|
58
|
+
# @return [Boolean]
|
59
|
+
def deregister(service_name)
|
60
|
+
deregister = @conn.get "#{Service::DEREGISTER_URL}/#{service_name}"
|
61
|
+
return deregister.status == 200
|
62
|
+
end
|
63
|
+
|
45
64
|
# @note This is sugar, see (#get)
|
46
65
|
def self.get *args
|
47
|
-
new(*args).get
|
66
|
+
Diplomat::Service.new(*args).get
|
67
|
+
end
|
68
|
+
|
69
|
+
# @note This is sugar, see (#register)
|
70
|
+
def self.register definition
|
71
|
+
Diplomat::Service.new.register definition
|
72
|
+
end
|
73
|
+
|
74
|
+
# @note This is sugar, see (#deregister)
|
75
|
+
def self.deregister service_name
|
76
|
+
Diplomat::Service.new.deregister service_name
|
48
77
|
end
|
49
78
|
|
50
79
|
end
|
data/lib/diplomat/version.rb
CHANGED