pinot 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fa42f97735f850dc0f870866e7d6da882227a998533b3aaa94f7c6a320d20ec
4
- data.tar.gz: '019daf46b029bdac3a7c196d0a5f2927234f63ba513873318c5e0f6d48e1d3c6'
3
+ metadata.gz: dc12c931af8cd247929cbab2185c0ccd69a7d241e750211ba95287af996e3914
4
+ data.tar.gz: 3682d27b5db1c615f1084af77ef1d64496859a6db92a21a4bdf4d45761f8b741
5
5
  SHA512:
6
- metadata.gz: 03e285bd5884bae307bd58797738d478f96cf97466ec0e6992dba0de6ab5120f935fba9245c4c5f1466794cf83da4a42dcc30b6819289e736c40cc374a054639
7
- data.tar.gz: 07345f9e2e93442855887c208d586d98a0922bc346e19cac7bc58efbea1b4a79aadafaf9abd70692957890211583b2202502fe92996278f7e87f28a503fcfd88
6
+ metadata.gz: f9a4464727f662abe8c7cace2952076e45ea08802d1380a09568b9c60f4d2b58b6f8bd501f29216e59525a2d54f131bd66d19de12dbb7a5880780dc1bab06831
7
+ data.tar.gz: 890d0696eb36c2059873a9d8330f584fdd3b6ff13870567f5eee7d69a7fd286f895b9143f6ecc387a150fce460f27e3c7db4b063fb1500d9d849a7403d3c3468
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2024-05-29
4
+
5
+ - feature: support socks5
6
+ - feature: support authentication bearer token
7
+
8
+ ## [0.1.1] - 2024-05-16
9
+
10
+ - feature: Add support for controller host
11
+ - fix: handle nil column names
12
+
3
13
  ## [0.1.0] - 2024-01-16
4
14
 
5
15
  - Initial release
data/README.md CHANGED
@@ -1,24 +1,71 @@
1
1
  # Pinot
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pinot`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
3
  ## Installation
8
4
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
5
  Install the gem and add to the application's Gemfile by executing:
12
6
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
7
+ $ bundle add pinot
14
8
 
15
9
  If bundler is not being used to manage dependencies, install the gem by executing:
16
10
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
11
+ $ gem install pinot
18
12
 
19
13
  ## Usage
20
14
 
21
- TODO: Write usage instructions here
15
+ To configure our client, we must have some data about our pinot cluster, its broken and controller host, and which port/protocol both services are using. After having this information, we can setup the client to use it.
16
+
17
+ ```ruby
18
+ host = "localhost"
19
+ controller_host = "localhost"
20
+ client = Pinot::Client.new(host: host, port: 443, protocol: :https, controller_host: controller_host, controller_port: 443)
21
+ ```
22
+
23
+ After setting up your client, we can start using it to query the cluster.
24
+
25
+ ```ruby
26
+ client.execute("select * from table;")
27
+ ```
28
+
29
+ After querying, it returns a `HTTPX::ErrorResponse` in case of any HTTP error, like a timeout, or connection refused, we are returning the client's error to make easier to troubleshoot any problem and handle it accordingly.
30
+
31
+ In case of success, it returns a `Pinot::Response`, an enumerable where you can interact over the returned rows.
32
+
33
+ Each row is an array with row's values.
34
+
35
+ ```ruby
36
+ result = client.execute("select id, name, age from people;")
37
+ result.each do |row|
38
+ puts row[0] # id
39
+ puts row[1] # name
40
+ puts row[2] # age
41
+ end
42
+ ```
43
+
44
+ If the column names and types are needed, can call `columns` method on the response.
45
+
46
+ ```ruby
47
+ result = client.execute("select count(*) from people;")
48
+ resp.columns
49
+ # {"count(*)"=>"LONG"}
50
+ ```
51
+
52
+ It's not on the public API, but the instance variable `@payload` contains all information returned from the Pinot cluster in case can help with troubleshooting
53
+
54
+ ### Authentication
55
+
56
+ In case your pinot cluster is using authentication bearer token, you can specify it on the client constructor
57
+
58
+ ```ruby
59
+ client = Pinot::Client.new(bearer_token: "my-secret", **client_args)
60
+ ```
61
+
62
+ ### Socks5
63
+
64
+ Using Pinot cluster inside a VPC and need to jump through a bastion host using socks5? We got your back!
65
+
66
+ ```ruby
67
+ client = Pinot::Client.new(socks5_uri: "socks5://localhost:80", **client_args)
68
+ ```
22
69
 
23
70
  ## Development
24
71
 
@@ -28,8 +75,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
75
 
29
76
  ## Contributing
30
77
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pinot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pinot/blob/main/CODE_OF_CONDUCT.md).
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/clickfunnels2/pinot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/clickfunnels2/pinot/blob/main/CODE_OF_CONDUCT.md).
32
79
 
33
80
  ## Code of Conduct
34
81
 
35
- Everyone interacting in the Pinot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pinot/blob/main/CODE_OF_CONDUCT.md).
82
+ Everyone interacting in the Pinot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/clickfunnels2/pinot/blob/main/CODE_OF_CONDUCT.md).
data/lib/pinot/client.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  module Pinot
2
2
  class Client
3
- attr_reader :host, :port, :controller_host, :controller_port, :protocol
3
+ attr_reader :host, :port, :controller_host, :controller_port, :protocol, :socks5_uri, :bearer_token
4
4
 
5
- def initialize(host:, port:, controller_port:, controller_host: nil, protocol: :http)
5
+ def initialize(host:, port:, controller_port:, controller_host: nil, protocol: :http, socks5_uri: nil, bearer_token: nil)
6
6
  @host = host
7
7
  @port = port
8
8
  @controller_port = controller_port
9
9
  @controller_host = controller_host || host
10
10
  @protocol = protocol
11
+ @socks5_uri = socks5_uri
12
+ @bearer_token = bearer_token
11
13
  end
12
14
 
13
15
  def execute(sql)
14
- Response.new(JSON.parse(http.post(query_sql_uri, json: {sql: sql})))
16
+ response = http.post(query_sql_uri, json: {sql: sql})
17
+ return response if response.is_a?(HTTPX::ErrorResponse)
18
+ Response.new(JSON.parse(response))
15
19
  end
16
20
 
17
21
  def schema(name)
@@ -63,7 +67,14 @@ module Pinot
63
67
  end
64
68
 
65
69
  def http(content_type: "application/json")
66
- HTTPX.with(headers: {"Content-Type" => content_type})
70
+ return @http if !@http.nil?
71
+ default_headers = {"Content-Type" => content_type}
72
+ default_headers["Authorization"] = "Bearer #{bearer_token}" if bearer_token
73
+ @http = HTTPX.with(headers: default_headers, timeout: { connect_timeout: 5 })
74
+ if socks5_uri
75
+ @http = @http.plugin(:proxy).with_proxy(uri: socks5_uri) if socks5_uri
76
+ end
77
+ @http
67
78
  end
68
79
 
69
80
  def uri
data/lib/pinot/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pinot
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Celso Fernandes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpx