Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
44
backend/sdk/cliproxy/watcher.go
Normal file
44
backend/sdk/cliproxy/watcher.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package cliproxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/router-for-me/CLIProxyAPI/v7/internal/watcher"
|
||||
coreauth "github.com/router-for-me/CLIProxyAPI/v7/sdk/cliproxy/auth"
|
||||
"github.com/router-for-me/CLIProxyAPI/v7/sdk/config"
|
||||
)
|
||||
|
||||
func defaultWatcherFactory(configPath, authDir string, reload func(*config.Config)) (*WatcherWrapper, error) {
|
||||
w, err := watcher.NewWatcher(configPath, authDir, reload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &WatcherWrapper{
|
||||
start: func(ctx context.Context) error {
|
||||
return w.Start(ctx)
|
||||
},
|
||||
stop: func() error {
|
||||
return w.Stop()
|
||||
},
|
||||
setConfig: func(cfg *config.Config) {
|
||||
w.SetConfig(cfg)
|
||||
},
|
||||
snapshotAuths: func() []*coreauth.Auth { return w.SnapshotCoreAuths() },
|
||||
setUpdateQueue: func(queue chan<- watcher.AuthUpdate) {
|
||||
w.SetAuthUpdateQueue(queue)
|
||||
},
|
||||
dispatchRuntimeUpdate: func(update watcher.AuthUpdate) bool {
|
||||
return w.DispatchRuntimeAuthUpdate(update)
|
||||
},
|
||||
dispatchPersistedAuth: func(update watcher.AuthUpdate) bool {
|
||||
return w.DispatchPersistedAuthUpdate(update)
|
||||
},
|
||||
setPluginAuthParser: func(parser PluginAuthParser) {
|
||||
w.SetPluginAuthParser(parser)
|
||||
},
|
||||
reloadConfigIfChanged: func() {
|
||||
w.ReloadConfigIfChanged()
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
Loading…
Reference in a new issue