Class: CSC::Server
- Inherits:
-
Object
- Object
- CSC::Server
- Defined in:
- lib/cache-server-connector/server.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#called ⇒ Object
Returns the value of attribute called.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#weight_called ⇒ Object
Returns the value of attribute weight_called.
Instance Method Summary collapse
- #indexed ⇒ Object
-
#initialize(host, weight = 1, port = 0) ⇒ Server
constructor
A new instance of Server.
- #to_s ⇒ Object
Constructor Details
#initialize(host, weight = 1, port = 0) ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/cache-server-connector/server.rb', line 7 def initialize(host, weight = 1, port = 0) raise NotImplementedError.new("#{self.class.name} is an abstract class.") end |
Instance Attribute Details
#called ⇒ Object
Returns the value of attribute called.
5 6 7 |
# File 'lib/cache-server-connector/server.rb', line 5 def called @called end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/cache-server-connector/server.rb', line 5 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/cache-server-connector/server.rb', line 5 def port @port end |
#weight ⇒ Object
Returns the value of attribute weight.
5 6 7 |
# File 'lib/cache-server-connector/server.rb', line 5 def weight @weight end |
#weight_called ⇒ Object
Returns the value of attribute weight_called.
5 6 7 |
# File 'lib/cache-server-connector/server.rb', line 5 def weight_called @weight_called end |
Instance Method Details
#indexed ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cache-server-connector/server.rb', line 11 def indexed @mutex ||= Mutex.new @mutex.synchronize { @called += 1 @weight_called = (@called + 1 / @weight).to_i } self end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/cache-server-connector/server.rb', line 22 def to_s "#@host:#@port" end |