Class: Vertica::Protocol::Startup

Inherits:
FrontendMessage show all
Defined in:
lib/vertica/protocol/frontend/startup.rb

Instance Method Summary collapse

Methods inherited from FrontendMessage

#to_bytes

Methods inherited from Message

message_id

Constructor Details

#initialize(user, database, options = nil) ⇒ Startup

Returns a new instance of Startup.



7
8
9
10
11
12
13
14
15
16
# File 'lib/vertica/protocol/frontend/startup.rb', line 7

def initialize(user, database, options = nil)
  @user     = user
  @database = database
  @options  = options
  @type     = "vertica-rb"
  @pid      = Process.pid.to_s
  @platform = RUBY_PLATFORM
  @version  = Vertica::VERSION
  @label    = "#{@type}-#{@version}-#{SecureRandom.uuid}"
end

Instance Method Details

#message_bodyObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vertica/protocol/frontend/startup.rb', line 18

def message_body
  str =  [Vertica::PROTOCOL_VERSION].pack('N')
  str << ["user", @user].pack('Z*Z*')         if @user
  str << ["database", @database].pack('Z*Z*') if @database
  str << ["client_type", @type].pack('Z*Z*')
  str << ["client_pid", @pid].pack('Z*Z*')
  str << ["client_os", @platform].pack('Z*Z*')
  str << ["client_version", @version].pack('Z*Z*')
  str << ["client_label", @label].pack('Z*Z*')
  str << ["options", @options].pack('Z*Z*')   if @options
  str << [].pack('x')
end