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.
10 11 12 13 |
# File 'lib/rspec/hive/connector.rb', line 10 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.
8 9 10 |
# File 'lib/rspec/hive/connector.rb', line 8 def config @config end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
8 9 10 |
# File 'lib/rspec/hive/connector.rb', line 8 def result @result end |
Instance Method Details
#start_connection(db_name = DbName.random_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rspec/hive/connector.rb', line 15 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
31 32 33 34 35 36 37 |
# File 'lib/rspec/hive/connector.rb', line 31 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
39 40 41 42 43 44 45 |
# File 'lib/rspec/hive/connector.rb', line 39 def tlcli_connect RBHive.tcli_connect(@config.host, @config.port, ) do |connection| yield ConnectionDelegator.new(connection, @config) end end |