vayacondios-client 0.2.11 → 0.3.0

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.
Files changed (62) hide show
  1. data/.gitignore +64 -0
  2. data/.travis.yml +13 -0
  3. data/CHANGELOG.md +0 -0
  4. data/Gemfile +21 -0
  5. data/LICENSE.md +95 -0
  6. data/Procfile +2 -0
  7. data/README.md +734 -0
  8. data/Rakefile +93 -0
  9. data/bin/vcd +10 -0
  10. data/config/database.yml +6 -0
  11. data/config/spec.example.yml +18 -0
  12. data/config/vayacondios.example.yml +15 -0
  13. data/examples/configuration.rb +56 -0
  14. data/examples/event_stream.rb +19 -0
  15. data/examples/simple.rb +61 -0
  16. data/features/event.feature +319 -0
  17. data/features/events.feature +208 -0
  18. data/features/stash.feature +840 -0
  19. data/features/stashes.feature +492 -0
  20. data/features/step_definitions/stash_steps.rb +113 -0
  21. data/features/stream.feature +30 -0
  22. data/features/support/em.rb +14 -0
  23. data/features/support/env.rb +13 -0
  24. data/lib/vayacondios/client/cli.rb +456 -0
  25. data/lib/vayacondios/client/configuration.rb +13 -0
  26. data/lib/vayacondios/client/connection.rb +39 -0
  27. data/lib/vayacondios/client/http_client.rb +6 -42
  28. data/lib/vayacondios/client/http_methods.rb +85 -0
  29. data/lib/vayacondios/client.rb +21 -0
  30. data/lib/vayacondios/configuration.rb +63 -0
  31. data/lib/vayacondios-client.rb +16 -17
  32. data/lib/vayacondios.rb +22 -0
  33. data/pom.xml +168 -0
  34. data/spec/client/cli_spec.rb +283 -0
  35. data/spec/client/configuration_spec.rb +11 -0
  36. data/spec/client/http_client_spec.rb +150 -0
  37. data/spec/configuration_spec.rb +41 -0
  38. data/spec/spec_helper.rb +27 -0
  39. data/spec/support/database_helper.rb +42 -0
  40. data/spec/support/log_helper.rb +19 -0
  41. data/spec/support/shared_context_for_events.rb +22 -0
  42. data/spec/support/shared_context_for_stashes.rb +24 -0
  43. data/spec/support/shared_examples_for_handlers.rb +32 -0
  44. data/src/main/java/com/infochimps/vayacondios/BaseClient.java +342 -0
  45. data/src/main/java/com/infochimps/vayacondios/HTTPClient.java +426 -0
  46. data/src/main/java/com/infochimps/vayacondios/VayacondiosClient.java +500 -0
  47. data/src/main/java/com/infochimps/vayacondios/test/IntegrationTest.java +3 -0
  48. data/src/test/java/com/infochimps/vayacondios/BaseClientTest.java +50 -0
  49. data/src/test/java/com/infochimps/vayacondios/HTTPClientIT.java +267 -0
  50. data/vayacondios-client.gemspec +25 -0
  51. metadata +96 -60
  52. checksums.yaml +0 -15
  53. data/lib/vayacondios/client/config.rb +0 -7
  54. data/lib/vayacondios/client/configliere.rb +0 -38
  55. data/lib/vayacondios/client/cube_client.rb +0 -39
  56. data/lib/vayacondios/client/itemset.rb +0 -130
  57. data/lib/vayacondios/client/legacy_switch.rb +0 -43
  58. data/lib/vayacondios/client/notifier.rb +0 -123
  59. data/lib/vayacondios/client/zabbix_client.rb +0 -148
  60. data/spec/client/itemset_legacy_spec.rb +0 -55
  61. data/spec/client/itemset_spec.rb +0 -60
  62. data/spec/client/notifier_spec.rb +0 -120
