Skip to content

Commit

Permalink
fix(watcher): remove default signal watch, use ctx (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
GGXXLL committed Feb 23, 2021
1 parent b13eb0b commit 3cd7b7b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"github.com/DoNewsCode/core/config/watcher"
"reflect"

"github.com/DoNewsCode/core/contract"
Expand Down Expand Up @@ -85,7 +84,8 @@ func (k KoanfAdapter) Reload() error {
// in the run group.
func (k KoanfAdapter) Watch(ctx context.Context) error {
if k.watcher == nil {
k.watcher = watcher.Signal{}
<-ctx.Done()
return ctx.Err()
}
return k.watcher.Watch(ctx, k.Reload)
}
Expand Down
2 changes: 2 additions & 0 deletions config/watcher/signal.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//+build !windows

package watcher

import (
Expand Down
2 changes: 2 additions & 0 deletions config/watcher/singal_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package watcher

import (
Expand Down

0 comments on commit 3cd7b7b

Please sign in to comment.