watcher

package
v0.0.0-...-fc9a6ea Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWatcherNotInitialized = errors.New("the watcher is not initialized")
)

Functions

This section is empty.

Types

type S3Watcher

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

func (*S3Watcher) Add

func (sw *S3Watcher) Add(bucketName, objectPath string) error

Add a path to the watcher which consists of a bucket and prefix (what the path must start with). The prefix should not start with a forward slash (/). The prefix does not have to exist in the bucket. Returns an error if the watcher is not initialized.

func (*S3Watcher) Close

func (sw *S3Watcher) Close()

Instructs the main loop to stop

func (*S3Watcher) ErrorChannel

func (sw *S3Watcher) ErrorChannel() (chan error, error)

Returns the watcher's error channel. Only returns an error if the watcher is not initialized

func (*S3Watcher) EventChannel

func (sw *S3Watcher) EventChannel() (chan string, error)

Returns the watcher's event channel. Only returns an error if the watcher is not initialized

func (*S3Watcher) New

func (sw *S3Watcher) New(options WatcherOptions) error

Initialize the watcher

func (*S3Watcher) Paths

func (sw *S3Watcher) Paths() []string

Returns the full path of objects monitored by the watcher. The full path is bucket/prefix. If the watcher is not initalized, an empty string slice is returned.

type S3WatcherOptions

type S3WatcherOptions struct {
	// The configured S3 client from the caller
	S3Client *s3.Client
	// The polling interval in seconds (must be greater than 0)
	PollTimeSeconds uint
}

type Watcher

type Watcher interface {
	// Set up a new instance of the Watcher
	New(WatcherOptions) error
	// Add a path (base path and object / file path) to watch, returns a nil error on success
	Add(string, string) error
	// Returns whether the watcher has been successfully initialized
	Initialized() bool
	// Return a slice of the paths that the watcher is monitoring
	Paths() []string
	// Return the event channel that sends a notification when an event has occurred
	// Returns an error if the Watcher has not been initialized
	EventChannel() (chan string, error)
	// Return the error channel that sends a notification when an error has occurred
	// Returns an error if the Watcher has not been initialized
	ErrorChannel() (chan error, error)
	// Performs any functions necessary to cleanly shutdown the watcher
	Close()
}

type WatcherOptions

type WatcherOptions interface{}

An empty interface for holding watcher options. These can be anything - it depends on the watcher.

Jump to

Keyboard shortcuts

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