class PGPool::NodeInfo

class: NodeInfo, PORO

Constants

DOWN
INITIALIZING
UP
UP_NO_CONNECTIONS

Attributes

hostname[R]
id[R]
port[R]
status[R]
weight[R]

Public Class Methods

build_from_raw_data(id, command_raw_data) click to toggle source
# File lib/pgpool/node_info.rb, line 20
def self.build_from_raw_data(id, command_raw_data)
  hostname, port, status, weight = command_raw_data.split(' ')

  NodeInfo.new(id, hostname, port, status, weight)
end
new(id, hostname, port, status, weight) click to toggle source
# File lib/pgpool/node_info.rb, line 28
def initialize(id, hostname, port, status, weight)
  @id         = id.to_i
  @hostname   = hostname
  @port       = port.to_i
  @weight     = weight.to_f

  self.status = status.to_i

  self
end

Public Instance Methods

down?() click to toggle source
# File lib/pgpool/node_info.rb, line 47
def down?
  status == DOWN
end
initializing?() click to toggle source
# File lib/pgpool/node_info.rb, line 39
def initializing?
  status == INITIALIZING
end
inspect() click to toggle source
# File lib/pgpool/node_info.rb, line 55
def inspect
  to_hash.inspect
end
to_hash() click to toggle source
# File lib/pgpool/node_info.rb, line 51
def to_hash
  { id: id, hostname: hostname, port: port, status: status, weight: weight }
end
to_s() click to toggle source
# File lib/pgpool/node_info.rb, line 59
def to_s
  inspect
end
up?() click to toggle source
# File lib/pgpool/node_info.rb, line 43
def up?
  (status == UP || status == UP_NO_CONNECTIONS)
end

Private Instance Methods

status=(status) click to toggle source
# File lib/pgpool/node_info.rb, line 12
def status=(status)
  fail("Invalid status: #{status}") unless [INITIALIZING, UP_NO_CONNECTIONS, UP, DOWN].include?(status)

  @status = status
end