Class: Tair::FetchDataServerResponse
- Defined in:
- lib/tair/operation/fetch_data_servers.rb
Defined Under Namespace
Classes: Body, CString, ConfigServer, DataServer, DataServersInfo, YaDataServer
Constant Summary collapse
- UNPACK_METHOD =
'C*'.freeze
- IP_SPLITTER =
'.'.freeze
Instance Attribute Summary
Attributes inherited from Response
Instance Method Summary collapse
Methods inherited from Response
Constructor Details
This class inherits a constructor from Tair::Response
Instance Method Details
#decode ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tair/operation/fetch_data_servers.rb', line 45 def decode Body.read(@body).tap do |body| bucket = body[:bucket] nodes = DataServersInfo.read(Zlib.inflate(body[:ds_data])).nodes.map do |n| [num_str_to_ip(n[:ip_num]), n[:port]].join(":".freeze).freeze end Cluster.new.tap do |cluster| cluster.update nodes, nodes_per_bucket: body[:bucket], copying_buckets_count: body[:copy] return cluster end end end |
#num_str_to_ip(str) ⇒ Object
66 67 68 |
# File 'lib/tair/operation/fetch_data_servers.rb', line 66 def num_str_to_ip(str) str.unpack(UNPACK_METHOD).join(IP_SPLITTER).freeze end |