@@ -0,0 +1,267 @@
1
+ package com.infochimps.vayacondios;
2
+
3
+ import java.util.Map;
4
+ import java.util.HashMap;
5
+ import java.util.List;
6
+ import java.util.ArrayList;
7
+ import java.util.Set;
8
+
9
+ import java.net.UnknownHostException;
10
+
11
+ import org.junit.Before;
12
+ import org.junit.After;
13
+ import org.junit.Test;
14
+ import org.junit.Ignore;
15
+ import org.junit.runner.RunWith;
16
+ import org.junit.runners.JUnit4;
17
+ import static org.junit.Assert.assertEquals;
18
+ import com.infochimps.vayacondios.test.IntegrationTest;
19
+ import org.junit.experimental.categories.Category;
20
+
21
+ import com.mongodb.MongoClient;
22
+ import com.mongodb.DB;
23
+
24
+ @RunWith(JUnit4.class)
25
+ @Category(IntegrationTest.class)
26
+ public class HTTPClientIT {
27
+
28
+ private String organization = "organization";
29
+ private String topic = "topic";
30
+ private String id = "id";
31
+
32
+ private HTTPClient client;
33
+
34
+ private Map event() {
35
+ Map e = new HashMap();
36
+ e.put("foo", "bar");
37
+ e.put("baz", 12.0);
38
+ return e;
39
+ }
40
+
41
+ private List list() {
42
+ List l = new ArrayList();
43
+ l.add(1.0);
44
+ l.add("2");
45
+ l.add("three");
46
+ return l;
47
+ }
48
+
49
+ private Map stash() {
50
+ Map s = new HashMap();
51
+ s.put("map", event());
52
+ s.put("list", list());
53
+ s.put("string", "hello");
54
+ s.put("double", 3.1415);
55
+ return s;
56
+ }
57
+
58
+ private Map query() {
59
+ Map q = new HashMap();
60
+ q.put("foo", "bar");
61
+ return q;
62
+ }
63
+
64
+ @Before
65
+ public void createClient() {
66
+ client = new HTTPClient(organization);
67
+ }
68
+
69
+ @Before
70
+ public void cleanMongo() {
71
+ try {
72
+ MongoClient mongo = new MongoClient( "localhost" , 27017 );
73
+ DB database = mongo.getDB( "vayacondios_test" );
74
+ Set<String> collections = database.getCollectionNames();
75
+ for (String collection : collections) {
76
+ if (! collection.matches("^system.*$")) {
77
+ database.getCollection(collection).drop();
78
+ }
79
+ }
80
+ } catch (UnknownHostException e) {
81
+ System.err.println("Could not connect to MongoDB, aborting");
82
+ }
83
+ }
84
+
85
+ @After
86
+ public void closeClient() throws InterruptedException {
87
+ client.close();
88
+ }
89
+
90
+ @Test
91
+ public void canGetSetHost() {
92
+ assertEquals(client.host(), HTTPClient.DEFAULT_HOST);
93
+ }
94
+
95
+ @Test
96
+ public void canGetSetPort() {
97
+ assertEquals(client.port(), HTTPClient.DEFAULT_PORT);
98
+ }
99
+
100
+ @Test
101
+ public void eventsEmpty() {
102
+ assertEquals(0, client.events(topic, query()).size());
103
+ }
104
+
105
+ @Test
106
+ public void announce() {
107
+ client.announce(topic, event());
108
+ client.announce(topic, event());
109
+ client.announce(topic, event());
110
+ assertEquals(3, client.events(topic, query()).size());
111
+ }
112
+
113
+ @Test
114
+ public void announceWithId() {
115
+ client.announce(topic, event(), "1");
116
+ client.announce(topic, event(), "2");
117
+ client.announce(topic, event(), "2");
118
+ assertEquals(2, client.events(topic, query()).size());
119
+ }
120
+
121
+ @Test
122
+ public void get() {
123
+ client.set(topic, stash());
124
+ Map s = client.get(topic);
125
+ assertEquals("hello", s.get("string"));
126
+ assertEquals(3.1415, s.get("double"));
127
+ }
128
+
129
+ @Test
130
+ public void getMap() {
131
+ client.set(topic, stash());
132
+ Map e = client.getMap(topic, "map");
133
+ assertEquals("bar", e.get("foo"));
134
+ }
135
+
136
+ @Test
137
+ public void getList() {
138
+ client.set(topic, stash());
139
+ List l = client.getList(topic, "list");
140
+ assertEquals("2", l.get(1));
141
+ assertEquals("three", l.get(2));
142
+ }
143
+
144
+ @Test
145
+ public void getString() {
146
+ client.set(topic, stash());
147
+ String s = client.getString(topic, "string");
148
+ assertEquals("hello", s);
149
+ }
150
+
151
+ @Test
152
+ public void getDouble() {
153
+ client.set(topic, stash());
154
+ Double d = client.getDouble(topic, "double");
155
+ assertEquals((Double) 3.1415, d);
156
+ }
157
+
158
+ @Test
159
+ public void setOverwrites() {
160
+ client.set(topic, stash());
161
+ client.set(topic, event());
162
+ Map s = client.get(topic);
163
+ assertEquals(null, s.get("string"));
164
+ assertEquals("bar", s.get("foo"));
165
+ }
166
+
167
+ @Test
168
+ public void setWithIdMapOverwrites() {
169
+ client.set(topic, stash());
170
+ client.set(topic, "map", stash());
171
+ Map s = client.getMap(topic, "map");
172
+ assertEquals(null, s.get("foo"));
173
+ assertEquals("hello", s.get("string"));
174
+ }
175
+
176
+ @Test
177
+ public void setWithIdListOvewrites() {
178
+ client.set(topic, stash());
179
+ List ol = list();
180
+ ol.set(0, "WOW");
181
+ client.set(topic, "list", ol);
182
+ List nl = client.getList(topic, "list");
183
+ assertEquals("WOW", nl.get(0));
184
+ assertEquals("2", nl.get(1));
185
+ }
186
+
187
+ @Test
188
+ public void setWithIdStringOvewrites() {
189
+ client.set(topic, stash());
190
+ client.set(topic, "string", "goodbye");
191
+ String s = client.getString(topic, "string");
192
+ assertEquals("goodbye", s);
193
+ }
194
+
195
+ @Test
196
+ public void setWithIdDoubleOvewrites() {
197
+ client.set(topic, stash());
198
+ client.set(topic, "double", 2.718);
199
+ Double d = client.getDouble(topic, "double");
200
+ assertEquals((double) 2.718, d, 0.001);
201
+ }
202
+
203
+ @Test
204
+ public void mergeMerges() {
205
+ Map s = stash();
206
+ client.set(topic, s);
207
+ s.put("newstring", "goodbye");
208
+ client.set(topic, s);
209
+
210
+ s = client.get(topic);
211
+ assertEquals("hello", s.get("string"));
212
+ assertEquals("goodbye", s.get("newstring"));
213
+ }
214
+
215
+ @Test
216
+ public void mergeWithIdMapMerges() throws InterruptedException {
217
+ client.set(topic, stash());
218
+ Map e = new HashMap();
219
+ e.put("bang", "boof");
220
+ client.merge(topic, "map", e);
221
+ Thread.sleep(100); // need to give the server time to process the merge
222
+ Map s = client.getMap(topic, "map");
223
+ assertEquals("bar", s.get("foo"));
224
+ assertEquals("boof", s.get("bang"));
225
+ }
226
+
227
+ public void mergeWithIdListConcatenates() throws InterruptedException {
228
+ client.set(topic, stash());
229
+ client.merge(topic, "list", list());
230
+ Thread.sleep(100); // need to give the server time to process the merge
231
+ List l = client.getList(topic, "list");
232
+ assertEquals(6, l.size());
233
+ }
234
+
235
+ public void mergeWithIdStringConcatenates() throws InterruptedException {
236
+ client.set(topic, stash());
237
+ client.merge(topic, "string", "goodbye");
238
+ Thread.sleep(100); // need to give the server time to process the merge
239
+ String s = client.getString(topic, "string");
240
+ assertEquals("hellogoodbye", s);
241
+ }
242
+
243
+ public void mergeWithIdDoubleIncrements() throws InterruptedException {
244
+ client.set(topic, stash());
245
+ client.merge(topic, "double", 3.1415);
246
+ Thread.sleep(100); // need to give the server time to process the merge
247
+ Double d = client.getDouble(topic, "double");
248
+ assertEquals((double) 6.2830, d, 0.001);
249
+ }
250
+
251
+ public void delete() throws InterruptedException {
252
+ client.set(topic, stash());
253
+ client.delete(topic);
254
+ Thread.sleep(100); // need to give the server time to process the delete
255
+ Map s = client.get(topic);
256
+ assertEquals(null, s);
257
+ }
258
+
259
+ public void deleteWithId() throws InterruptedException {
260
+ client.set(topic, stash());
261
+ client.delete(topic, "map");
262
+ Thread.sleep(100); // need to give the server time to process the delete
263
+ Map s = client.getMap(topic, "map");
264
+ assertEquals(null, s);
265
+ }
266
+
267
+ }
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.push File.expand_path('../lib', __FILE__)
4
+ require 'vayacondios'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'vayacondios-client'
8
+ gem.version = Vayacondios::GEM_VERSION
9
+ gem.authors = ['Philip (flip) Kromer', 'Travis Dempsey', 'Huston Hoburg', 'Logan Lowell', 'Dhruv Bansal']
10
+ gem.homepage = 'https://github.com/infochimps-labs/vayacondios'
11
+ gem.email = 'coders@infochimps.com'
12
+ gem.licenses = ['Apache 2.0']
13
+ gem.summary = 'Data goes in. The right thing happens'
14
+ gem.description = "Simple enough to use in a shell script, performant enough to use everywhere. Dios mío! Record that metric, ese!"
15
+
16
+ gem.files = `git ls-files`.split("\n").reject{ |f| f =~ /server/ }
17
+ gem.executables = ['vcd']
18
+ gem.test_files = gem.files.grep(/^spec/)
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.add_dependency('configliere')
22
+ gem.add_dependency('multi_json')
23
+ gem.add_dependency('faraday', '= 0.8.9')
24
+ gem.add_dependency('faraday_middleware')
25
+ end
metadata CHANGED
@@ -1,146 +1,182 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vayacondios-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Philip (flip) Kromer
8
9
  - Travis Dempsey
