package watch
import "github.com/docker/compose/v2/pkg/watch"
Index ¶
- Constants
- func BatchDebounceEvents(ctx context.Context, clock clockwork.Clock, input <-chan FileEvent) <-chan []FileEvent
- func DesiredWindowsBufferSize() int
- func DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error)
- func IsWindowsShortReadError(err error) bool
- func MaybeIncreaseBufferSize(w *fsnotify.Watcher)
- func NewDockerPatternMatcher(repoRoot string, patterns []string) (*dockerPathMatcher, error)
- func SanitizeFileName(name string) string
- type AnyMatcher
- func (AnyMatcher) Matches(f string) (bool, error)
- func (AnyMatcher) MatchesEntireDir(f string) (bool, error)
- type CompositePathMatcher
- func (c CompositePathMatcher) Matches(f string) (bool, error)
- func (c CompositePathMatcher) MatchesEntireDir(f string) (bool, error)
- type EmptyMatcher
- func (EmptyMatcher) Matches(f string) (bool, error)
- func (EmptyMatcher) MatchesEntireDir(f string) (bool, error)
- type FileEvent
- type Notify
- type PathMatcher
- func EphemeralPathMatcher() PathMatcher
- func LoadDockerIgnore(build *types.BuildConfig) (PathMatcher, error)
- func NewCompositeMatcher(matchers ...PathMatcher) PathMatcher
- type TempDir
- func NewDir(prefix string) (*TempDir, error)
- func NewDirAtRoot(root, prefix string) (*TempDir, error)
- func NewDirAtSlashTmp(prefix string) (*TempDir, error)
- func (d *TempDir) NewDeterministicDir(name string) (*TempDir, error)
- func (d *TempDir) NewDir(prefix string) (*TempDir, error)
- func (d *TempDir) Path() string
- func (d *TempDir) TearDown() error
- type TempDirFixture
- func NewTempDirFixture(t testing.TB) *TempDirFixture
- func (f *TempDirFixture) Chdir()
- func (f *TempDirFixture) CopyFile(originalPath, newPath string)
- func (f *TempDirFixture) JoinPath(path ...string) string
- func (f *TempDirFixture) JoinPaths(paths []string) []string
- func (f *TempDirFixture) MkdirAll(path string)
- func (f *TempDirFixture) NewFile(prefix string) (*os.File, error)
- func (f *TempDirFixture) Path() string
- func (f *TempDirFixture) ReadFile(path string) string
- func (f *TempDirFixture) Rm(pathInRepo string)
- func (f *TempDirFixture) T() testing.TB
- func (f *TempDirFixture) TempDir(prefix string) string
- func (f *TempDirFixture) TouchFiles(paths []string)
- func (f *TempDirFixture) WriteFile(path string, contents string) string
- func (f *TempDirFixture) WriteSymlink(linkContents, destPath string)
Constants ¶
const QuietPeriod = 500 * time.Millisecond
const WindowsBufferSizeEnvVar = "COMPOSE_WATCH_WINDOWS_BUFFER_SIZE"
Functions ¶
func BatchDebounceEvents ¶
func BatchDebounceEvents(ctx context.Context, clock clockwork.Clock, input <-chan FileEvent) <-chan []FileEvent
BatchDebounceEvents groups identical file events within a sliding time window and writes the results to the returned channel.
The returned channel is closed when the debouncer is stopped via context cancellation or by closing the input channel.
func DesiredWindowsBufferSize ¶
func DesiredWindowsBufferSize() int
func DockerIgnoreTesterFromContents ¶
func IsWindowsShortReadError ¶
func MaybeIncreaseBufferSize ¶
func NewDockerPatternMatcher ¶
func SanitizeFileName ¶
Types ¶
type AnyMatcher ¶
type AnyMatcher struct{}
AnyMatcher is a PathMatcher to match any path
func (AnyMatcher) Matches ¶
func (AnyMatcher) Matches(f string) (bool, error)
func (AnyMatcher) MatchesEntireDir ¶
func (AnyMatcher) MatchesEntireDir(f string) (bool, error)
type CompositePathMatcher ¶
type CompositePathMatcher struct { Matchers []PathMatcher }
func (CompositePathMatcher) Matches ¶
func (c CompositePathMatcher) Matches(f string) (bool, error)
func (CompositePathMatcher) MatchesEntireDir ¶
func (c CompositePathMatcher) MatchesEntireDir(f string) (bool, error)
type EmptyMatcher ¶
type EmptyMatcher struct{}
EmptyMatcher is a PathMatcher to match no path
func (EmptyMatcher) Matches ¶
func (EmptyMatcher) Matches(f string) (bool, error)
func (EmptyMatcher) MatchesEntireDir ¶
func (EmptyMatcher) MatchesEntireDir(f string) (bool, error)
type FileEvent ¶
type FileEvent string
func NewFileEvent ¶
type Notify ¶
type Notify interface { // Start watching the paths set at init time Start() error // Stop watching and close all channels Close() error // A channel to read off incoming file changes Events() chan FileEvent // A channel to read off show-stopping errors Errors() chan error }
func NewWatcher ¶
type PathMatcher ¶
type PathMatcher interface { Matches(file string) (bool, error) // If this matches the entire dir, we can often optimize filetree walks a bit. MatchesEntireDir(file string) (bool, error) }
When we specify directories to watch, we often want to ignore some subset of the files under those directories.
For example: - Watch /src/repo, but ignore /src/repo/.git - Watch /src/repo, but ignore everything in /src/repo/bazel-bin except /src/repo/bazel-bin/app-binary
The PathMatcher interface helps us manage these ignores.
func EphemeralPathMatcher ¶
func EphemeralPathMatcher() PathMatcher
EphemeralPathMatcher filters out spurious changes that we don't want to rebuild on, like IDE temp/lock files.
This isn't an ideal solution. In an ideal world, the user would put everything to ignore in their tiltignore/dockerignore files. This is a stop-gap so they don't have a terrible experience if those files aren't there or aren't in the right places.
NOTE: The underlying `patternmatcher` is NOT always Goroutine-safe, so this is not a singleton; we create an instance for each watcher currently.
func LoadDockerIgnore ¶
func LoadDockerIgnore(build *types.BuildConfig) (PathMatcher, error)
func NewCompositeMatcher ¶
func NewCompositeMatcher(matchers ...PathMatcher) PathMatcher
type TempDir ¶
type TempDir struct {
// contains filtered or unexported fields
}
TempDir holds a temp directory and allows easy access to new temp directories.
func NewDir ¶
NewDir creates a new TempDir in the default location (typically $TMPDIR)
func NewDirAtRoot ¶
NewDirAtRoot creates a new TempDir at the given root.
func NewDirAtSlashTmp ¶
NewDirAtSlashTmp creates a new TempDir at /tmp
func (*TempDir) NewDeterministicDir ¶
func (*TempDir) NewDir ¶
d.NewDir creates a new TempDir under d
func (*TempDir) Path ¶
func (*TempDir) TearDown ¶
type TempDirFixture ¶
type TempDirFixture struct {
// contains filtered or unexported fields
}
func NewTempDirFixture ¶
func NewTempDirFixture(t testing.TB) *TempDirFixture
func (*TempDirFixture) Chdir ¶
func (f *TempDirFixture) Chdir()
func (*TempDirFixture) CopyFile ¶
func (f *TempDirFixture) CopyFile(originalPath, newPath string)
Returns the full path to the file written.
func (*TempDirFixture) JoinPath ¶
func (f *TempDirFixture) JoinPath(path ...string) string
func (*TempDirFixture) JoinPaths ¶
func (f *TempDirFixture) JoinPaths(paths []string) []string
func (*TempDirFixture) MkdirAll ¶
func (f *TempDirFixture) MkdirAll(path string)
func (*TempDirFixture) NewFile ¶
func (f *TempDirFixture) NewFile(prefix string) (*os.File, error)
func (*TempDirFixture) Path ¶
func (f *TempDirFixture) Path() string
func (*TempDirFixture) ReadFile ¶
func (f *TempDirFixture) ReadFile(path string) string
Read the file.
func (*TempDirFixture) Rm ¶
func (f *TempDirFixture) Rm(pathInRepo string)
func (*TempDirFixture) T ¶
func (f *TempDirFixture) T() testing.TB
func (*TempDirFixture) TempDir ¶
func (f *TempDirFixture) TempDir(prefix string) string
func (*TempDirFixture) TouchFiles ¶
func (f *TempDirFixture) TouchFiles(paths []string)
func (*TempDirFixture) WriteFile ¶
func (f *TempDirFixture) WriteFile(path string, contents string) string
Returns the full path to the file written.
func (*TempDirFixture) WriteSymlink ¶
func (f *TempDirFixture) WriteSymlink(linkContents, destPath string)
Source Files ¶
debounce.go dockerignore.go ephemeral.go notify.go paths.go temp.go temp_dir_fixture.go watcher_naive.go watcher_nonwin.go
- Version
- v2.35.1 (latest)
- Published
- Apr 17, 2025
- Platform
- linux/amd64
- Imports
- 23 packages
- Last checked
- 21 hours ago –
Tools for package owners.