fstask

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

fstask

Installation

Run the following command under your project:

go get -u github.com/NICEXAI/fstask

Basic Usage

If I want to listen for changes to the settings.yaml file and perform a response, you can:

	fsTask, err := fstask.New("./example/config")
	if err != nil {
		log.Println(err)
		return
	}
	defer fsTask.Close()

	fsTask.Add(fstask.Task{
		Rule:   ".*settings.yaml",
		Action: []string{"write"},
		Handle: func(event fsnotify.Event) {
			log.Println(event.Name, "config file change")
		},
	})

	fsTask.Wait()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debounce

func Debounce(key string, fn func(), delay time.Duration)

Debounce prevents jitter and ensures that it is executed only once in a given period of time

func Include

func Include(name string, list []string) bool

Include Is in the array

func MD5

func MD5(data []byte) string

MD5 encryption

Types

type FsTask

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

FsTask document task instance

func New

func New(name string) (*FsTask, error)

New initialize FsTask

func (*FsTask) Add

func (f *FsTask) Add(task Task) error

func (*FsTask) Close

func (f *FsTask) Close() error

func (*FsTask) Wait

func (f *FsTask) Wait()

type Task

type Task struct {
	Folder string   // folder
	Rule   string   // rule
	Action []string // fire action: create、 write、 rename、remove、chmod
	Handle func(event fsnotify.Event)
}

Task document task

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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