9
10
  - Huston Hoburg
10
11
  - Logan Lowell
12
+ - Dhruv Bansal
11
13
  autorequire:
12
14
  bindir: bin
13
15
  cert_chain: []
14
- date: 2013-08-08 00:00:00.000000000 Z
16
+ date: 2014-02-18 00:00:00.000000000 Z
15
17
  dependencies:
16
18
  - !ruby/object:Gem::Dependency
17
19
  name: configliere
18
20
  requirement: !ruby/object:Gem::Requirement
21
+ none: false
19
22
  requirements:
20
23
  - - ! '>='
21
24
  - !ruby/object:Gem::Version
22
- version: 0.4.16
25
+ version: '0'
23
26
  type: :runtime
24
27
  prerelease: false
25
28
  version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
26
30
  requirements:
27
31
  - - ! '>='
28
32
  - !ruby/object:Gem::Version
29
- version: 0.4.16
33
+ version: '0'
30
34
  - !ruby/object:Gem::Dependency
31
35
  name: multi_json
32
36
  requirement: !ruby/object:Gem::Requirement
37
+ none: false
33
38
  requirements:
34
39
  - - ! '>='
35
40
  - !ruby/object:Gem::Version
36
- version: 1.3.6
41
+ version: '0'
37
42
  type: :runtime
