Documentation ¶
Overview ¶
Package notifications fixes the problem of multiple file change notifications for the same file from the OS API. With FileNotificationWaiter(chanA, chanB, data) you can send data to the chanB if nothing was send to the chanA for 5 seconds
The flow: - For each file create a channel and store it with RegisterFileNotification() - Call FileNotificationWaiter() as a go routin with the created channel and other needed data - On the next file change notification check if the channel for this file exists, if so send true to the channel - If nothing was send on the channel, FileNotificationWaiter() will send the data to the provided channel after 5 seconds
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType int
ActionType represents what happens with the file
const ( // Invalid action is 0 Invalid ActionType = iota // FileAdded - the file was added to the directory. FileAdded // 1 // FileRemoved - the file was removed from the directory. FileRemoved // 2 // FileModified - the file was modified. This can be a change in the time stamp or attributes. FileModified // 3 // FileRenamedOldName - the file was renamed and this is the old name. FileRenamedOldName // 4 // FileRenamedNewName - the file was renamed and this is the new name. FileRenamedNewName // 5 )
type Event ¶
type Event struct { Action ActionType MimeType string Machine string FileName string AbsolutePath string RelativePath string DirectoryPath string WatchDirectoryName string Size int64 Timestamp time.Time UUID uuid.UUID Checksum string }
Event ...
type Waiter ¶
Waiter ...
func (*Waiter) LookupForFileNotification ¶
LookupForFileNotification returns a channel for a given file path
func (*Waiter) RegisterFileNotification ¶
RegisterFileNotification channel for a given file path, use this channel for with FileNotificationWaiter() function
func (*Waiter) UnregisterFileNotification ¶
UnregisterFileNotification channel for a given file path