Skip to content

Commit

Permalink
refactor: fix commenting and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tochemey committed Jul 9, 2023
1 parent 7ca75e3 commit ba10d67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion discovery/kubernetes/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (d *Discovery) Stop() error {
// release the lock
defer d.mu.Unlock()

// first check whether the actor system has started
// first check whether the discovery provider has started
if !d.isInitialized.Load() {
return errors.New("kubernetes discovery engine not initialized")
}
Expand Down
11 changes: 7 additions & 4 deletions discovery/static/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ func (d *Discovery) EarliestNode(ctx context.Context) (*discovery.Node, error) {

// Stop shutdown the discovery engine
func (d *Discovery) Stop() error {
// first check whether the actor system has started
if !d.isInitialized.Load() {
return errors.New("static discovery engine not initialized")
}
// acquire the lock
d.mu.Lock()
// release the lock
defer d.mu.Unlock()

// first check whether the discovery provider has started
if !d.isInitialized.Load() {
return errors.New("static discovery engine not initialized")
}
// set the initialized to false
d.isInitialized = atomic.NewBool(false)
// close the public channel
close(d.publicChan)
// stop the watchers
Expand Down

0 comments on commit ba10d67

Please sign in to comment.