Documentation ¶
Overview ¶
Watches a directory recursively, translating file system events into our internal Op structure.
File events are complicated! Here are some helpful links: https://fsnotify.org/ http://man7.org/linux/man-pages/man7/inotify.7.html
Index ¶
- Constants
- func DefaultMatcher() *ospath.Matcher
- func LimitChecksEnabled() bool
- func NewWatcher() (wmNotify, error)
- func SetLimitChecksEnabled(enabled bool)
- type RecipeTagProvider
- type WatchErrEvent
- type WatchEvent
- type WatchOpsEvent
- type WatchSyncEvent
- type WorkspaceWatcher
- func NewWorkspaceWatcher(path string, db dbint.DB2, matcher *ospath.Matcher, owner data.UserID, ...) (*WorkspaceWatcher, error)
- func NewWorkspaceWatcherAndSync(path string, db dbint.DB2, previous data.SnapshotID, matcher *ospath.Matcher, ...) (*WorkspaceWatcher, error)
- func NewWorkspaceWatcherWithLimit(path string, db dbint.DB2, matcher *ospath.Matcher, owner data.UserID, ...) (*WorkspaceWatcher, error)
Constants ¶
const CheckLimitKey = "WM_CHECK_LIMIT"
const MAX_COALESCE = 10
We put a cap on how many sequential events to coalesce for use-cases like log files where we see continuous data for a long time.
Variables ¶
This section is empty.
Functions ¶
func DefaultMatcher ¶
The default matcher of a watcher. Just ignores .git directories.
func LimitChecksEnabled ¶
func LimitChecksEnabled() bool
func NewWatcher ¶
func NewWatcher() (wmNotify, error)
func SetLimitChecksEnabled ¶
func SetLimitChecksEnabled(enabled bool)
Allows limit checks to be disabled for testing.
Types ¶
type RecipeTagProvider ¶
type RecipeTagProvider func() data.RecipeWTag
func NewRecipeTagProvider ¶
func NewRecipeTagProvider(tag data.RecipeWTag) RecipeTagProvider
type WatchEvent ¶
type WatchEvent interface {
// contains filtered or unexported methods
}
type WatchOpsEvent ¶
type WatchOpsEvent struct { SnapID data.SnapshotID Ops []data.Op }
New ops have been created
func ChangesSinceModTimeToOpsEvent ¶
func ChangesSinceModTimeToOpsEvent(path string, db dbint.DB2, previous data.SnapshotID, owner data.UserID, minMtime time.Time) (WatchOpsEvent, error)
Crawls a directory for modifications since the given time, and generates temp write ops for everything in it.
func DirectoryToOpsEvent ¶
func DirectoryToOpsEvent(path string, db dbint.DB2, matcher *ospath.Matcher, previous data.SnapshotID, owner data.UserID, tag data.RecipeWTag) (WatchOpsEvent, error)
Crawls a directory, and generates write ops for everything in it.
func (WatchOpsEvent) IsEmpty ¶
func (e WatchOpsEvent) IsEmpty() bool
type WorkspaceWatcher ¶
type WorkspaceWatcher struct { Events chan WatchEvent // contains filtered or unexported fields }
Watches a directory of files and emits Ops for each change.
func NewWorkspaceWatcher ¶
func NewWorkspaceWatcher(path string, db dbint.DB2, matcher *ospath.Matcher, owner data.UserID, tag data.RecipeWTag, tmp *temp.TempDir) (*WorkspaceWatcher, error)
Watches a directory. Does not generate write ops for existing contents.
func NewWorkspaceWatcherAndSync ¶
func NewWorkspaceWatcherAndSync(path string, db dbint.DB2, previous data.SnapshotID, matcher *ospath.Matcher, owner data.UserID, tagFn RecipeTagProvider, tmp *temp.TempDir) (*WorkspaceWatcher, error)
Watches a directory.
Generates write ops for any existing contents of the directory that aren't in the snapshot, and remove ops for any contents of the snapshot that aren't in the directory.
The use of RecipeTagProvider is a major hack so that we can assign a Temp tag recipe to the initial ops. I wish we had a better way to do this but this is good enough for now.
func (*WorkspaceWatcher) Close ¶
func (ww *WorkspaceWatcher) Close() error
func (*WorkspaceWatcher) FSync ¶
func (ww *WorkspaceWatcher) FSync(ctx context.Context, token string) error
Wait for WorkspaceWatcher to catch up We accomplish this by writing to a file in a sync directory and waiting to notice. Sends a SyncOp on the ops channel with the given token. Cf. https://facebook.github.io/watchman/docs/cookies.html TODO(dbentley): what if they end up on different filesystems?
func (*WorkspaceWatcher) Matcher ¶
func (ww *WorkspaceWatcher) Matcher() *ospath.Matcher
func (*WorkspaceWatcher) NotifyOnChange ¶
func (ww *WorkspaceWatcher) NotifyOnChange(path string, c chan struct{})
func (*WorkspaceWatcher) Root ¶
func (ww *WorkspaceWatcher) Root() string