tailer

package
v0.0.0-...-192aea2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

publishes status of each app, reporting when the log tailer has matched it's pattern and the app is warmed up and ready to serve, or an error message if the tailer fails.

func NewPublisher

func NewPublisher() *Publisher

obtain a publisher

func (*Publisher) Add

func (p *Publisher) Add(key string, evt Status)

Update status for a particular registered app

func (*Publisher) GetAll

func (p *Publisher) GetAll() ([]byte, int)

Obtain serialized status update for all registered apps

func (*Publisher) GetStatuses

func (p *Publisher) GetStatuses(services []string) ([]byte, int)

Obtain serialized status update for a selection of registered services

type Status

type Status struct {
	Ready bool       `json:"ready"`
	At    *time.Time `json:"at,omitempty"`
	Error string     `json:"error"`
}

status reported for each app

type Tailer

type Tailer struct {
	Ctx          context.Context
	Name         string
	ID           string
	Since        time.Duration
	Patterns     []*regexp.Regexp
	AwaitStartup time.Duration
	AwaitReady   time.Duration

	Publisher *Publisher
	Client    *docker.Client
	Driver    *tail.Tail
	Reader    io.ReadCloser
	Writer    *os.File

	Logger *log.Logger
	Done   chan bool
}

performs the log monitoring and status publishing for one service container

func New

func New(ctx context.Context, client *docker.Client, pub *Publisher, containerName string, target config.Container, awaitStartup time.Duration) (*Tailer, error)

func (*Tailer) ProcessLine

func (t *Tailer) ProcessLine(line *tail.Line, lineCount int) bool

handle processing each log line, publish result if error or match occurs

func (*Tailer) Start

func (t *Tailer) Start()

caller should execute this in a goroutine

Jump to

Keyboard shortcuts

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