clickhouse 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ef193e0967f146e206ce76d41d1b5893948ae9
4
- data.tar.gz: 47a7ba893cb391215495c80384146947be07b62d
3
+ metadata.gz: 9430c069f56f33af1e4e54bcad89cf33fd836051
4
+ data.tar.gz: a708443dd04408661f84e897e0cec49777188330
5
5
  SHA512:
6
- metadata.gz: 774e1ae3330a758d3dd5bd0609d4f4819a06050a35f2f66b520fbfced6baab89ab376e5c855079486dccc841e627bfb9db19af48ca5005c08154d9e95974180d
7
- data.tar.gz: 06dd73764247a86c0651f50b1a10c27f5b8f8e13e1b9198b5f1386f73edb597c9c51afb8f28f08999a4feaf4f6fc7fefe4ae967af93d29682ead965d34293f67
6
+ metadata.gz: 4b99166f3cbe200af3337764a0db939432094168d52cd2ba0f6526ef43fc5778e60030bbb49e7e877def07b5c0670df71a2c548488135a5a7613a2e7510884c8
7
+ data.tar.gz: a71ad741943715b618bfae02fa34874074b4a72c3b9814c2a38c48bb5fae184b77a9367aa6976d6ca68312397112db11a28bbf3fee4573443839bec5c05fafca
@@ -1,5 +1,9 @@
1
1
  ## Clickhouse CHANGELOG
2
2
 
3
+ ### Version 0.1.3 (October 21, 2016)
4
+
5
+ * Only removing connections from cluster connection pool after a Clickhouse::ConnectionError
6
+
3
7
  ### Version 0.1.2 (October 20, 2016)
4
8
 
5
9
  * Being able to specify a URL
data/README.md CHANGED
@@ -141,6 +141,40 @@ GROUP BY year, date;
141
141
  => [2, 2016, #<Date: 2016-10-17 ((2457679j,0s,0n),+0s,2299161j)>, 0.1915000081062317]
142
142
  ```
143
143
 
144
+ ### Connecting to a cluster
145
+
146
+ To connect to a cluster you only need to specify the URLs of the cluster servers in `:urls` of the configuration and that is it! The API of using Clickhouse stays the same.
147
+
148
+ ```ruby
149
+ Clickhouse.establish_connection urls: %w(http://192.168.99.100:32809 http://192.168.99.100:32812 http://192.168.99.100:32815)
150
+ => true
151
+
152
+ Clickhouse.connection.tables
153
+ I, [2016-10-21T11:56:47.375772 #63374] INFO -- :
154
+ SQL (6.2ms) SHOW TABLES;
155
+ => ["events"]
156
+ ```
157
+
158
+ In case of a connection dropping out, Clickhouse will retry the request with another connection. The failed connection will also be removed from the connection pool.
159
+
160
+ ```ruby
161
+ Clickhouse.establish_connection urls: %w(http://192.168.99.100:32809 http://192.168.99.100:1 http://192.168.99.100:32815)
162
+ => true
163
+
164
+ Clickhouse.connection.pond.available.collect(&:url)
165
+ => ["http://192.168.99.100:1", "http://192.168.99.100:32815", "http://192.168.99.100:32809"]
166
+
167
+ Clickhouse.connection.tables
168
+ I, [2016-10-21T12:11:55.974573 #63527] INFO -- :
169
+ SQL (7.1ms) SHOW TABLES;
170
+ => ["events"]
171
+
172
+ Clickhouse.connection.pond.available.collect(&:url)
173
+ => ["http://192.168.99.100:32809", "http://192.168.99.100:32815"]
174
+ ```
175
+
176
+ If all the connections failed, it will just return `nil`.
177
+
144
178
  ### Check out the tests
145
179
 
146
180
  To see what more the `Clickhouse` gem has to offer, please take a look at the unit tests ( [test/unit/connection/test_query.rb](https://github.com/archan937/clickhouse/blob/master/test/unit/connection/test_query.rb) for instance).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -33,7 +33,7 @@ module Clickhouse
33
33
  pond.checkout do |connection|
34
34
  connection.send(*args, &block)
35
35
  end
36
- rescue
36
+ rescue ::Clickhouse::ConnectionError
37
37
  retry if pond.available.any?
38
38
  end
39
39
 
@@ -3,16 +3,16 @@ module Clickhouse
3
3
  class Error < StandardError
4
4
  end
5
5
 
6
- class InvalidConnectionError < Error
7
- end
8
-
9
6
  class ConnectionError < Error
10
7
  end
11
8
 
12
- class InvalidQueryError < Error
9
+ class InvalidConnectionError < ConnectionError
13
10
  end
14
11
 
15
12
  class QueryError < Error
16
13
  end
17
14
 
15
+ class InvalidQueryError < QueryError
16
+ end
17
+
18
18
  end
@@ -1,7 +1,7 @@
1
1
  module Clickhouse
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 2
4
+ TINY = 3
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -34,6 +34,7 @@ module Unit
34
34
  describe "when connection fails" do
35
35
  it "removes invalid connections from the pond" do
36
36
  cluster = Clickhouse::Cluster.new :urls => %w(http://localhost:1234 http://localhost:1235 http://localhost:1236)
37
+
37
38
  assert_equal %w(
38
39
  http://localhost:1234
39
40
  http://localhost:1235
@@ -44,6 +45,29 @@ module Unit
44
45
  assert_equal [], cluster.pond.available.collect(&:url)
45
46
  end
46
47
  end
48
+
49
+ describe "when error gets raised other than Clickhouse::ConnectionError" do
50
+ it "does not remove the connection from the pond" do
51
+ Clickhouse::Connection.any_instance.expects(:ping!)
52
+
53
+ cluster = Clickhouse::Cluster.new :urls => %w(http://localhost:1234 http://localhost:1235 http://localhost:1236)
54
+ assert_equal %w(
55
+ http://localhost:1234
56
+ http://localhost:1235
57
+ http://localhost:1236
58
+ ), cluster.pond.available.collect(&:url)
59
+
60
+ assert_raises NoMethodError do
61
+ cluster.select_rows ""
62
+ end
63
+
64
+ assert_equal %w(
65
+ http://localhost:1235
66
+ http://localhost:1236
67
+ http://localhost:1234
68
+ ), cluster.pond.available.collect(&:url)
69
+ end
70
+ end
47
71
  end
48
72
 
49
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clickhouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-20 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday