Class: Terastream::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/terastream/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.



7
8
9
10
11
12
# File 'lib/terastream/connection.rb', line 7

def initialize(options = {})
  @config     = Config.new(options)
  @connection = nil
  @formatter  = Terastream::Query::RecordsBuilder.new
  @output     = nil
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/terastream/connection.rb', line 5

def config
  @config
end

#formatterObject

Returns the value of attribute formatter.



3
4
5
# File 'lib/terastream/connection.rb', line 3

def formatter
  @formatter
end

#outputObject

Returns the value of attribute output.



3
4
5
# File 'lib/terastream/connection.rb', line 3

def output
  @output
end

Instance Method Details

#connectionObject



14
15
16
# File 'lib/terastream/connection.rb', line 14

def connection
  @connection ||= get_connection
end

#create_statementObject



18
19
20
# File 'lib/terastream/connection.rb', line 18

def create_statement
  connection.create_statement
end

#hostname=(hostname) ⇒ Object



35
36
37
# File 'lib/terastream/connection.rb', line 35

def hostname=(hostname)
  config.hostname = hostname
end

#password=(password) ⇒ Object



31
32
33
# File 'lib/terastream/connection.rb', line 31

def password=(password)
  config.password = password
end

#query(query_string) ⇒ Object



22
23
24
# File 'lib/terastream/connection.rb', line 22

def query(query_string)
  Query.build(self).execute(query_string)
end

#timeout=(timeout) ⇒ Object



39
40
41
# File 'lib/terastream/connection.rb', line 39

def timeout=(timeout)
  config.timeout = timeout
end

#username=(username) ⇒ Object

Config helpers



27
28
29
# File 'lib/terastream/connection.rb', line 27

def username=(username)
  config.username = username
end