Class: ZooKeeper::Packet

Inherits:
Operation show all
Defined in:
lib/zkruby/protocol.rb

Direct Known Subclasses

ClosePacket, ExistsPacket

Instance Attribute Summary collapse

Attributes inherited from Operation

#callback, #op, #opcode, #request, #response

Instance Method Summary collapse

Methods inherited from Operation

#path

Constructor Details

#initialize(xid, op, opcode, request, response, watch_type, watcher, callback) ⇒ Packet

Returns a new instance of Packet.



82
83
84
85
86
# File 'lib/zkruby/protocol.rb', line 82

def initialize(xid,op,opcode,request,response,watch_type,watcher,callback)
    super(op,opcode,request,response,callback)
    @xid=xid;
    @watch_type = watch_type; @watcher = watcher
end

Instance Attribute Details

#watch_typeObject (readonly)

Returns the value of attribute watch_type.



80
81
82
# File 'lib/zkruby/protocol.rb', line 80

def watch_type
  @watch_type
end

#watcherObject (readonly)

Returns the value of attribute watcher.



80
81
82
# File 'lib/zkruby/protocol.rb', line 80

def watcher
  @watcher
end

#xidObject (readonly)

Returns the value of attribute xid.



80
81
82
# File 'lib/zkruby/protocol.rb', line 80

def xid
  @xid
end

Instance Method Details

#error(reason) ⇒ Object



89
90
91
# File 'lib/zkruby/protocol.rb', line 89

def error(reason)
    result(reason)[0..2] # don't need the watch
end

#result(rc) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/zkruby/protocol.rb', line 93

def result(rc)
    error = nil
    unless (Error::NONE === rc) then 
        error = Error.lookup(rc) 
        error = error.exception("ZooKeeper error for #{@op}(#{path}) ")
    end
    [ callback, error ,response, watch_type ] 
end