38
43
  prerelease: false
39
44
  version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
40
46
  requirements:
41
47
  - - ! '>='
42
48
  - !ruby/object:Gem::Version
43
- version: 1.3.6
49
+ version: '0'
44
50
  - !ruby/object:Gem::Dependency
45
- name: gorillib
51
+ name: faraday
46
52
  requirement: !ruby/object:Gem::Requirement
53
+ none: false
47
54
  requirements:
48
- - - ! '>='
55
+ - - '='
49
56
  - !ruby/object:Gem::Version
50
- version: 0.4.2
57
+ version: 0.8.9
51
58
  type: :runtime
52
59
  prerelease: false
53
60
  version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
54
62
  requirements:
55
- - - ! '>='
63
+ - - '='
56
64
  - !ruby/object:Gem::Version
57
- version: 0.4.2
65
+ version: 0.8.9
58
66
  - !ruby/object:Gem::Dependency
59
- name: rake
67
+ name: faraday_middleware
60
68
  requirement: !ruby/object:Gem::Requirement
69
+ none: false
61
70
  requirements:
62
71
  - - ! '>='
63
72
  - !ruby/object:Gem::Version
64
73
  version: '0'
65
- type: :development
74
+ type: :runtime
66
75
  prerelease: false
67
76
  version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
68
78
  requirements:
69
79
  - - ! '>='
70
80
  - !ruby/object:Gem::Version
71
81
  version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: yard
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0.7'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0.7'
86
- - !ruby/object:Gem::Dependency
87
- name: rspec
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ! '>='
91
- - !ruby/object:Gem::Version
92
- version: '2.8'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '2.8'
100
82
  description: Simple enough to use in a shell script, performant enough to use everywhere.
101
83
  Dios mío! Record that metric, ese!
