filedetector

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector int

Detector is used to specify how changes to the file should be detected.

const (
	// DetectorInvalid indicates an invalid UpdateType.
	DetectorInvalid Detector = iota
	// DetectorFSNotify uses filesystem events to wait for changes to the file.
	DetectorFSNotify
	// DetectorPoll will re-read the file on an interval to detect changes.
	DetectorPoll

	// DetectorDefault holds the default UpdateType.
	DetectorDefault = DetectorFSNotify
)

func (Detector) MarshalText

func (ut Detector) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (Detector) String

func (ut Detector) String() string

String returns the string representation of the UpdateType.

func (*Detector) UnmarshalText

func (ut *Detector) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type FSNotify

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

func NewFSNotify

func NewFSNotify(opts FSNotifyOptions) (*FSNotify, error)

newFSNotify creates a new fsnotify detector which uses filesystem events to detect that a file has changed.

func (*FSNotify) Close

func (fsn *FSNotify) Close() error

type FSNotifyOptions

type FSNotifyOptions struct {
	Logger        log.Logger
	Filename      string
	ReloadFile    func()        // Callback to request file reload.
	PollFrequency time.Duration // How often to do fallback polling
}

type Poller

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

func NewPoller

func NewPoller(opts PollerOptions) *Poller

newPoller creates a new poll-based file update detector.

func (*Poller) Close

func (p *Poller) Close() error

Close terminates the poller.

type PollerOptions

type PollerOptions struct {
	Filename      string
	ReloadFile    func() // Callback to request file reload.
	PollFrequency time.Duration
}

Jump to

Keyboard shortcuts

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