Class: PGPool::NodeInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pgpool/node_info.rb

Overview

class: NodeInfo, PORO

Constant Summary collapse

INITIALIZING =

This state is only used during the initialization.

0
UP_NO_CONNECTIONS =

Node is up. No connections yet.

1
UP =

Node is up. Connections are pooled.

2
DOWN =

Node is down.

3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, hostname, port, status, weight) ⇒ NodeInfo

Returns a new instance of NodeInfo.



28
29
30
31
32
33
34
35
36
37
# 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

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



26
27
28
# File 'lib/pgpool/node_info.rb', line 26

def hostname
  @hostname
end

#idObject (readonly)

Returns the value of attribute id.



26
27
28
# File 'lib/pgpool/node_info.rb', line 26

def id
  @id
end

#portObject (readonly)

Returns the value of attribute port.



26
27
28
# File 'lib/pgpool/node_info.rb', line 26

def port
  @port
end

#statusObject

Returns the value of attribute status.



26
27
28
# File 'lib/pgpool/node_info.rb', line 26

def status
  @status
end

#weightObject (readonly)

Returns the value of attribute weight.



26
27
28
# File 'lib/pgpool/node_info.rb', line 26

def weight
  @weight
end

Class Method Details

.build_from_raw_data(id, command_raw_data) ⇒ Object



20
21
22
23
24
# 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

Instance Method Details

#down?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/pgpool/node_info.rb', line 47

def down?
  status == DOWN
end

#initializing?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/pgpool/node_info.rb', line 39

def initializing?
  status == INITIALIZING
end

#inspectObject



55
56
57
# File 'lib/pgpool/node_info.rb', line 55

def inspect
  to_hash.inspect
end

#to_hashObject



51
52
53
# File 'lib/pgpool/node_info.rb', line 51

def to_hash
  { id: id, hostname: hostname, port: port, status: status, weight: weight }
end

#to_sObject



59
60
61
# File 'lib/pgpool/node_info.rb', line 59

def to_s
  inspect
end

#up?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/pgpool/node_info.rb', line 43

def up?
  (status == UP || status == UP_NO_CONNECTIONS)
end