ruby-druid 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/Gemfile +5 -14
- data/README.md +128 -148
- data/Rakefile +1 -0
- data/bin/dripl +2 -4
- data/lib/druid/console.rb +11 -5
- data/ruby-druid.gemspec +16 -15
- data/spec/lib/client_spec.rb +4 -4
- data/spec/lib/query_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +43 -35
- data/CHANGELOG.md +0 -5
- data/Guardfile +0 -10
data/.travis.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- jruby
|
4
|
+
- 2.0.0
|
5
|
+
- 1.9.3
|
6
|
+
notifications:
|
7
|
+
email: false
|
8
|
+
hipchat:
|
9
|
+
rooms:
|
10
|
+
secure: WhPGqnsNAVchiJz/rmmIPIFHXI7NVd+k/zClVhtgyoPEdebFYFgOCEIGbE/53IVymVeXFFBeJUVQg1Um4AVsZzVpS5sC6ABWw7rH5PZQZ7k177ZmuhbIAVYLLXcX0OmolgsATvGejifVj5i/Kld46kRx3JDlWL/mA465Kso7a/k=
|
data/Gemfile
CHANGED
@@ -2,20 +2,11 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
+
gem 'liquid-ext'
|
6
|
+
gem 'ripl'
|
7
|
+
gem 'terminal-table'
|
8
|
+
|
5
9
|
group :test, :development do
|
6
|
-
gem '
|
7
|
-
gem 'guard-bundler'
|
8
|
-
gem 'guard-rspec'
|
9
|
-
gem 'rb-fsevent'
|
10
|
-
gem 'rspec'
|
11
|
-
gem 'ruby_gntp'
|
10
|
+
gem 'liquid-development'
|
12
11
|
gem 'webmock'
|
13
|
-
gem 'debugger'
|
14
|
-
end
|
15
|
-
|
16
|
-
group :console do
|
17
|
-
gem 'activesupport'
|
18
|
-
gem 'awesome_print'
|
19
|
-
gem 'ripl'
|
20
|
-
gem 'terminal-table'
|
21
12
|
end
|
data/README.md
CHANGED
@@ -1,84 +1,29 @@
|
|
1
1
|
# ruby-druid
|
2
2
|
|
3
|
-
[
|
3
|
+
A ruby client for [druid](http://druid.io).
|
4
4
|
|
5
|
-
|
5
|
+
ruby-druid features a [Squeel](https://github.com/ernie/squeel)-like query DSL
|
6
|
+
and generates a JSON query that can be sent to druid directly. A console for
|
7
|
+
testing is also provided.
|
6
8
|
|
7
|
-
ruby-druid
|
8
|
-
|
9
|
+
[![Gem Version](https://badge.fury.io/rb/ruby-druid.png)](http://badge.fury.io/rb/ruby-druid)
|
10
|
+
[![Build Status](https://travis-ci.org/liquidm/ruby-druid.png)](https://travis-ci.org/liquidm/ruby-druid)
|
11
|
+
[![Code Climate](https://codeclimate.com/github/liquidm/ruby-druid.png)](https://codeclimate.com/github/liquidm/ruby-druid)
|
12
|
+
[![Dependency Status](https://gemnasium.com/liquidm/ruby-druid.png)](https://gemnasium.com/liquidm/ruby-druid)
|
9
13
|
|
10
|
-
##
|
14
|
+
## Installation
|
11
15
|
|
12
|
-
|
16
|
+
Add this line to your application's Gemfile:
|
13
17
|
|
14
|
-
|
15
|
-
$ bin/dripl
|
16
|
-
>> metrics
|
17
|
-
[
|
18
|
-
[0] "actions"
|
19
|
-
]
|
20
|
-
|
21
|
-
>> dimensions
|
22
|
-
[
|
23
|
-
[0] "actions"
|
24
|
-
]
|
25
|
-
|
26
|
-
>> long_sum(:actions)
|
27
|
-
+---------+
|
28
|
-
| actions |
|
29
|
-
+---------+
|
30
|
-
| 98575 |
|
31
|
-
+---------+
|
32
|
-
|
33
|
-
>> long_sum(:actions)[-7.days].granularity(:day)
|
34
|
-
+-------------------------------+----------+
|
35
|
-
| timestamp | actions |
|
36
|
-
+-------------------------------+----------+
|
37
|
-
| 2013-03-28T00:00:00.000+01:00 | 93371 |
|
38
|
-
| 2013-03-29T00:00:00.000+01:00 | 448200 |
|
39
|
-
| 2013-03-30T00:00:00.000+01:00 | 117167 |
|
40
|
-
| 2013-03-31T00:00:00.000+01:00 | 828321 |
|
41
|
-
| 2013-04-01T00:00:00.000+02:00 | 261578 |
|
42
|
-
| 2013-04-02T00:00:00.000+02:00 | 05149 |
|
43
|
-
| 2013-04-03T00:00:00.000+02:00 | 27512 |
|
44
|
-
| 2013-04-04T00:00:00.000+02:00 | 18897 |
|
45
|
-
+-------------------------------+----------+
|
46
|
-
|
47
|
-
>> long_sum(:actions)[-7.days].granularity(:day).properties
|
48
|
-
{
|
49
|
-
:dataSource => "events",
|
50
|
-
:granularity => {
|
51
|
-
:type => "period",
|
52
|
-
:period => "P1D",
|
53
|
-
:timeZone => "Europe/Berlin"
|
54
|
-
},
|
55
|
-
:intervals => [
|
56
|
-
[0] "2013-03-28T00:00:00+01:00/2013-04-04T11:57:20+02:00"
|
57
|
-
],
|
58
|
-
:queryType => :groupBy,
|
59
|
-
:aggregations => [
|
60
|
-
[0] {
|
61
|
-
:type => "longSum",
|
62
|
-
:name => :actions,
|
63
|
-
:fieldName => :actions
|
64
|
-
}
|
65
|
-
]
|
66
|
-
}
|
67
|
-
```
|
18
|
+
gem 'ruby-druid'
|
68
19
|
|
69
|
-
|
20
|
+
And then execute:
|
70
21
|
|
71
|
-
|
22
|
+
$ bundle
|
72
23
|
|
73
|
-
|
74
|
-
gem 'ruby-druid'
|
75
|
-
```
|
24
|
+
Or install it yourself as:
|
76
25
|
|
77
|
-
|
78
|
-
|
79
|
-
```ruby
|
80
|
-
require 'druid'
|
81
|
-
```
|
26
|
+
$ gem install ruby-druid
|
82
27
|
|
83
28
|
## Usage
|
84
29
|
|
@@ -86,85 +31,87 @@ In your code:
|
|
86
31
|
Druid::Client.new('zk1:2181,zk2:2181/druid').query('service/source')
|
87
32
|
```
|
88
33
|
|
89
|
-
returns a query object on which all other methods can be called to create a
|
34
|
+
returns a query object on which all other methods can be called to create a
|
35
|
+
full and valid druid query.
|
90
36
|
|
91
37
|
A query object can be sent like this:
|
92
38
|
|
93
39
|
```ruby
|
94
|
-
Druid::Client.new('zk1:2181,zk2:2181/druid').query('service/source').send
|
95
|
-
#or
|
96
40
|
client = Druid::Client.new('zk1:2181,zk2:2181/druid')
|
97
41
|
query = Druid::Query.new('service/source')
|
98
42
|
client.send(query)
|
99
43
|
```
|
100
44
|
|
101
|
-
The `send` method returns the parsed response from the druid server as an
|
102
|
-
If the response is not empty it contains one `ResponseRow` object for
|
103
|
-
The timestamp by can be received by a method with the same name
|
104
|
-
all row values by hashlike syntax (i.e.
|
45
|
+
The `send` method returns the parsed response from the druid server as an
|
46
|
+
array. If the response is not empty it contains one `ResponseRow` object for
|
47
|
+
each row. The timestamp by can be received by a method with the same name
|
48
|
+
(i.e. `row.timestamp`), all row values by hashlike syntax (i.e.
|
49
|
+
`row['dimension'])
|
105
50
|
|
106
|
-
###
|
51
|
+
### GroupBy
|
107
52
|
|
108
|
-
https://github.com/metamx/druid/wiki/GroupByQuery
|
53
|
+
A [GroupByQuery](https://github.com/metamx/druid/wiki/GroupByQuery) sets the
|
54
|
+
dimensions to group the data.
|
109
55
|
|
110
56
|
`queryType` is set automatically to `groupBy`.
|
111
57
|
|
112
|
-
|
113
58
|
```ruby
|
114
59
|
Druid::Query.new('service/source').group_by([:dimension1, :dimension2])
|
115
60
|
```
|
116
61
|
|
117
|
-
###
|
62
|
+
### TimeSeries
|
118
63
|
|
119
|
-
https://github.com/metamx/druid/wiki/TimeseriesQuery
|
64
|
+
A [TimeSeriesQuery](https://github.com/metamx/druid/wiki/TimeseriesQuery)
|
65
|
+
returns an array of JSON objects where each object represents a value asked for
|
66
|
+
by the timeseries query.
|
120
67
|
|
121
68
|
```ruby
|
122
69
|
Druid::Query.new('service/source').time_series([:aggregate1, :aggregate2])
|
123
70
|
```
|
124
71
|
|
125
|
-
###
|
72
|
+
### Aggregations
|
126
73
|
|
127
74
|
```ruby
|
128
75
|
Druid::Query.new('service/source').long_sum([:aggregate1, :aggregate2])
|
129
76
|
```
|
130
77
|
|
131
|
-
###
|
78
|
+
### Post Aggregations
|
132
79
|
|
133
80
|
A simple syntax for post aggregations with +,-,/,* can be used like:
|
134
81
|
|
135
82
|
```ruby
|
136
83
|
query = Druid::Query.new('service/source').long_sum([:aggregate1, :aggregate2])
|
137
|
-
|
138
84
|
query.postagg{(aggregate2 + aggregate2).as output_field_name}
|
139
85
|
```
|
140
86
|
|
141
|
-
Required fields for the postaggregation are fetched automatically by the
|
87
|
+
Required fields for the postaggregation are fetched automatically by the
|
88
|
+
library.
|
142
89
|
|
143
|
-
###
|
90
|
+
### Query Interval
|
144
91
|
|
145
|
-
The interval for the query takes a string with date and time or objects that
|
92
|
+
The interval for the query takes a string with date and time or objects that
|
93
|
+
provide an `iso8601` method.
|
146
94
|
|
147
95
|
```ruby
|
148
96
|
query = Druid::Query.new('service/source').long_sum(:aggregate1)
|
149
|
-
|
150
97
|
query.interval("2013-01-01T00", Time.now)
|
151
98
|
```
|
152
99
|
|
153
|
-
###
|
100
|
+
### Result Granularity
|
154
101
|
|
155
|
-
granularity can be `:all`, `:none`, `:minute`, `:fifteen_minute`,
|
102
|
+
The granularity can be `:all`, `:none`, `:minute`, `:fifteen_minute`,
|
103
|
+
`:thirthy_minute`, `:hour` or `:day`.
|
156
104
|
|
157
|
-
It can also be a period granularity as described in
|
105
|
+
It can also be a period granularity as described in the [druid
|
106
|
+
wiki](https://github.com/metamx/druid/wiki/Granularities).
|
158
107
|
|
159
108
|
The period `'day'` or `:day` will be interpreted as `'P1D'`.
|
160
109
|
|
161
|
-
If a period granularity is specifed, the (optional) second parameter is a time
|
162
|
-
to the machines local time zone.
|
110
|
+
If a period granularity is specifed, the (optional) second parameter is a time
|
111
|
+
zone. It defaults to the machines local time zone. i.e.
|
163
112
|
|
164
|
-
I.E:
|
165
113
|
```ruby
|
166
114
|
query = Druid::Query.new('service/source').long_sum(:aggregate1)
|
167
|
-
|
168
115
|
query.granularity(:day)
|
169
116
|
```
|
170
117
|
|
@@ -172,75 +119,73 @@ is (on my box) the same as
|
|
172
119
|
|
173
120
|
```ruby
|
174
121
|
query = Druid::Query.new('service/source').long_sum(:aggregate1)
|
175
|
-
|
176
122
|
query.granularity('P1D', 'Europe/Berlin')
|
177
123
|
```
|
178
124
|
|
179
|
-
|
180
|
-
|
181
|
-
### having >
|
125
|
+
### Having
|
182
126
|
|
183
127
|
```ruby
|
184
128
|
Druid::Query.new('service/source').having{metric > 10}
|
185
129
|
```
|
186
130
|
|
187
|
-
### having <
|
188
|
-
|
189
131
|
```ruby
|
190
132
|
Druid::Query.new('service/source').having{metric < 10}
|
191
133
|
```
|
192
134
|
|
193
|
-
|
135
|
+
### Filters
|
194
136
|
|
195
|
-
Filters are set by the `filter` method. It takes a block or a hash as
|
137
|
+
Filters are set by the `filter` method. It takes a block or a hash as
|
138
|
+
parameter.
|
196
139
|
|
197
140
|
Filters can be chained `filter{...}.filter{...}`
|
198
141
|
|
199
|
-
|
142
|
+
#### Base Filters
|
200
143
|
|
201
144
|
```ruby
|
145
|
+
# equality
|
202
146
|
Druid::Query.new('service/source').filter{dimension.eq 1}
|
203
|
-
|
204
|
-
#this is the same as
|
205
|
-
|
206
147
|
Druid::Query.new('service/source').filter{dimension == 1}
|
207
148
|
```
|
208
149
|
|
209
|
-
### filter != , neq
|
210
|
-
|
211
150
|
```ruby
|
151
|
+
# inequality
|
212
152
|
Druid::Query.new('service/source').filter{dimension.neq 1}
|
153
|
+
Druid::Query.new('service/source').filter{dimension != 1}
|
154
|
+
```
|
213
155
|
|
214
|
-
|
156
|
+
```ruby
|
157
|
+
# greater, less
|
158
|
+
Druid::Query.new('service/source').filter{dimension > 1}
|
159
|
+
Druid::Query.new('service/source').filter{dimension >= 1}
|
160
|
+
Druid::Query.new('service/source').filter{dimension < 1}
|
161
|
+
Druid::Query.new('service/source').filter{dimension <= 1}
|
162
|
+
```
|
215
163
|
|
216
|
-
|
164
|
+
```ruby
|
165
|
+
# JavaScript
|
166
|
+
Druid::Query.new('service/source').filter{a.javascript('dimension >= 1 && dimension < 5')}
|
217
167
|
```
|
218
168
|
|
219
|
-
|
169
|
+
#### Compound Filters
|
220
170
|
|
221
|
-
|
171
|
+
Filters can be combined with boolean logic.
|
222
172
|
|
223
173
|
```ruby
|
174
|
+
# and
|
224
175
|
Druid::Query.new('service/source').filter{dimension.neq 1 & dimension2.neq 2}
|
225
176
|
```
|
226
177
|
|
227
|
-
### filter or
|
228
|
-
|
229
|
-
a logical or than can combine all other filters
|
230
|
-
|
231
178
|
```ruby
|
179
|
+
# or
|
232
180
|
Druid::Query.new('service/source').filter{dimension.neq 1 | dimension2.neq 2}
|
233
181
|
```
|
234
182
|
|
235
|
-
### filter not
|
236
|
-
|
237
|
-
a logical not than can negate all other filter
|
238
|
-
|
239
183
|
```ruby
|
184
|
+
# not
|
240
185
|
Druid::Query.new('service/source').filter{!dimension.eq(1)}
|
241
186
|
```
|
242
187
|
|
243
|
-
|
188
|
+
#### Inclusion Filter
|
244
189
|
|
245
190
|
This filter creates a set of equals filters in an and filter.
|
246
191
|
|
@@ -248,10 +193,10 @@ This filter creates a set of equals filters in an and filter.
|
|
248
193
|
Druid::Query.new('service/source').filter{dimension.in(1,2,3)}
|
249
194
|
```
|
250
195
|
|
251
|
-
|
196
|
+
#### Hash syntax
|
252
197
|
|
253
|
-
|
254
|
-
for example if you already get them from a list or
|
198
|
+
Sometimes it can be useful to use a hash syntax for filtering
|
199
|
+
for example if you already get them from a list or parameter hash.
|
255
200
|
|
256
201
|
```ruby
|
257
202
|
Druid::Query.new('service/source').filter{dimension => 1, dimension1 =>2, dimension2 => 3}
|
@@ -261,34 +206,69 @@ Druid::Query.new('service/source').filter{dimension => 1, dimension1 =>2, dimens
|
|
261
206
|
Druid::Query.new('service/source').filter{dimension.eq(1) & dimension1.eq(2) & dimension2.eq(3)}
|
262
207
|
```
|
263
208
|
|
264
|
-
###
|
209
|
+
### DRIPL
|
265
210
|
|
266
|
-
|
267
|
-
Druid::Query.new('service/source').filter{dimension >= 1}
|
268
|
-
```
|
269
|
-
|
270
|
-
### filter javascript
|
211
|
+
ruby-druid now includes a [REPL](https://github.com/cldwalker/ripl):
|
271
212
|
|
272
213
|
```ruby
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
```
|
214
|
+
$ bin/dripl
|
215
|
+
>> metrics
|
216
|
+
[
|
217
|
+
[0] "actions"
|
218
|
+
]
|
279
219
|
|
280
|
-
|
220
|
+
>> dimensions
|
221
|
+
[
|
222
|
+
[0] "actions"
|
223
|
+
]
|
281
224
|
|
282
|
-
|
225
|
+
>> long_sum(:actions)
|
226
|
+
+---------+
|
227
|
+
| actions |
|
228
|
+
+---------+
|
229
|
+
| 98575 |
|
230
|
+
+---------+
|
283
231
|
|
284
|
-
|
232
|
+
>> long_sum(:actions)[-7.days].granularity(:day)
|
233
|
+
+-------------------------------+----------+
|
234
|
+
| timestamp | actions |
|
235
|
+
+-------------------------------+----------+
|
236
|
+
| 2013-03-28T00:00:00.000+01:00 | 93371 |
|
237
|
+
| 2013-03-29T00:00:00.000+01:00 | 448200 |
|
238
|
+
| 2013-03-30T00:00:00.000+01:00 | 117167 |
|
239
|
+
| 2013-03-31T00:00:00.000+01:00 | 828321 |
|
240
|
+
| 2013-04-01T00:00:00.000+02:00 | 261578 |
|
241
|
+
| 2013-04-02T00:00:00.000+02:00 | 05149 |
|
242
|
+
| 2013-04-03T00:00:00.000+02:00 | 27512 |
|
243
|
+
| 2013-04-04T00:00:00.000+02:00 | 18897 |
|
244
|
+
+-------------------------------+----------+
|
285
245
|
|
286
|
-
|
246
|
+
>> long_sum(:actions)[-7.days].granularity(:day).properties
|
247
|
+
{
|
248
|
+
:dataSource => "events",
|
249
|
+
:granularity => {
|
250
|
+
:type => "period",
|
251
|
+
:period => "P1D",
|
252
|
+
:timeZone => "Europe/Berlin"
|
253
|
+
},
|
254
|
+
:intervals => [
|
255
|
+
[0] "2013-03-28T00:00:00+01:00/2013-04-04T11:57:20+02:00"
|
256
|
+
],
|
257
|
+
:queryType => :groupBy,
|
258
|
+
:aggregations => [
|
259
|
+
[0] {
|
260
|
+
:type => "longSum",
|
261
|
+
:name => :actions,
|
262
|
+
:fieldName => :actions
|
263
|
+
}
|
264
|
+
]
|
265
|
+
}
|
266
|
+
```
|
287
267
|
|
288
|
-
|
268
|
+
## Contributing
|
289
269
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
270
|
+
1. Fork it
|
271
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
272
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
273
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
274
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/bin/dripl
CHANGED
data/lib/druid/console.rb
CHANGED
@@ -9,15 +9,21 @@ require 'druid'
|
|
9
9
|
|
10
10
|
Ripl::Shell.class_eval do
|
11
11
|
def format_query_result(result, query)
|
12
|
-
|
13
12
|
include_timestamp = query.properties[:granularity] != 'all'
|
14
13
|
|
15
14
|
keys = result.empty? ? [] : result.last.keys
|
15
|
+
grouped_result = result.group_by(&:timestamp)
|
16
16
|
|
17
|
-
Terminal::Table.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
Terminal::Table.new(:headings => keys) do
|
18
|
+
grouped_result.each do |timestamp, rows|
|
19
|
+
if include_timestamp
|
20
|
+
add_row :separator unless timestamp == result.first.timestamp
|
21
|
+
add_row [{ :value => timestamp, :colspan => keys.length }]
|
22
|
+
add_row :separator
|
23
|
+
end
|
24
|
+
rows.each {|row| add_row keys.map {|key| row[key] } }
|
25
|
+
end
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
def format_result(result)
|
data/ruby-druid.gemspec
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
|
1
|
+
# coding: utf-8
|
2
2
|
|
3
|
-
Gem::Specification.new do |
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ruby-druid"
|
5
|
+
spec.version = "0.1.3"
|
6
|
+
spec.authors = ["LiquidM, Inc."]
|
7
|
+
spec.email = ["opensource@liquidm.com"]
|
8
|
+
spec.summary = %q{Ruby client for metamx druid}
|
9
|
+
spec.description = %q{Ruby client for metamx druid}
|
10
|
+
spec.homepage = "https://github.com/liquidm/ruby-druid"
|
11
|
+
spec.license = "MIT"
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
spec.add_dependency "zk"
|
19
|
+
spec.add_dependency "rest-client"
|
19
20
|
end
|
data/spec/lib/client_spec.rb
CHANGED
@@ -8,12 +8,12 @@ describe Druid::Client do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'creates a query' do
|
11
|
-
Druid::ZooHandler.stub
|
11
|
+
Druid::ZooHandler.stub(:new).and_return(double(Druid::ZooHandler, :data_sources => {'test/test' => 'http://www.example.com'}, :close! => true))
|
12
12
|
Druid::Client.new('test_uri', zk_keepalive: true).query('test/test').should be_a Druid::Query
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'sends query if block is given' do
|
16
|
-
Druid::ZooHandler.stub
|
16
|
+
Druid::ZooHandler.stub(:new).and_return(double(Druid::ZooHandler, :data_sources => {'test/test' => 'http://www.example.com'}, :close! => true))
|
17
17
|
client = Druid::Client.new('test_uri', zk_keepalive: true)
|
18
18
|
client.should_receive(:send)
|
19
19
|
client.query('test/test') do
|
@@ -26,7 +26,7 @@ describe Druid::Client do
|
|
26
26
|
with(:body => "{\"dataSource\":\"test\",\"granularity\":\"all\",\"intervals\":[\"2013-04-04T00:00:00+00:00/2013-04-04T00:00:00+00:00\"]}",
|
27
27
|
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
|
28
28
|
to_return(:status => 200, :body => "[]", :headers => {})
|
29
|
-
Druid::ZooHandler.stub
|
29
|
+
Druid::ZooHandler.stub(:new).and_return(double(Druid::ZooHandler, :data_sources => {'test/test' => 'http://www.example.com/druid/v2'}, :close! => true))
|
30
30
|
client = Druid::Client.new('test_uri', zk_keepalive: true)
|
31
31
|
JSON.should_receive(:parse).and_return([])
|
32
32
|
client.send(client.query('test/test').interval("2013-04-04", "2013-04-04"))
|
@@ -37,7 +37,7 @@ describe Druid::Client do
|
|
37
37
|
with(:body => "{\"dataSource\":\"test\",\"granularity\":\"all\",\"intervals\":[\"2013-04-04T00:00:00+00:00/2013-04-04T00:00:00+00:00\"]}",
|
38
38
|
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
|
39
39
|
to_return(:status => 666, :body => "Strange server error", :headers => {})
|
40
|
-
Druid::ZooHandler.stub
|
40
|
+
Druid::ZooHandler.stub(:new).and_return(double(Druid::ZooHandler, :data_sources => {'test/test' => 'http://www.example.com/druid/v2'}, :close! => true))
|
41
41
|
client = Druid::Client.new('test_uri', zk_keepalive: true)
|
42
42
|
expect { client.send(client.query('test/test').interval("2013-04-04", "2013-04-04")) }.to raise_error(RuntimeError, /Request failed: 666: Strange server error/)
|
43
43
|
end
|
data/spec/lib/query_spec.rb
CHANGED
@@ -344,7 +344,7 @@ end
|
|
344
344
|
end
|
345
345
|
|
346
346
|
it 'raises wrong number of arguments if filter operator is called without param' do
|
347
|
-
expect { @query.filter{a.eq}.to_json}.to raise_error
|
347
|
+
expect { @query.filter{a.eq}.to_json}.to raise_error
|
348
348
|
end
|
349
349
|
|
350
350
|
it 'should query regexp using .regexp(string)' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require 'webmock/rspec'
|
1
|
+
require 'druid'
|
2
|
+
require 'webmock/rspec'
|
metadata
CHANGED
@@ -1,58 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-druid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
9
|
-
autorequire:
|
8
|
+
- LiquidM, Inc.
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zk
|
16
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
17
18
|
requirements:
|
18
|
-
- - '>='
|
19
|
+
- - ! '>='
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
25
|
none: false
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
|
-
none: false
|
28
|
-
prerelease: false
|
29
|
-
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rest-client
|
32
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
33
34
|
requirements:
|
34
|
-
- - '>='
|
35
|
+
- - ! '>='
|
35
36
|
- !ruby/object:Gem::Version
|
36
37
|
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
41
|
none: false
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
42
|
requirements:
|
40
|
-
- - '>='
|
43
|
+
- - ! '>='
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: '0'
|
43
|
-
none: false
|
44
|
-
prerelease: false
|
45
|
-
type: :runtime
|
46
46
|
description: Ruby client for metamx druid
|
47
|
-
email:
|
48
|
-
|
47
|
+
email:
|
48
|
+
- opensource@liquidm.com
|
49
|
+
executables:
|
50
|
+
- dripl
|
49
51
|
extensions: []
|
50
52
|
extra_rdoc_files: []
|
51
53
|
files:
|
52
54
|
- .gitignore
|
53
|
-
-
|
55
|
+
- .travis.yml
|
54
56
|
- Gemfile
|
55
|
-
- Guardfile
|
56
57
|
- LICENSE
|
57
58
|
- README.md
|
58
59
|
- Rakefile
|
@@ -72,33 +73,40 @@ files:
|
|
72
73
|
- spec/lib/query_spec.rb
|
73
74
|
- spec/lib/zoo_handler_spec.rb
|
74
75
|
- spec/spec_helper.rb
|
75
|
-
homepage: https://github.com/
|
76
|
-
licenses:
|
77
|
-
|
76
|
+
homepage: https://github.com/liquidm/ruby-druid
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
78
80
|
rdoc_options: []
|
79
81
|
require_paths:
|
80
82
|
- lib
|
81
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
82
85
|
requirements:
|
83
|
-
- - '>='
|
86
|
+
- - ! '>='
|
84
87
|
- !ruby/object:Gem::Version
|
85
88
|
version: '0'
|
86
|
-
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
hash: -4499616778972236254
|
87
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
88
94
|
requirements:
|
89
|
-
- - '>='
|
95
|
+
- - ! '>='
|
90
96
|
- !ruby/object:Gem::Version
|
91
97
|
version: '0'
|
92
|
-
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
hash: -4499616778972236254
|
93
101
|
requirements: []
|
94
|
-
rubyforge_project:
|
95
|
-
rubygems_version: 1.8.
|
96
|
-
signing_key:
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.8.25
|
104
|
+
signing_key:
|
97
105
|
specification_version: 3
|
98
|
-
summary: Ruby client for druid
|
106
|
+
summary: Ruby client for metamx druid
|
99
107
|
test_files:
|
100
108
|
- spec/lib/client_spec.rb
|
101
109
|
- spec/lib/query_spec.rb
|
102
110
|
- spec/lib/zoo_handler_spec.rb
|
103
111
|
- spec/spec_helper.rb
|
104
|
-
has_rdoc:
|
112
|
+
has_rdoc:
|
data/CHANGELOG.md
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
### 0.1.1
|
2
|
-
|
3
|
-
* Zookeeper connection issues
|
4
|
-
* Fixed the issue where ZK connections weren't closed after the client was initialized. The new flow opens a connection to ZK then closes it once it has a list of data sources. To keep the connection open with ZK please use the options `zk_keepalive: true`
|
5
|
-
* Added Time Series query support. You can now use `.time_series(aggregations)` for time series based queries
|
data/Guardfile
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# More info at https://github.com/guard/guard#readme
|
2
|
-
guard :bundler do
|
3
|
-
watch('Gemfile')
|
4
|
-
end
|
5
|
-
|
6
|
-
guard :rspec, :cli => '--color --format nested' do
|
7
|
-
watch(%r{^spec/.+_spec\.rb$})
|
8
|
-
watch(%r{^(.+)\.rb$}) {|m| "spec/#{m[1]}_spec.rb" }
|
9
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
10
|
-
end
|