Class: Fastdfs::Client::Tracker
- Extended by:
- Hook
- Defined in:
- lib/fastdfs-client/tracker.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#options ⇒ Object
Returns the value of attribute options.
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
- #get_storage ⇒ Object
-
#initialize(host, port, options = {}) ⇒ Tracker
constructor
A new instance of Tracker.
Methods included from Hook
add_hook, after, before, ensure_hijacked, hooks, method_added
Constructor Details
#initialize(host, port, options = {}) ⇒ Tracker
Returns a new instance of Tracker.
14 15 16 17 |
# File 'lib/fastdfs-client/tracker.rb', line 14 def initialize(host, port, = {}) @socket = Socket.new(host, port, [:socket]) @cmd = CMD::STORE_WITHOUT_GROUP_ONE end |
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
12 13 14 |
# File 'lib/fastdfs-client/tracker.rb', line 12 def cmd @cmd end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/fastdfs-client/tracker.rb', line 12 def @options end |
#socket ⇒ Object
Returns the value of attribute socket.
12 13 14 |
# File 'lib/fastdfs-client/tracker.rb', line 12 def socket @socket end |
Instance Method Details
#get_storage ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fastdfs-client/tracker.rb', line 19 def get_storage header = ProtoCommon.header_bytes(@cmd, 0) @socket.write(@cmd, header) @socket.receive do |body| storage_ip = body[ProtoCommon::IPADDR].strip storage_port = body[ProtoCommon::PORT].unpack("C*").to_pack_long store_path = body[ProtoCommon::TRACKER_BODY_LEN-1].unpack("C*")[0] Storage.new(storage_ip, storage_port, store_path, ) end end |