Class: Fluent::CrateClient
- Inherits:
-
CrateRuby::Client
- Object
- CrateRuby::Client
- Fluent::CrateClient
- Defined in:
- lib/fluent/plugin/out_cratedb.rb
Instance Method Summary collapse
- #execute(sql, args = nil, bulk_args = nil, http_options = {}) ⇒ ResultSet
-
#initialize(servers = [], opts = {}) ⇒ CrateClient
constructor
A new instance of CrateClient.
Constructor Details
#initialize(servers = [], opts = {}) ⇒ CrateClient
Returns a new instance of CrateClient.
84 85 86 |
# File 'lib/fluent/plugin/out_cratedb.rb', line 84 def initialize(servers = [], opts = {}) super(servers, opts) end |
Instance Method Details
#execute(sql, args = nil, bulk_args = nil, http_options = {}) ⇒ ResultSet
Copy from github.com/crate/crate_ruby/blob/master/lib/crate_ruby/client.rb#L95
Executes a SQL statement against the Crate HTTP REST endpoint.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/fluent/plugin/out_cratedb.rb', line 95 def execute(sql, args = nil, bulk_args = nil, = {}) @logger.debug sql req = Net::HTTP::Post.new("/_sql", initheader = {'Content-Type' => 'application/json'}) body = {"stmt" => sql} body.merge!({'args' => args}) if args body.merge!({'bulk_args' => bulk_args}) if bulk_args req.body = body.to_json response = request(req, ) @logger.debug response.body success = case response.code when /^2\d{2}/ ResultSet.new response.body else @logger.info(response.body) raise CrateRuby::CrateError.new(response.body) end success end |