Class: Fastdfs::Client::Tracker
- Includes:
- Delegation
- Defined in:
- lib/fastdfs-client/tracker.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #get_storage(alive = false) ⇒ Object
-
#initialize(options = {}) ⇒ Tracker
constructor
A new instance of Tracker.
- #pipeline ⇒ Object
Methods included from Delegation
Constructor Details
#initialize(options = {}) ⇒ Tracker
Returns a new instance of Tracker.
14 15 16 17 18 19 20 21 |
# File 'lib/fastdfs-client/tracker.rb', line 14 def initialize( = {}) @options = () @proxies = @options[:trackers].map do |tracker| opt = tracker.fs_symbolize_keys ClientProxy.new(opt[:host], opt[:port], .merge(alive: true)) end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/fastdfs-client/tracker.rb', line 10 def @options end |
Instance Method Details
#get_storage(alive = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fastdfs-client/tracker.rb', line 23 def get_storage(alive = false) res = proxy.dispose(CMD::STORE_WITHOUT_GROUP_ONE) 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, .merge(alive: alive)) end raise res[:err_msg] unless res[:status] res[:result] end |
#pipeline ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/fastdfs-client/tracker.rb', line 35 def pipeline storage = get_storage(true) yield storage storage ensure storage.proxy.close end |