Class: Pgai::Port::Allocator
- Inherits:
-
Object
- Object
- Pgai::Port::Allocator
- Defined in:
- lib/pgai/port/allocator.rb
Constant Summary collapse
- START_PORT =
5000
- FINISH_PORT =
9000
- LOCALHOST =
"127.0.0.1"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(start: START_PORT, finish: FINISH_PORT) ⇒ Allocator
constructor
A new instance of Allocator.
- #pick ⇒ Object
Constructor Details
#initialize(start: START_PORT, finish: FINISH_PORT) ⇒ Allocator
Returns a new instance of Allocator.
16 17 18 19 |
# File 'lib/pgai/port/allocator.rb', line 16 def initialize(start: START_PORT, finish: FINISH_PORT) @start = start @finish = finish end |
Class Method Details
.pick ⇒ Object
12 13 14 |
# File 'lib/pgai/port/allocator.rb', line 12 def self.pick new.pick end |
Instance Method Details
#pick ⇒ Object
21 22 23 24 25 |
# File 'lib/pgai/port/allocator.rb', line 21 def pick (start + jitter).upto(finish) do |port| return port if available?(port) end end |