etcd 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +1 -1
- data/lib/etcd/client.rb +38 -2
- data/lib/etcd/version.rb +1 -1
- metadata +27 -5
- checksums.yaml +0 -15
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/etcd/client.rb
CHANGED
@@ -37,26 +37,38 @@ module Etcd
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
# Currently use 'v1' as version for etcd store
|
40
41
|
def version_prefix
|
41
42
|
'/v1'
|
42
43
|
end
|
43
44
|
|
45
|
+
# Lists all machines in the cluster
|
44
46
|
def machines
|
45
|
-
api_execute( version_prefix + '/machines', :get).split(",")
|
47
|
+
api_execute( version_prefix + '/machines', :get).split(",").map(&:strip)
|
46
48
|
end
|
47
49
|
|
50
|
+
# Get the current leader in a cluster
|
48
51
|
def leader
|
49
52
|
api_execute( version_prefix + '/leader', :get)
|
50
53
|
end
|
51
54
|
|
55
|
+
# Lists all the data (keys, dir etc) present in etcd store
|
52
56
|
def key_endpoint
|
53
57
|
version_prefix + '/keys'
|
54
58
|
end
|
55
59
|
|
60
|
+
# Watches all keys and notifies if anyone changes
|
56
61
|
def watch_endpoint
|
57
62
|
version_prefix + '/watch'
|
58
63
|
end
|
59
64
|
|
65
|
+
# Set a new value for key if previous value of key is matched
|
66
|
+
#
|
67
|
+
# This method takes following parameters as argument
|
68
|
+
# * key - whose value is going to change if previous value is matched
|
69
|
+
# * value - new value to be set for specified key
|
70
|
+
# * prevValue - value of a key to compare with existing value of key
|
71
|
+
# * ttl - shelf life of a key (in secsonds) (optional)
|
60
72
|
def test_and_set(key, value, prevValue, ttl = nil)
|
61
73
|
path = key_endpoint + key
|
62
74
|
payload = {'value' => value, 'prevValue' => prevValue }
|
@@ -65,6 +77,12 @@ module Etcd
|
|
65
77
|
json2obj(response)
|
66
78
|
end
|
67
79
|
|
80
|
+
# Adds a new key with specified value and ttl, overwrites old values if exists
|
81
|
+
#
|
82
|
+
# This method has following parameters as argument
|
83
|
+
# * key - whose value to be set
|
84
|
+
# * value - value to be set for specified key
|
85
|
+
# * ttl - shelf life of a key (in secsonds) (optional)
|
68
86
|
def set(key, value, ttl=nil)
|
69
87
|
path = key_endpoint + key
|
70
88
|
payload = {'value' => value}
|
@@ -73,17 +91,29 @@ module Etcd
|
|
73
91
|
json2obj(response)
|
74
92
|
end
|
75
93
|
|
76
|
-
|
94
|
+
# Deletes a key along with all associated data
|
95
|
+
#
|
96
|
+
# This method has following parameters as argument
|
97
|
+
# * key - key to be deleted
|
77
98
|
def delete(key)
|
78
99
|
response = api_execute(key_endpoint + key, :delete)
|
79
100
|
json2obj(response)
|
80
101
|
end
|
81
102
|
|
103
|
+
# Retrives a key with its associated data, if key is not present it will return with message "Key Not Found"
|
104
|
+
#
|
105
|
+
# This method has following parameters as argument
|
106
|
+
# * key - whose data to be retrive
|
82
107
|
def get(key)
|
83
108
|
response = api_execute(key_endpoint + key, :get)
|
84
109
|
json2obj(response)
|
85
110
|
end
|
86
111
|
|
112
|
+
# Gives a notification when specified key changes
|
113
|
+
#
|
114
|
+
# This method has following parameters as argument
|
115
|
+
# * key - key to be watched
|
116
|
+
# * index - etcd server index of specified key (optional)
|
87
117
|
def watch(key, index=nil)
|
88
118
|
response = if index.nil?
|
89
119
|
api_execute(watch_endpoint + key, :get)
|
@@ -93,6 +123,12 @@ module Etcd
|
|
93
123
|
json2obj(response)
|
94
124
|
end
|
95
125
|
|
126
|
+
# This method sends api request to etcd server.
|
127
|
+
#
|
128
|
+
# This method has following parameters as argument
|
129
|
+
# * path - etcd server path (etcd server end point)
|
130
|
+
# * method - the request method used
|
131
|
+
# * params - any additional parameters used by request method (optional)
|
96
132
|
def api_execute(path, method, params=nil)
|
97
133
|
|
98
134
|
http = if path=~/^http/
|
data/lib/etcd/version.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etcd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Ranjib Dey
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: mixlib-cli
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: mixlib-log
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: uuid
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -55,6 +62,7 @@ dependencies:
|
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: bundler
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
67
|
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
@@ -62,6 +70,7 @@ dependencies:
|
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
75
|
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
@@ -69,6 +78,7 @@ dependencies:
|
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rake
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
83
|
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
@@ -76,6 +86,7 @@ dependencies:
|
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
91
|
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
@@ -83,6 +94,7 @@ dependencies:
|
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: rspec
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
99
|
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
@@ -90,6 +102,7 @@ dependencies:
|
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
107
|
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
@@ -97,6 +110,7 @@ dependencies:
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: simplecov
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
115
|
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
@@ -104,6 +118,7 @@ dependencies:
|
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
123
|
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
@@ -144,26 +159,33 @@ files:
|
|
144
159
|
homepage: https://github.com/ranjib/etcd-ruby
|
145
160
|
licenses:
|
146
161
|
- MIT
|
147
|
-
metadata: {}
|
148
162
|
post_install_message:
|
149
163
|
rdoc_options: []
|
150
164
|
require_paths:
|
151
165
|
- lib
|
152
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
153
168
|
requirements:
|
154
169
|
- - ! '>='
|
155
170
|
- !ruby/object:Gem::Version
|
156
171
|
version: '0'
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
hash: -924240572325429270
|
157
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
158
177
|
requirements:
|
159
178
|
- - ! '>='
|
160
179
|
- !ruby/object:Gem::Version
|
161
180
|
version: '0'
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
hash: -924240572325429270
|
162
184
|
requirements: []
|
163
185
|
rubyforge_project:
|
164
|
-
rubygems_version:
|
186
|
+
rubygems_version: 1.8.23
|
165
187
|
signing_key:
|
166
|
-
specification_version:
|
188
|
+
specification_version: 3
|
167
189
|
summary: Ruby client library for etcd
|
168
190
|
test_files:
|
169
191
|
- spec/functional/client_spec.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
MzNhZWZiNTA1ZjAzOTQ0ZjQ4YjUzOTIyZTZiNjEwZGVkZWJkYzllZg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Y2ZlOTY4YTcxYTNkNzRhZGRhZDBlNzRlYWUyNjk2Y2VmMzBjYWFmYg==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YTU1YjdhMmVhNTM1ZWFlOTc3ZmQwN2ZlNDM2N2EyNTI0ZTVjN2FkNTljMzc2
|
10
|
-
ODZhYjdiNTU4YmE3NGE0NjdiY2M2MDhhM2VmNWEzZTQ0OTBmMjViYmI3MWVj
|
11
|
-
MTkxZjI1YWM4NTU5OWUzMmRiYmY5MzcyNzg0YzljN2Y2OWQ5Njg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjJlNWY1NjQyNmQ0YmU1Y2M1ZTkxYTY3NzRhOTc3Mjc0ODUxODYxOGE2NGY0
|
14
|
-
NDE3ZWFkZjMzMGFlNzZhYWIyZTRhMTE5NDUyMjZkNWE3Y2Y4MTI4NzQ4YmRh
|
15
|
-
ZGM0MGRlNDM5ZGQ4MzNkN2JhNmEzMTVhN2QzNWNhNjY1NjkyZWM=
|