watcher

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFileNodeWithTransactions

func CreateFileNodeWithTransactions(tbl [][]byte) (*filenode.FileNode, error)

func NewFSWatcher

func NewFSWatcher(fsPath string) (Watcher, *EventTransaction, error)

func NewPathWatcher

func NewPathWatcher(fsPath string) (*TreeWatcher, *EventTransaction, error)

func NewVirtualPathWatcher

func NewVirtualPathWatcher(virtualPath string, extra *filenode.ExtraPayload) (*VirtualTree, *EventTransaction, error)

func NewVirtualWatcher

func NewVirtualWatcher(fsPath string, extra *filenode.ExtraPayload) (Watcher, *EventTransaction, error)

func RestoreWatcherWithTransactions

func RestoreWatcherWithTransactions(tbl [][]byte, tw Watcher) error

Types

type EventTransaction

type EventTransaction struct {
	Name       string
	Type       event.Type
	UUID       string
	ParentUUID string
	Meta       filenode.MetaData
}

func (*EventTransaction) Decode

func (t *EventTransaction) Decode(b []byte) error

func (*EventTransaction) Encode

func (t *EventTransaction) Encode() ([]byte, error)

type TreeWatcher

type TreeWatcher struct {
	FileTree   *filenode.FileNode
	Watcher    *fsnotify.Watcher
	Path       connector.Path
	ParentPath connector.Path

	Events chan *EventTransaction
	Errors chan error

	sync.Mutex
	EventManager event.EventHandler
}

func (*TreeWatcher) Create

func (tw *TreeWatcher) Create(path connector.Path, extra *filenode.ExtraPayload) (*filenode.FileNode, error)

func (*TreeWatcher) GetErrors

func (tw *TreeWatcher) GetErrors() <-chan error

func (*TreeWatcher) GetEvents

func (tw *TreeWatcher) GetEvents() <-chan *EventTransaction

func (*TreeWatcher) Handler

func (tw *TreeWatcher) Handler(e event.Event, extras ...*filenode.ExtraPayload) (*EventTransaction, error)

Handler the 'extras' parameter is optional because we may need to move an external value to the node layer. sample; We want to parameterize the uuid from outside in VFS, but we don't want to do that in FS.

func (*TreeWatcher) Move

func (tw *TreeWatcher) Move(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)

func (*TreeWatcher) PrintTree

func (tw *TreeWatcher) PrintTree(label string)

func (*TreeWatcher) Remove

func (tw *TreeWatcher) Remove(path connector.Path) (*filenode.FileNode, error)

func (*TreeWatcher) Rename

func (tw *TreeWatcher) Rename(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)

func (*TreeWatcher) Restore

func (tw *TreeWatcher) Restore(tree *filenode.FileNode)

func (*TreeWatcher) SearchByPath

func (tw *TreeWatcher) SearchByPath(path string) *filenode.FileNode

func (*TreeWatcher) SearchByUUID

func (tw *TreeWatcher) SearchByUUID(uuid string) *filenode.FileNode

func (*TreeWatcher) Start

func (tw *TreeWatcher) Start()

func (*TreeWatcher) Stop

func (tw *TreeWatcher) Stop()

func (*TreeWatcher) Watch

func (tw *TreeWatcher) Watch()

func (*TreeWatcher) Write

func (tw *TreeWatcher) Write(path connector.Path) (*filenode.FileNode, error)

type VirtualTree

type VirtualTree struct {
	FileTree   *filenode.FileNode
	Path       connector.Path
	ParentPath connector.Path

	sync.Mutex
}

func (*VirtualTree) Create

func (tw *VirtualTree) Create(path connector.Path, extra *filenode.ExtraPayload) (*filenode.FileNode, error)

func (*VirtualTree) GetErrors

func (tw *VirtualTree) GetErrors() <-chan error

func (*VirtualTree) GetEvents

func (tw *VirtualTree) GetEvents() <-chan *EventTransaction

func (*VirtualTree) Handler

func (tw *VirtualTree) Handler(e event.Event, extras ...*filenode.ExtraPayload) (*EventTransaction, error)

func (*VirtualTree) Move

func (tw *VirtualTree) Move(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)

func (*VirtualTree) PrintTree

func (tw *VirtualTree) PrintTree(label string)

func (*VirtualTree) Remove

func (tw *VirtualTree) Remove(path connector.Path) (*filenode.FileNode, error)

func (*VirtualTree) Rename

func (tw *VirtualTree) Rename(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)

func (*VirtualTree) Restore

func (tw *VirtualTree) Restore(tree *filenode.FileNode)

func (*VirtualTree) SearchByPath

func (tw *VirtualTree) SearchByPath(path string) *filenode.FileNode

func (*VirtualTree) SearchByUUID

func (tw *VirtualTree) SearchByUUID(uuid string) *filenode.FileNode

func (*VirtualTree) Start

func (tw *VirtualTree) Start()

func (*VirtualTree) Stop

func (tw *VirtualTree) Stop()

func (*VirtualTree) Watch

func (tw *VirtualTree) Watch()

func (*VirtualTree) Write

func (tw *VirtualTree) Write(path connector.Path) (*filenode.FileNode, error)

type Watcher

type Watcher interface {
	Stop()
	Start()
	Watch()
	PrintTree(label string) // for debug
	GetErrors() <-chan error
	GetEvents() <-chan *EventTransaction
	Restore(tree *filenode.FileNode)
	SearchByPath(path string) *filenode.FileNode
	SearchByUUID(uuid string) *filenode.FileNode
	Handler(event event.Event, extra ...*filenode.ExtraPayload) (*EventTransaction, error)
	Create(fromPath connector.Path, extra *filenode.ExtraPayload) (*filenode.FileNode, error)
	Write(fromPath connector.Path) (*filenode.FileNode, error)
	Remove(fromPath connector.Path) (*filenode.FileNode, error)
	Move(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)
	Rename(fromPath connector.Path, toPath connector.Path) (*filenode.FileNode, error)
}

Jump to

Keyboard shortcuts

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