Module: Trino::Client

Defined in:
lib/trino/client/query.rb,
lib/trino/client.rb,
lib/trino/client/client.rb,
lib/trino/client/errors.rb,
lib/trino/client/models.rb,
lib/trino/client/version.rb,
lib/trino/client/faraday_client.rb,
lib/trino/client/statement_client.rb

Overview

Trino client for Ruby

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Defined Under Namespace

Modules: ModelVersions, PrestoHeaders, TrinoHeaders Classes: Client, Query, StatementClient, TrinoClientError, TrinoError, TrinoHttpError, TrinoQueryError, TrinoQueryTimeoutError

Constant Summary collapse

Models =
ModelVersions::V351
VERSION =
"1.0.1"
HEADERS =
{
  "User-Agent" => "trino-ruby/#{VERSION}",
}
HTTP11_SEPARATOR =
["(", ")", "<", ">", "@", ",", ";", ":", "\\", "<", ">", "/", "[", "]", "?", "=", "{", "}", " ", "\v"]
HTTP11_TOKEN_CHARSET =
(32..126).map {|x| x.chr } - HTTP11_SEPARATOR
HTTP11_TOKEN_REGEXP =
/^[#{Regexp.escape(HTTP11_TOKEN_CHARSET.join)}]+\z/
HTTP11_CTL_CHARSET =
(0..31).map {|x| x.chr } + [127.chr]
HTTP11_CTL_CHARSET_REGEXP =
/[#{Regexp.escape(HTTP11_CTL_CHARSET.join)}]/

Class Method Summary collapse

Class Method Details

.faraday_client(options) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/trino/client/faraday_client.rb', line 58

def self.faraday_client(options)
  server = options[:server]
  unless server
    raise ArgumentError, ":server option is required"
  end

  ssl = faraday_ssl_options(options)

  if options[:password] && !ssl
    raise ArgumentError, "Protocol must be https when passing a password"
  end

  url = "#{ssl ? "https" : "http"}://#{server}"
  proxy = options[:http_proxy] || options[:proxy]  # :proxy is obsoleted

  faraday_options = {url: url, proxy: "#{proxy}"}
  faraday_options[:ssl] = ssl if ssl

  faraday = Faraday.new(faraday_options) do |faraday|
    if options[:user] && options[:password]
      faraday.basic_auth(options[:user], options[:password])
    end
    if options[:follow_redirect]
      faraday.use FaradayMiddleware::FollowRedirects
    end
    if options[:gzip]
      faraday.use FaradayMiddleware::Gzip
    end
    faraday.response :logger if options[:http_debug]
    faraday.adapter Faraday.default_adapter
  end

  faraday.headers.merge!(HEADERS)
  faraday.headers.merge!(optional_headers(options))

  return faraday
end

.new(*args) ⇒ Object



75
76
77
# File 'lib/trino/client/client.rb', line 75

def self.new(*args)
  Client.new(*args)
end