30 lines
535 B
Go
30 lines
535 B
Go
|
|
package env
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"github.com/geo-platform/tenant-api/internal/shared/config/runtime"
|
||
|
|
)
|
||
|
|
|
||
|
|
var _ runtime.Watcher = (*watcher)(nil)
|
||
|
|
|
||
|
|
type watcher struct {
|
||
|
|
ctx context.Context
|
||
|
|
cancel context.CancelFunc
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewWatcher() (runtime.Watcher, error) {
|
||
|
|
ctx, cancel := context.WithCancel(context.Background())
|
||
|
|
return &watcher{ctx: ctx, cancel: cancel}, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (w *watcher) Next() ([]*runtime.KeyValue, error) {
|
||
|
|
<-w.ctx.Done()
|
||
|
|
return nil, w.ctx.Err()
|
||
|
|
}
|
||
|
|
|
||
|
|
func (w *watcher) Stop() error {
|
||
|
|
w.cancel()
|
||
|
|
return nil
|
||
|
|
}
|