Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func TestEventSetup ¶ added in v1.0.0
TestEventSetup sets up a new event for testing purposes
func TestProducerConsumer ¶ added in v1.0.0
TestProducerConsumer returns a Producer/Consumer struct for testing
Types ¶
type Consumer ¶
type Consumer interface { // Receive an event from the producer Receive(path, event string) // Process an event Process(e *event.Event) // Process a dir event ProcessDirEvent(e *event.Event) }
Consumer interface Must implement Receive(), and Process() methods
type PathConsumer ¶
type PathConsumer struct { // Path to watch Path string // Destination to move files to Destination string // File extenstion Ext string // Regex Pattern Pattern regexp.Regexp }
PathConsumer is a consumer that consumes events from a path and moves them to a destination
func (*PathConsumer) Process ¶
func (pc *PathConsumer) Process(e *event.Event)
Process takes an event and moves it to the destination
func (*PathConsumer) ProcessDirEvent ¶
func (pc *PathConsumer) ProcessDirEvent(e *event.Event)
ProcessDirEvent takes an event and scans files ext
func (*PathConsumer) Receive ¶
func (pc *PathConsumer) Receive(path, ev string)
Receive takes a path and an event operation, determines its validity and passes it to be processed it if valid
type PathWatcher ¶
type PathWatcher struct { // List of consumers Consumers []*Consumer // Queue Queue *Q // Watcher instance Watcher fsnotify.Watcher // Path to watch Path string }
PathWatcher is a producer that watches a path for events
func TestPathWatcher ¶ added in v1.0.0
func TestPathWatcher() *PathWatcher
TestPathWatcher returns a test watcher
func (*PathWatcher) AddPath ¶
func (pw *PathWatcher) AddPath(path string)
AddPath adds a path to the watcher
func (*PathWatcher) Notify ¶ added in v0.2.1
func (pw *PathWatcher) Notify(path, event string)
Notify consumers of an event
func (*PathWatcher) Poll ¶ added in v0.2.1
func (pw *PathWatcher) Poll(interval int)
Poll polls the queue for valid events given an interval (in seconds)
func (*PathWatcher) Register ¶
func (pw *PathWatcher) Register(consumer *Consumer)
Register a consumer to the producer
func (*PathWatcher) Unregister ¶
func (pw *PathWatcher) Unregister(consumer *Consumer)
Unregister a consumer from the producer
type Producer ¶
type Producer interface { // Register a consumer to the producer Register(consumer *Consumer) // Unregister a consumer from the producer Unregister(consumer *Consumer) // Notify consumers of an event Notify(path, event string) // Observe the producer Observe(pollInterval int) }
Producer interface for the watcher Must implement Register(), Unregister(), and Observe(), and notify()
type Q ¶ added in v0.2.1
Q holds the Queue