fwatcher

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 16 Imported by: 0

README

fwatcher

file watcher with DI

Documentation

Index

Constants

View Source
const (
	KeyExcelFolder = "path"
)

Variables

View Source
var ErrorShouldRetry = errors.New("process failed but should retry")
View Source
var FileWatcheSettingKey = "files"

Functions

func FileExisted

func FileExisted(file string) bool

Types

type FileAction

type FileAction interface {
	HandleFile(file string) error
}

type FileIdempotent

type FileIdempotent struct {
	gorm.Model
	FileName string `gorm:"size:64"`
	FileKey  string `gorm:"size:64;unique"`
}

type FileIdempotentService

type FileIdempotentService struct {
	Logger *zap.Logger
	Key    string
	DB     *gorm.DB
}

func (*FileIdempotentService) Idempotent

func (fs *FileIdempotentService) Idempotent(file string) (bool, error)

type FileWatcherParams

type FileWatcherParams struct {
	dig.In
	Ctx        context.Context
	Logger     *zap.Logger
	Action     FileAction
	Idempotent *FileIdempotentService `optional:"true"`
}

type FilelWatcher

type FilelWatcher struct {
	Logger        *zap.Logger
	Action        FileAction
	Recursive     bool
	Path          string
	Interval      time.Duration
	Included      []string
	Excluded      []string
	RetryDelay    time.Duration
	RetryAttempts uint
	Delete        bool
	DoneFolder    string
	ErrorFolder   string
	ShouldRetry   retry.RetryIfFunc
	Idempotent    *FileIdempotentService
}

FileWatcher, not support recursion & idempotent yet.

func (*FilelWatcher) Filter

func (e *FilelWatcher) Filter(file string) bool

func (*FilelWatcher) ScheduleWalk

func (e *FilelWatcher) ScheduleWalk(ctx context.Context)

func (*FilelWatcher) StartService

func (e *FilelWatcher) StartService(ctx context.Context)

func (*FilelWatcher) StartWatcher

func (e *FilelWatcher) StartWatcher(ctx context.Context) error

func (*FilelWatcher) Walk

func (e *FilelWatcher) Walk()

Jump to

Keyboard shortcuts

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