8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/emque/consuming/transmitter.rb', line 8
def self.send(command:, socket_path: "tmp/emque.sock", args: [])
if File.exist?(socket_path)
socket = UNIXSocket.new(socket_path)
socket.send(Oj.dump({
:command => command,
:args => args
}, :mode => :compat), 0)
response = socket.recv(10000000)
socket.close
response
else
"Socket not found at #{socket_path}"
end
rescue Errno::ECONNREFUSED
FileUtils.rm_f(socket_path) if File.exist?(socket_path)
"The UNIX Socket found at #{socket_path} was dead"
end
|