tail

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tail mimicks the behaviour of `tail -f`

tail watches an events file for writes and sends out matching events, one for each line written. It is careful to parse the data read in a separate goroutine, which helps assure all events are caught.

ev, _ := tail.WatchEvents(ctx, path.Dir(dir), path.Base(dir))
for event := range ev {
	fmt.Println(ev.Service, ev.Name)
	switch ev.EventType {
	case tail.FeedEvent:
		// [...]
	case tail.DocEvent:
		// [...]
	case tail.NotifyEvent:
		// [...]
	case tail.NoneEvent:
		// [...]
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WatchEvents

func WatchEvents(ctx context.Context, dir, service string) (chan *Event, error)

WatchEvents watches a given directory, returning a channel of all events written to the events file

Types

type Event

type Event struct {
	Service   string
	EventType EventType
	Name      string
}

Event represents a single event that occured on a service Such as new data to feed or a notification

type EventType

type EventType int

EventType indicites which type of file the event is for

const (
	FeedEvent EventType = iota
	NotifyEvent
	DocEvent
	NoneEvent
)

Available EventTypes - this will likely increase

Jump to

Keyboard shortcuts

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