Class: Trace::Endpoint
- Inherits:
-
Struct
- Object
- Struct
- Trace::Endpoint
- Defined in:
- lib/finagle-thrift/tracer.rb
Constant Summary collapse
- MAX_I32 =
((2 ** 31) - 1)
- MASK =
(2 ** 32) - 1
Instance Attribute Summary collapse
-
#ipv4 ⇒ Object
Returns the value of attribute ipv4.
-
#port ⇒ Object
Returns the value of attribute port.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
Class Method Summary collapse
Instance Method Summary collapse
- #to_s ⇒ Object
- #to_thrift ⇒ Object
- #with_port(port) ⇒ Object
- #with_service_name(service_name) ⇒ Object
Instance Attribute Details
#ipv4 ⇒ Object
Returns the value of attribute ipv4
209 210 211 |
# File 'lib/finagle-thrift/tracer.rb', line 209 def ipv4 @ipv4 end |
#port ⇒ Object
Returns the value of attribute port
209 210 211 |
# File 'lib/finagle-thrift/tracer.rb', line 209 def port @port end |
#service_name ⇒ Object
Returns the value of attribute service_name
209 210 211 |
# File 'lib/finagle-thrift/tracer.rb', line 209 def service_name @service_name end |
Class Method Details
.host_to_i32(host) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/finagle-thrift/tracer.rb', line 213 def self.host_to_i32(host) unsigned_i32 = Socket.getaddrinfo(host, nil)[0][3].split(".").map do |i| i.to_i end.inject(0) { |a,e| (a << 8) + e } signed_i32 = if unsigned_i32 > MAX_I32 -1 * ((unsigned_i32 ^ MASK) + 1) else unsigned_i32 end signed_i32 end |
Instance Method Details
#to_s ⇒ Object
243 244 245 |
# File 'lib/finagle-thrift/tracer.rb', line 243 def to_s "#{service_name}@#{ipv4}:#{port}" end |
#to_thrift ⇒ Object
235 236 237 238 239 240 241 |
# File 'lib/finagle-thrift/tracer.rb', line 235 def to_thrift FinagleThrift::Endpoint.new( :ipv4 => self.ipv4, :port => self.port, :service_name => self.service_name ) end |
#with_port(port) ⇒ Object
227 228 229 |
# File 'lib/finagle-thrift/tracer.rb', line 227 def with_port(port) Endpoint.new(self.ipv4, port, self.service_name) end |
#with_service_name(service_name) ⇒ Object
231 232 233 |
# File 'lib/finagle-thrift/tracer.rb', line 231 def with_service_name(service_name) Endpoint.new(self.ipv4, self.port, service_name) end |