Documentation
¶
Overview ¶
Copyright (c) 2023-2025 Chakib Ben Ziane <contact@blob42.xyz> and [`GoSuki` contributors] (https://github.com/blob42/gosuki/graphs/contributors).
All rights reserved.
SPDX-License-Identifier: AGPL-3.0-or-later
This file is part of GoSuki.
GoSuki is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSuki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with gosuki. If not, see <http://www.gnu.org/licenses/>.
Watch package provides functionality for watching file system events and managing bookmark data sources.
Index ¶
- func ReduceEvents(interval time.Duration, w WatchRunner)
- func WatchLoop(w any)
- type EventType
- type Fetcher
- type Loader
- type PollWork
- type Poller
- type ResetWatcher
- type Runner
- type Shutdowner
- type StatMaker
- type Watch
- type WatchDescriptor
- type WatchLoad
- type WatchLoader
- type WatchRunner
- type WatchWork
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReduceEvents ¶
func ReduceEvents(interval time.Duration, w WatchRunner)
Run reducer in its own thread when the watcher is started It receives a struct{event, func} and runs the func only once in the interval
Types ¶
type Fetcher ¶
Fetcher is an interface for modules that fetches data from some source and produces a list of bookmarks.
type Loader ¶
Loader is an interface for modules that can load bookmarks. It requires the implementation of a Load method, which returns a slice of pointers to gosuki.Bookmark and an error.
type PollWork ¶
Implement work unit for poller runners
func (PollWork) Run ¶
func (iw PollWork) Run(m manager.UnitManager)
type ResetWatcher ¶
type ResetWatcher interface {
ResetWatcher() error // resets a new watcher
}
If the browser needs the watcher to be reset for each new event
type Runner ¶
type Runner interface {
Run()
}
Modules the implement their bookmark loading through a Run() method with an internal logic of handling bookmarks and direct sync with gosuki DB Mostly used through implementing WatchRunner
type Shutdowner ¶
type Shutdowner interface {
Shutdown() error
}
type StatMaker ¶
type StatMaker interface {
ResetStats()
}
StatMaker interface can be implemented in modules that keep and track stats
type Watch ¶
type Watch struct {
Path string // Path to watch for events
EventTypes []fsnotify.Op // events to watch for
// event names to watch for (file/dir names)
// use "*" to watch all names
EventNames []string
// Reset the watcher at each event occurence (useful for `create` events)
ResetWatch bool
}
Watch is a filesystem object that can be watched for changes.
type WatchDescriptor ¶
type WatchDescriptor struct {
// ID is a unique identifier for the watch descriptor.
ID string
// W is the underlying fsnotify.Watcher that this wrapper uses to monitor file system events.
W *fsnotify.Watcher
// Watches is a slice of pointers to Watch objects, which represent specific files or directories being watched.
Watches []*Watch
// List of unique event names that where encountered
// Useful to track unique filenames in a watched path
TrackEventNames bool
EventNames []string
// contains filtered or unexported fields
}
WatchDescriptor is a warpper around an fsnotify.Watcher that defines watch properties.
func NewWatcher ¶
func NewWatcher(name string, watches ...*Watch) (*WatchDescriptor, error)
func NewWatcherWithReducer ¶
func NewWatcherWithReducer(name string, reducerLen int, watches ...*Watch) (*WatchDescriptor, error)
func (*WatchDescriptor) AddEventName ¶
func (w *WatchDescriptor) AddEventName(name string)
type WatchLoad ¶
type WatchLoad struct {
WatchLoader
}
A module that needs to watch paths to load boomkarks. Browsers SHOULD use WatchRunner instead.
func (WatchLoad) Run ¶
func (w WatchLoad) Run(m manager.UnitManager)
Implement work unit for watch loaders
type WatchLoader ¶
WatchLoader is an interface that combines the capabilities of both Watcher and Loader interfaces. It is intended for modules that need to watch for changes and also load bookmarks through the Load method.
type WatchRunner ¶
type WatchWork ¶
type WatchWork struct {
WatchRunner
}
Implement work unit for watchers
func WatchWorkers ¶
func (WatchWork) Run ¶
func (w WatchWork) Run(m manager.UnitManager)
type Watcher ¶
type Watcher interface {
Watch() *WatchDescriptor
}
Required interface to be implemented by browsers that want to use the fsnotify event loop and watch changes on bookmark files.