Sha256: 27b48c4cc343a6b5cd755160b934b7bb7e7581fc4f9c4c0045d10c67a912cfab
Contents?: true
Size: 602 Bytes
Versions: 11
Compression:
Stored size: 602 Bytes
Contents
require 'socket' require 'timeout' class Eye::Client attr_reader :socket_path def initialize(socket_path) @socket_path = socket_path end def command(cmd, *args) attempt_command([cmd, *args] * '|') end def attempt_command(pack) Timeout.timeout(Eye::Settings.client_timeout) do return send_request(pack) end rescue Timeout::Error, EOFError :timeouted end def send_request(pack) UNIXSocket.open(@socket_path) do |socket| socket.puts(pack) data = socket.read res = Marshal.load(data) rescue :corrupred_marshal end end end
Version data entries
11 entries across 11 versions & 2 rubygems