disk_monitor

package
v0.0.0-...-f683eec Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallMonitorOptionsWatchDog

func InstallMonitorOptionsWatchDog(dog func(cc *MonitorOptions))

InstallMonitorOptionsWatchDog install watch dog

Types

type DiskMonitor

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

func NewMonitor

func NewMonitor(opt ...MonitorOption) *DiskMonitor

func (*DiskMonitor) Monitor

func (dm *DiskMonitor) Monitor(fileOrDir string) error

Monitor 监控文件或者目录变化

func (*DiskMonitor) Start

func (dm *DiskMonitor) Start() (err error)

func (*DiskMonitor) Stop

func (dm *DiskMonitor) Stop()

type DiskNotifier

type DiskNotifier interface {
	Prepare(logger *zaplog.Logger, fileName string)
	Change(logger *zaplog.Logger, fileName string, data []byte) error
	Finish(logger *zaplog.Logger, fileName string)
}

DiskNotifier 磁盘监控变动接口

func DiskNoitifierFunc

func DiskNoitifierFunc(prepare func(logger *zaplog.Logger, fileName string),
	change func(logger *zaplog.Logger, fileName string, data []byte) error,
	finish func(logger *zaplog.Logger, fileName string)) DiskNotifier

type DiskNotifierChangeFunc

type DiskNotifierChangeFunc func(logger *zaplog.Logger, fileName string, data []byte) error

DiskNotifierChangeFunc 监控文件变化函数

func (DiskNotifierChangeFunc) Change

func (df DiskNotifierChangeFunc) Change(logger *zaplog.Logger, fileName string, data []byte) error

func (DiskNotifierChangeFunc) Finish

func (DiskNotifierChangeFunc) Finish(logger *zaplog.Logger, fileName string)

func (DiskNotifierChangeFunc) Prepare

func (DiskNotifierChangeFunc) Prepare(logger *zaplog.Logger, fileName string)

type MonitorOption

type MonitorOption func(cc *MonitorOptions) MonitorOption

MonitorOption option define

func WithFileExt

func WithFileExt(v string) MonitorOption

file ext

func WithLogger

func WithLogger(v *zaplog.Logger) MonitorOption

log interface

func WithNotifier

func WithNotifier(v DiskNotifier) MonitorOption

monitor notify interface

func WithPaths

func WithPaths(v ...string) MonitorOption

monitor file or paths

func WithRetryInterval

func WithRetryInterval(v time.Duration) MonitorOption

retry interval

func WithRetryLimit

func WithRetryLimit(v int) MonitorOption

retry time limit, 0:disable retry

func WithStoper

func WithStoper(v app.Stoper) MonitorOption

app stopper

type MonitorOptions

type MonitorOptions struct {
	// log interface
	Logger *zaplog.Logger
	// file ext
	FileExt string
	// monitor file or paths
	Paths []string
	// retry time limit, 0:disable retry
	RetryLimit int
	// retry interval
	RetryInterval time.Duration
	// monitor notify interface
	Notifier DiskNotifier
	// app stopper
	Stoper app.Stoper
}

MonitorOption use for process

func NewMonitorOptions

func NewMonitorOptions(opts ...MonitorOption) *MonitorOptions

NewMonitorOptions create options instance.

func (*MonitorOptions) ApplyOption

func (cc *MonitorOptions) ApplyOption(opts ...MonitorOption)

ApplyOption modify options

func (*MonitorOptions) GetSetOption

func (cc *MonitorOptions) GetSetOption(opt MonitorOption) MonitorOption

GetSetOption modify and get last option

func (*MonitorOptions) SetOption

func (cc *MonitorOptions) SetOption(opt MonitorOption)

SetOption modify options

Jump to

Keyboard shortcuts

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