watch

package
v0.58.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(root *cobra.Command)

Types

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

Uploader uploads local files to the target storage via a worker pool. If a file changes while being uploaded, it is re-uploaded once after the current upload finishes, instead of being queued multiple times.

func NewUploader

func NewUploader(ctx context.Context, opts UploaderOptions) *Uploader

NewUploader creates and starts an Uploader. The caller must call Close when done.

func (*Uploader) Close

func (u *Uploader) Close()

Close stops accepting jobs and waits for in-flight uploads to finish.

func (*Uploader) Submit

func (u *Uploader) Submit(ctx context.Context, job uploadJob) bool

Submit enqueues an upload job. If the same file is already in flight, it is marked for re-upload instead of being queued again. Returns false if ctx is cancelled before the job can be enqueued.

type UploaderOptions

type UploaderOptions struct {
	Storage    storage.Storage
	DestDir    string
	Overwrite  bool
	Workers    int
	Retry      int
	RetryDelay time.Duration
	QueueSize  int
}

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches a local directory and submits stable files to the Uploader.

Write-completion detection: fsnotify emits Write events throughout a write. Watcher debounces per file and only uploads once the file size stays unchanged across a debounce window, avoiding uploads of partial files.

func NewWatcher

func NewWatcher(ctx context.Context, opts WatcherOptions) (*Watcher, error)

NewWatcher creates a Watcher.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

Run starts watching and blocks until ctx is cancelled.

func (*Watcher) ScanExisting

func (w *Watcher) ScanExisting(ctx context.Context)

ScanExisting triggers a one-time scan and upload of existing files under the watch root.

type WatcherOptions

type WatcherOptions struct {
	Root      string
	Recursive bool
	Debounce  time.Duration
	Uploader  *Uploader
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL