Class: PGPool::Response
- Inherits:
-
Object
- Object
- PGPool::Response
- Defined in:
- lib/pgpool/response.rb
Overview
class: Response
Constant Summary collapse
- OK =
0
- UNKNOWN =
Unknown Error (should not occur)
1
- EOF =
EOF Error
2
- NOMEM =
Memory shortage
3
- READ =
Error while reading from the server
4
- WRITE =
Error while writing to the server
5
- TIMEOUT =
Timeout
6
- INVAL =
Argument(s) to the PCP command was invalid
7
- CONN =
Server connection error
8
- NOCONN =
No connection exists
9
- SOCK =
Socket error
10
- HOST =
Hostname resolution error
11
- BACKEND =
PCP process error on the server
12
- AUTH =
Authorization failure
13
- ERROR_MESSAGES =
{ OK: 'No error', UNKNOWN: 'Unknown Error', EOF: 'EOF Error', NOMEM: 'Memory shortage', READ: 'Error while reading from the server', WRITE: 'Error while writing to the server', TIMEOUT: 'Timeout', INVAL: 'Argument(s) to the PCP command was invalid', CONN: 'Server connection error', NOCONN: 'No connection exists', SOCK: 'Socket error', HOST: 'Hostname resolution error', BACKEND: 'PCP process error on the server', AUTH: 'Authorization failure' }
Instance Attribute Summary collapse
-
#node_info ⇒ Object
readonly
Returns the value of attribute node_info.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error? ⇒ Boolean
- #error_message ⇒ Object
-
#initialize(node_id, command) ⇒ Response
constructor
A new instance of Response.
- #inspect ⇒ Object
- #success? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(node_id, command) ⇒ Response
Returns a new instance of Response.
41 42 43 44 45 46 |
# File 'lib/pgpool/response.rb', line 41 def initialize(node_id, command) @status = command.exitstatus @node_info = success? ? NodeInfo.build_from_raw_data(node_id, command.stdout) : command.stderr self end |
Instance Attribute Details
#node_info ⇒ Object (readonly)
Returns the value of attribute node_info.
39 40 41 |
# File 'lib/pgpool/response.rb', line 39 def node_info @node_info end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
39 40 41 |
# File 'lib/pgpool/response.rb', line 39 def status @status end |
Instance Method Details
#error? ⇒ Boolean
52 53 54 |
# File 'lib/pgpool/response.rb', line 52 def error? status != OK end |
#error_message ⇒ Object
56 57 58 |
# File 'lib/pgpool/response.rb', line 56 def ERROR_MESSAGES[@status] end |
#inspect ⇒ Object
64 65 66 |
# File 'lib/pgpool/response.rb', line 64 def inspect to_hash.inspect end |
#success? ⇒ Boolean
48 49 50 |
# File 'lib/pgpool/response.rb', line 48 def success? status == OK end |
#to_hash ⇒ Object
60 61 62 |
# File 'lib/pgpool/response.rb', line 60 def to_hash { status: @status, node_info: @node_info } end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/pgpool/response.rb', line 68 def to_s "#{inspect}" end |