mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 12:42:34 +02:00
23 lines
502 B
Go
23 lines
502 B
Go
package watcher
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/yusing/go-proxy/internal/common"
|
|
)
|
|
|
|
var (
|
|
configDirWatcher *DirWatcher
|
|
configDirWatcherMu sync.Mutex
|
|
)
|
|
|
|
// create a new file watcher for file under ConfigBasePath.
|
|
func NewConfigFileWatcher(filename string) Watcher {
|
|
configDirWatcherMu.Lock()
|
|
defer configDirWatcherMu.Unlock()
|
|
if configDirWatcher == nil {
|
|
configDirWatcher = NewDirectoryWatcher(context.Background(), common.ConfigBasePath)
|
|
}
|
|
return configDirWatcher.Add(filename)
|
|
}
|