pinot 0.1.1 → 0.1.3

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: 6443fe94263c767cc5039c400a7684fae467ab856e2d04253959ef6e0042e1d1
4
+ data.tar.gz: 4cb05bc8fe5c6f9b83cffa623e359f3c90fdc768575033e13968a78c5f7d43ff
5
5
  SHA512:
6
- metadata.gz: 03e285bd5884bae307bd58797738d478f96cf97466ec0e6992dba0de6ab5120f935fba9245c4c5f1466794cf83da4a42dcc30b6819289e736c40cc374a054639
7
- data.tar.gz: 07345f9e2e93442855887c208d586d98a0922bc346e19cac7bc58efbea1b4a79aadafaf9abd70692957890211583b2202502fe92996278f7e87f28a503fcfd88
6
+ metadata.gz: f217a53c1c2712e8d098aa94e5f3a4a93995e0839cad0f1a640f78c6e5269f7847afe9ef6d8344c2eb1d1df85ea087a5fb0db853ce3eb8c2d65d029ddbc6d554
7
+ data.tar.gz: 70694ca05dd5de01ef4e1d8af6e8bc61b899840e73ccb2b9680150d5d9dd48553fba2002607e6b22a9e3e1939d08d625e8c1d672adc6f4001345ad0ea5da9c5a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2024-07-02
4
+
5
+ - feature: add tables command
6
+
7
+ ## [0.1.2] - 2024-05-29
8
+
9
+ - feature: support socks5
10
+ - feature: support authentication bearer token
11
+
12
+ ## [0.1.1] - 2024-05-16
13
+
14
+ - feature: Add support for controller host
15
+ - fix: handle nil column names
16
+
3
17
  ## [0.1.0] - 2024-01-16
4
18
 
5
19
  - 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)
@@ -62,8 +66,21 @@ module Pinot
62
66
  JSON.parse(response)
63
67
  end
64
68
 
69
+ def tables
70
+ url = "#{controller_uri}/tables"
71
+ response = http.get(url)
72
+ JSON.parse(response)
73
+ end
74
+
65
75
  def http(content_type: "application/json")
66
- HTTPX.with(headers: {"Content-Type" => content_type})
76
+ return @http if !@http.nil?
77
+ default_headers = {"Content-Type" => content_type}
78
+ default_headers["Authorization"] = "Bearer #{bearer_token}" if bearer_token
79
+ @http = HTTPX.with(headers: default_headers, timeout: {connect_timeout: 5})
80
+ if socks5_uri
81
+ @http = @http.plugin(:proxy).with_proxy(uri: socks5_uri) if socks5_uri
82
+ end
83
+ @http
67
84
  end
68
85
 
69
86
  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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Celso Fernandes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-16 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpx
@@ -90,7 +90,7 @@ metadata:
90
90
  homepage_uri: https://github.com/fernandes/pinot-ruby
91
91
  source_code_uri: https://github.com/fernandes/pinot
92
92
  changelog_uri: https://github.com/fernandes/pinot/blob/main/CHANGELOG.md
93
- post_install_message:
93
+ post_install_message:
94
94
  rdoc_options: []
95
95
  require_paths:
96
96
  - lib
@@ -105,8 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.5.3
109
- signing_key:
108
+ rubygems_version: 3.5.14
109
+ signing_key:
110
110
  specification_version: 4
111
111
  summary: Client for Apache Pinot
112
112
  test_files: []