102
- email:
103
- executables: []
84
+ email: coders@infochimps.com
85
+ executables:
86
+ - vcd
104
87
  extensions: []
105
88
  extra_rdoc_files: []
106
89
  files:
90
+ - .gitignore
91
+ - .travis.yml
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - LICENSE.md
95
+ - Procfile
96
+ - README.md
97
+ - Rakefile
98
+ - bin/vcd
99
+ - config/database.yml
100
+ - config/spec.example.yml
101
+ - config/vayacondios.example.yml
102
+ - examples/configuration.rb
103
+ - examples/event_stream.rb
104
+ - examples/simple.rb
105
+ - features/event.feature
106
+ - features/events.feature
107
+ - features/stash.feature
108
+ - features/stashes.feature
109
+ - features/step_definitions/stash_steps.rb
110
+ - features/stream.feature
111
+ - features/support/em.rb
112
+ - features/support/env.rb
107
113
  - lib/vayacondios-client.rb
108
- - lib/vayacondios/client/config.rb
109
- - lib/vayacondios/client/configliere.rb
110
- - lib/vayacondios/client/cube_client.rb
114
+ - lib/vayacondios.rb
115
+ - lib/vayacondios/client.rb
116
+ - lib/vayacondios/client/cli.rb
117
+ - lib/vayacondios/client/configuration.rb
118
+ - lib/vayacondios/client/connection.rb
111
119
  - lib/vayacondios/client/http_client.rb
112
- - lib/vayacondios/client/itemset.rb
113
- - lib/vayacondios/client/legacy_switch.rb
114
- - lib/vayacondios/client/notifier.rb
115
- - lib/vayacondios/client/zabbix_client.rb
116
- - spec/client/itemset_legacy_spec.rb
117
- - spec/client/itemset_spec.rb
118
- - spec/client/notifier_spec.rb
120
+ - lib/vayacondios/client/http_methods.rb
121
+ - lib/vayacondios/configuration.rb
122
+ - pom.xml
123
+ - spec/client/cli_spec.rb
124
+ - spec/client/configuration_spec.rb
125
+ - spec/client/http_client_spec.rb
126
+ - spec/configuration_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/support/database_helper.rb
129
+ - spec/support/log_helper.rb
130
+ - spec/support/shared_context_for_events.rb
131
+ - spec/support/shared_context_for_stashes.rb
132
+ - spec/support/shared_examples_for_handlers.rb
133
+ - src/main/java/com/infochimps/vayacondios/BaseClient.java
134
+ - src/main/java/com/infochimps/vayacondios/HTTPClient.java
135
+ - src/main/java/com/infochimps/vayacondios/VayacondiosClient.java
136
+ - src/main/java/com/infochimps/vayacondios/test/IntegrationTest.java
137
+ - src/test/java/com/infochimps/vayacondios/BaseClientTest.java
138
+ - src/test/java/com/infochimps/vayacondios/HTTPClientIT.java
139
+ - vayacondios-client.gemspec
119
140
  homepage: https://github.com/infochimps-labs/vayacondios
120
- licenses: []
121
- metadata: {}
141
+ licenses:
142
+ - Apache 2.0
122
143
  post_install_message:
123
144
  rdoc_options: []
124
145
  require_paths:
125
146
  - lib
126
147
  required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
127
149
  requirements:
128
150
  - - ! '>='
129
151
  - !ruby/object:Gem::Version
130
152
  version: '0'
153
+ segments:
154
+ - 0
155
+ hash: -3142814313644370706
131
156
  required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
132
158
  requirements:
133
159
  - - ! '>='
134
160
  - !ruby/object:Gem::Version
135
161
  version: '0'
162
+ segments:
163
+ - 0
164
+ hash: -3142814313644370706
136
165
  requirements: []
137
166
  rubyforge_project:
138
- rubygems_version: 2.0.5
167
+ rubygems_version: 1.8.23
139
168
  signing_key:
140
- specification_version: 4
169
+ specification_version: 3
141
170
  summary: Data goes in. The right thing happens
142
171
  test_files:
