Skip to content

Commit

Permalink
move lock aquisition to where we absolutely must acquire it, rather t…
Browse files Browse the repository at this point in the history
…han super early.
  • Loading branch information
puellanivis committed Jun 14, 2018
1 parent c893dba commit 108cbe7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions health.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ type (

// Register registers a check config to be performed.
func Register(c Config) error {
mu.Lock()
defer mu.Unlock()

if c.Timeout == 0 {
c.Timeout = time.Second * 2
}
Expand All @@ -84,6 +81,9 @@ func Register(c Config) error {
return errors.New("health check must have a name to be registered")
}

mu.Lock()
defer mu.Unlock()

if _, ok := checkMap[c.Name]; ok {
return fmt.Errorf("health check %s is already registered", c.Name)
}
Expand Down

0 comments on commit 108cbe7

Please sign in to comment.