Class: Protobuf::Rpc::ServiceDirectory::Listing
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Protobuf::Rpc::ServiceDirectory::Listing
- Defined in:
- lib/protobuf/rpc/service_directory.rb
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
Instance Method Summary collapse
- #current? ⇒ Boolean
- #eql?(other) ⇒ Boolean
- #expired? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(server) ⇒ Listing
constructor
A new instance of Listing.
- #ttl ⇒ Object
- #update(server) ⇒ Object
Constructor Details
#initialize(server) ⇒ Listing
Returns a new instance of Listing.
31 32 33 |
# File 'lib/protobuf/rpc/service_directory.rb', line 31 def initialize(server) update(server) end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
29 30 31 |
# File 'lib/protobuf/rpc/service_directory.rb', line 29 def expires_at @expires_at end |
Instance Method Details
#current? ⇒ Boolean
35 36 37 |
# File 'lib/protobuf/rpc/service_directory.rb', line 35 def current? !expired? end |
#eql?(other) ⇒ Boolean
39 40 41 |
# File 'lib/protobuf/rpc/service_directory.rb', line 39 def eql?(other) uuid.eql?(other.uuid) end |
#expired? ⇒ Boolean
43 44 45 |
# File 'lib/protobuf/rpc/service_directory.rb', line 43 def expired? Time.now.to_i >= @expires_at end |
#hash ⇒ Object
47 48 49 |
# File 'lib/protobuf/rpc/service_directory.rb', line 47 def hash uuid.hash end |
#ttl ⇒ Object
51 52 53 |
# File 'lib/protobuf/rpc/service_directory.rb', line 51 def ttl [super.to_i, 1].max end |
#update(server) ⇒ Object
55 56 57 58 |
# File 'lib/protobuf/rpc/service_directory.rb', line 55 def update(server) __setobj__(server) @expires_at = Time.now.to_i + ttl end |