143
- - spec/client/itemset_legacy_spec.rb
144
- - spec/client/itemset_spec.rb
145
- - spec/client/notifier_spec.rb
172
+ - spec/client/cli_spec.rb
173
+ - spec/client/configuration_spec.rb
174
+ - spec/client/http_client_spec.rb
175
+ - spec/configuration_spec.rb
176
+ - spec/spec_helper.rb
177
+ - spec/support/database_helper.rb
178
+ - spec/support/log_helper.rb
179
+ - spec/support/shared_context_for_events.rb
180
+ - spec/support/shared_context_for_stashes.rb
181
+ - spec/support/shared_examples_for_handlers.rb
146
182
  has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MmEzMjBjNzFlYzE5OTc5N2VmZTBlNDc5MjAwNWMxZWYzNGE3OTIwNQ==
5
- data.tar.gz: !binary |-
6
- OTFmNjUzOGU3YzNmODk2ZWM3ZDgyMzJhNjlkNmNiNDhiZDZmZDY5Yw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YWZmYTVhZTFlODg2YTZjNWM2Mzc0Mjk2M2FiMTg1MTEyOGFmYTA3NmZkYjMw
10
- YzBhMTgyNmFiZTFkNjZjYTcwNmQyYWUzZGEyY2Q1YWRmMGQxMWFkNGFiYzlk
11
- OWI1Y2Y4ZGFiZDlmZWQ2NzcxNzZkNjM5NWU5YTI3ZDY3MzY3MWM=
12
- data.tar.gz: !binary |-
13
- ZDQyZmQ2Yzc4MDJmZGMzZjQwN2QwNThkZjQ5ZjljZjNlMjg2YWNlNTE2NmJk
14
- YzM4NjM2ZDYzY2FiMmY3MWE5YjA5MTY2MThmOWM2YTFkYjY4NmEzNTAzZWQz
15
- M2Q1ZDg3NDAyZTlmZDk4MTlhMjc3ZmIyMTczNzFjYWJkMjk2NWU=
@@ -1,7 +0,0 @@
1
- def ENV.root_path(*args)
2
- File.expand_path(File.join(File.dirname(__FILE__), '../../../', *args))
3
- end
4
-
5
- require 'configliere'
6
-
7
- Settings.read(ENV.root_path('config/vayacondios.yaml'))
@@ -1,38 +0,0 @@
1
- class Vayacondios
2
- module Configliere
3
-
4
- def load_from_vayacondios(organization, id, options = {})
5
- options.symbolize_keys!.deep_merge!(organization: organization)
6
-
7
- client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
8
- id = [id, options[:env]].compact.join('.')
9
-
10
- begin
11
- new_data = client.fetch(:config, id)
12
- rescue ::Vayacondios::HttpClient::Error
13
- warn "Unable to load vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
14
- new_data = {}
15
- end
16
- deep_merge! new_data
17
- self
18
- end
19
-
20
- def save_to_vayacondios(organization, id, options = {})
21
- options.symbolize_keys!.deep_merge!(organization: organization)
22
-
23
- client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
24
- id = [id, options[:env]].compact.join('.')
25
-
26
- begin
27
- client.insert(self.to_hash, :config, id)
28
- rescue ::Vayacondios::HttpClient::Error
29
- warn "Unable to save vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
30
- end
31
- self
32
- end
33
- end
34
- end
35
-
36
- ::Configliere::Param.class_eval do
37
- include ::Vayacondios::Configliere
38
- end
@@ -1,39 +0,0 @@
1
- class Vayacondios
2
- class CubeClient
3
- include Gorillib::Model
4
-
5
- field :host, String, :default => 'localhost'
6
- field :port, Integer, :default => 6000
7
-
8
- class Error < StandardError; end
9
-
10
- def uri
11
- return @uri if @uri
12
-
13
- uri_str = "http://#{host}:#{port}/1.0"
14
- @uri ||= URI(uri_str)
15
- end
16
-
17
- def event(topic, document = {})
18
- request(:post, File.join(uri.path, 'event'), MultiJson.dump(document))
19
- end
20
-
21
- private
22
-
23
- def request(method, path, document=nil)
24
- http = Net::HTTP.new(uri.host, uri.port)
25
-
26
- params = [method.to_sym, path]
27
- params += [document, {'Content-Type' => 'application/json'}] unless document.nil?
28
-
29
- response = http.send *params
30
-
31
- if Net::HTTPSuccess === response
32
- MultiJson.load(response.body) rescue response.body
33
- else
34
- raise Error.new("Error (#{response.code}) while #{method.to_s == 'get' ? 'fetching' : 'inserting'} document: " + response.body)
35
- end
36
- end
37
- end
38
- end
39
-