good morning!!!!

Skip to content
Snippets Groups Projects
Commit d0de3377 authored by Garet Halliday's avatar Garet Halliday
Browse files

better scaling up

parent 69e3d957
Branches
Tags
No related merge requests found
...@@ -25,7 +25,7 @@ type Pool struct { ...@@ -25,7 +25,7 @@ type Pool struct {
closed chan struct{} closed chan struct{}
backingOff atomic.Bool scalingUp atomic.Bool
recipes map[string]*recipe.Recipe recipes map[string]*recipe.Recipe
clients map[uuid.UUID]*Client clients map[uuid.UUID]*Client
...@@ -147,14 +147,13 @@ func (T *Pool) removeRecipe(name string) { ...@@ -147,14 +147,13 @@ func (T *Pool) removeRecipe(name string) {
} }
func (T *Pool) scaleUp() { func (T *Pool) scaleUp() {
backoff := T.options.ServerReconnectInitialTime if T.scalingUp.Swap(true) {
backingOff := false // another person is trying to scale up this pool already
return
defer func() {
if backingOff {
T.backingOff.Store(false)
} }
}() defer T.scalingUp.Store(false)
backoff := T.options.ServerReconnectInitialTime
for { for {
select { select {
...@@ -163,11 +162,6 @@ func (T *Pool) scaleUp() { ...@@ -163,11 +162,6 @@ func (T *Pool) scaleUp() {
default: default:
} }
if !backingOff && T.backingOff.Load() {
// already in backoff
return
}
name, r := func() (string, *recipe.Recipe) { name, r := func() (string, *recipe.Recipe) {
T.mu.RLock() T.mu.RLock()
defer T.mu.RUnlock() defer T.mu.RUnlock()
...@@ -199,13 +193,6 @@ func (T *Pool) scaleUp() { ...@@ -199,13 +193,6 @@ func (T *Pool) scaleUp() {
return return
} }
if !backingOff {
if T.backingOff.Swap(true) {
return
}
backingOff = true
}
log.Printf("failed to dial server. trying again in %v", backoff) log.Printf("failed to dial server. trying again in %v", backoff)
time.Sleep(backoff) time.Sleep(backoff)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment