Module: OMQ::Transport::IPC
- Defined in:
- lib/omq/transport/ipc.rb
Overview
IPC transport using Unix domain sockets.
Supports both file-based paths and Linux abstract namespace (paths starting with @).
Defined Under Namespace
Classes: Listener
Class Method Summary collapse
-
.apply_buffer_sizes(sock, options) ⇒ Object
Applies SO_SNDBUF / SO_RCVBUF to
sockfrom the socket’s Options. -
.bind(endpoint, engine) ⇒ Listener
Binds an IPC server.
-
.connect(endpoint, engine) ⇒ void
Connects to an IPC endpoint.
Class Method Details
.apply_buffer_sizes(sock, options) ⇒ Object
Applies SO_SNDBUF / SO_RCVBUF to sock from the socket’s Options. No-op when both are nil (OS default).
55 56 57 58 59 60 61 62 63 |
# File 'lib/omq/transport/ipc.rb', line 55 def apply_buffer_sizes(sock, ) if .sndbuf sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, .sndbuf) end if .rcvbuf sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF, .rcvbuf) end end |
.bind(endpoint, engine) ⇒ Listener
Binds an IPC server.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omq/transport/ipc.rb', line 21 def bind(endpoint, engine) path = parse_path(endpoint) sock_path = to_socket_path(path) # Remove stale socket file for file-based paths File.delete(sock_path) if !abstract?(path) && File.exist?(sock_path) server = UNIXServer.new(sock_path) Listener.new(endpoint, server, path, engine) end |
.connect(endpoint, engine) ⇒ void
This method returns an undefined value.
Connects to an IPC endpoint.
40 41 42 43 44 45 46 |
# File 'lib/omq/transport/ipc.rb', line 40 def connect(endpoint, engine) path = parse_path(endpoint) sock_path = to_socket_path(path) sock = UNIXSocket.new(sock_path) apply_buffer_sizes(sock, engine.) engine.handle_connected(IO::Stream::Buffered.wrap(sock), endpoint: endpoint) end |