Class: RSpec::Hive::Connector
- Inherits:
-
Object
- Object
- RSpec::Hive::Connector
- Defined in:
- lib/rspec/hive/connector.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(configuration) ⇒ Connector
constructor
A new instance of Connector.
- #start_connection(db_name = DbName.random_name) ⇒ Object
- #stop_connection(connection) ⇒ Object
- #tlcli_connect ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Connector
Returns a new instance of Connector.
12 13 14 15 |
# File 'lib/rspec/hive/connector.rb', line 12 def initialize(configuration) @config = configuration # transport: :sasl, sasl_params: {username: 'hive', password: ''}, end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/rspec/hive/connector.rb', line 10 def config @config end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
10 11 12 |
# File 'lib/rspec/hive/connector.rb', line 10 def result @result end |
Instance Method Details
#start_connection(db_name = DbName.random_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/hive/connector.rb', line 17 def start_connection(db_name = DbName.random_name) connection = open_connection connection.switch_database(db_name) @config..each do |key, value| connection.execute("SET #{key}=#{value}") end connection rescue Thrift::ApplicationException => e config.logger.fatal('An exception was thrown during start connection') config.logger.fatal(e) stop_connection(connection) connection end |
#stop_connection(connection) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rspec/hive/connector.rb', line 32 def stop_connection(connection) connection.close_session if connection.session connection.close rescue IOError => e config.logger.fatal('An exception was thrown during close connection') config.logger.fatal(e) end |
#tlcli_connect ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/rspec/hive/connector.rb', line 40 def tlcli_connect RBHive.tcli_connect(@config.host, @config.port, ) do |connection| yield ConnectionDelegator.new(connection, @config) end end |