Class: EMogileFS::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/emogilefs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, request) ⇒ Request

Returns a new instance of Request.



77
78
79
80
81
# File 'lib/emogilefs.rb', line 77

def initialize(client, request)
  self.client, self.request = client, request
  self.socket = client.send :socket
  EMogileFS << self
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



76
77
78
# File 'lib/emogilefs.rb', line 76

def client
  @client
end

#optionsObject

Returns the value of attribute options.



76
77
78
# File 'lib/emogilefs.rb', line 76

def options
  @options
end

#requestObject

Returns the value of attribute request.



76
77
78
# File 'lib/emogilefs.rb', line 76

def request
  @request
end

#socketObject

Returns the value of attribute socket.



76
77
78
# File 'lib/emogilefs.rb', line 76

def socket
  @socket
end

Instance Method Details

#callback(options = {}, &block) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/emogilefs.rb', line 83

def callback(options = {}, &block)
  if block
    @options = options
    @callback = block
  else
    @callback
  end
end

#performObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/emogilefs.rb', line 92

def perform
  begin
    bytes_sent = socket.send request, 0
  rescue SystemCallError
    client.send :shutdown
    raise MogileFS::UnreachableBackendError
  end

  unless bytes_sent == request.length then
    raise MogileFS::RequestTruncatedError,
      "request truncated (sent #{bytes_sent} expected #{request.length})"
  end
  
end