diff options
Diffstat (limited to 'worker/handlers')
-rw-r--r-- | worker/handlers/register.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/worker/handlers/register.go b/worker/handlers/register.go index c871f07b..c94a256e 100644 --- a/worker/handlers/register.go +++ b/worker/handlers/register.go @@ -2,6 +2,7 @@ package handlers import ( "fmt" + "runtime" "git.sr.ht/~rjarry/aerc/worker/types" ) @@ -25,3 +26,18 @@ func GetHandlerForScheme(scheme string, worker *types.Worker) (types.Backend, er } return backend, nil } + +type WatcherFactoryFunc func() (types.FSWatcher, error) + +var watcherFactories map[string]WatcherFactoryFunc = make(map[string]WatcherFactoryFunc) + +func RegisterWatcherFactory(os string, fn WatcherFactoryFunc) { + watcherFactories[os] = fn +} + +func NewWatcher() (types.FSWatcher, error) { + if fn, ok := watcherFactories[runtime.GOOS]; ok { + return fn() + } + return nil, fmt.Errorf("Unsupported OS: %s", runtime.GOOS) +} |