Class: QB::IPC::STDIO::Client::Connection
- Inherits:
-
Object
- Object
- QB::IPC::STDIO::Client::Connection
- Includes:
- NRSER::Log::Mixin
- Defined in:
- lib/qb/ipc/stdio/client.rb
Instance Attribute Summary collapse
-
#env_var_name ⇒ String
readonly
TODO document
env_var_name
attribute. -
#global_original ⇒ attr_type
readonly
TODO document
global_original
attribute. -
#name ⇒ Symbol
readonly
TODO document
name
attribute. -
#path ⇒ Pathname?
readonly
TODO document
path
attribute. -
#socket ⇒ UNIXSocket?
readonly
TODO document
socket
attribute. -
#type ⇒ :in | :out
readonly
TODO document
type
attribute.
Instance Method Summary collapse
- #connect! ⇒ Object
-
#connected? ⇒ Boolean
Instance Methods ========================================================================.
- #disconnect! ⇒ Object
-
#initialize(name:, type:) ⇒ Connection
constructor
Instantiate a new
Connection
.
Constructor Details
#initialize(name:, type:) ⇒ Connection
Instantiate a new Connection
.
101 102 103 104 105 106 107 108 |
# File 'lib/qb/ipc/stdio/client.rb', line 101 def initialize name:, type: @name = name @type = type @global_original = nil @path = nil @socket = nil @env_var_name = QB::IPC::STDIO.path_env_var_name name end |
Instance Attribute Details
#env_var_name ⇒ String (readonly)
TODO document env_var_name
attribute.
94 95 96 |
# File 'lib/qb/ipc/stdio/client.rb', line 94 def env_var_name @env_var_name end |
#global_original ⇒ attr_type (readonly)
TODO document global_original
attribute.
87 88 89 |
# File 'lib/qb/ipc/stdio/client.rb', line 87 def global_original @global_original end |
#name ⇒ Symbol (readonly)
TODO document name
attribute.
59 60 61 |
# File 'lib/qb/ipc/stdio/client.rb', line 59 def name @name end |
#path ⇒ Pathname? (readonly)
TODO document path
attribute.
73 74 75 |
# File 'lib/qb/ipc/stdio/client.rb', line 73 def path @path end |
#socket ⇒ UNIXSocket? (readonly)
TODO document socket
attribute.
80 81 82 |
# File 'lib/qb/ipc/stdio/client.rb', line 80 def socket @socket end |
#type ⇒ :in | :out (readonly)
TODO document type
attribute.
66 67 68 |
# File 'lib/qb/ipc/stdio/client.rb', line 66 def type @type end |
Instance Method Details
#connect! ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/qb/ipc/stdio/client.rb', line 119 def connect! if connected? raise "#{ inspect } is already connected!" end if get_path! @global_original = global_get @socket = UNIXSocket.new path.to_s global_set! socket end end |
#connected? ⇒ Boolean
Instance Methods
114 115 116 |
# File 'lib/qb/ipc/stdio/client.rb', line 114 def connected? !!socket end |
#disconnect! ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/qb/ipc/stdio/client.rb', line 132 def disconnect! return unless connected? logger.debug "Disconnecting...", name: name, socket: socket, global_original: global_original # Restore the original global and `nil` it out (if we have one) if global_original global_set! global_original @global_original = nil end # Flush the socket if it's an out-bound socket.flush if type == :out # And close and `nil` it socket.close @socket = nil end |