Skip to content

Commit

Permalink
Merge pull request brightbox#25 from brightbox/add-timeout-to-loadbal…
Browse files Browse the repository at this point in the history
…ancer-listeners

Add timeout to load balancer listeners
  • Loading branch information
gnufied committed Mar 20, 2012
2 parents 8ec2004 + ab4ee5e commit 25fec5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/brightbox-cli/commands/lbs-create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Brightbox
c.default_value "least-connections"
c.flag [:p, :policy]

c.desc "Listeners. Format: in-port:out-port:type. Comma separate multiple listeners."
c.default_value "80:80:http,443:443:tcp"
c.desc "Listeners. Format: in-port:out-port:type:timeout. Comma separate multiple listeners. Protocols can be tcp, http or http+ws and timeouts are in milliseconds."
c.default_value "80:80:http:50000,443:443:tcp:50000"
c.flag [:l, :listeners]

c.desc "Healthcheck port. Defaults to first listener out port."
Expand Down Expand Up @@ -46,9 +46,9 @@ module Brightbox
raise "You must specify which servers to balance connections to" if args.empty?

listeners = options[:l].split(",").collect do |l|
inport, outport, protocol = l.split ":"
inport, outport, protocol, timeout = l.split ":"
raise "listener '#{l}' is invalid" if inport.nil? or outport.nil? or protocol.nil?
{ :in => inport, :out => outport, :protocol => protocol }
{ :in => inport, :out => outport, :protocol => protocol, :timeout => timeout }
end

raise "You must specify at least one listener" if listeners.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/brightbox-cli/commands/lbs-update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Brightbox
c.desc "Load balancer policy"
c.flag [:p, :policy]

c.desc "Listeners (in-port:out-port:protocol. Comma separate multiple listeners)"
c.desc "Listeners (in-port:out-port:protocol:timeout. Comma separate multiple listeners)"
c.flag [:l, :listeners]

c.desc "Healthcheck port"
Expand Down Expand Up @@ -64,8 +64,8 @@ module Brightbox

if options[:l]
lbopts[:listeners] = options[:l].split(",").collect do |l|
inport, output, protocol = l.split ":"
{ :in => inport, :out => output, :protocol => protocol }
inport, output, protocol, timeout = l.split ":"
{ :in => inport, :out => output, :protocol => protocol, :timeout => timeout }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/brightbox-cli/load_balancers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cloud_ips

def listeners
if attributes[:listeners]
attributes[:listeners].collect { |l| [l["in"], l["out"], l["protocol"]].join(":") }
attributes[:listeners].collect { |l| [l["in"], l["out"], l["protocol"], l['timeout']].join(":") }
else
nil
end
Expand Down

0 comments on commit 25fec5e

Please sign in to comment.