output

package
v0.0.0-...-a0a3655 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package output contains interfaces and implementations for Butler Outputs, which are responsible for delivering Butler protobufs to LogDog collection endpoints.

Output instance implementations must be goroutine-safe. The Butler may elect to output multiple messages at the same time.

The package current provides the following implementations:

  • pubsub: Write logs to Google Cloud Pub/Sub.
  • log: (Debug/testing) data is dumped to the installed Logger instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntryRecord

type EntryRecord struct {
	// Streams is a map of a given stream to its record.
	Streams map[types.StreamPath]*StreamEntryRecord
}

EntryRecord is a record of which log entries have been sent for a given stream.

type EntryTracker

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

EntryTracker tracks individual which log entries have been sent for any given log entry stream.

func (*EntryTracker) Record

func (o *EntryTracker) Record() *EntryRecord

Record exports a snapshot of the current tracking state.

func (*EntryTracker) Track

func (o *EntryTracker) Track(b *logpb.ButlerLogBundle)

Track adds the log entries contained in the supplied bundle to the record.

type Output

type Output interface {
	// SendBundle sends a constructed ButlerLogBundle through the Output.
	//
	// If an error is returned, it indicates a failure to send the bundle.
	// If there is a data error or a message type is not supported by the
	// Output, it should log the error and return nil.
	SendBundle(*logpb.ButlerLogBundle) error

	// MaxSize returns the maximum number of bytes that this Output can process
	// with a single send. A return value <=0 indicates that there is no fixed
	// maximum size for this Output.
	//
	// Since it is impossible for callers to know the actual size of the message
	// that is being submitted, and since message batching may cluster across
	// size boundaries, this should be a conservative estimate.
	MaxSize() int

	// Collect current Output stats.
	Stats() Stats

	// Record returns the detailed stream record for an Output. This may return
	// nil if the Output is not configured to keep a stream record.
	Record() *EntryRecord

	// Close closes the Output, blocking until any buffered actions are flushed.
	Close()
}

Output is a sink endpoint for groups of messages.

An Output's methods must be goroutine-safe.

Note that there is no guarantee that any of the bundles passed through an Output are ordered.

type Range

type Range struct {
	Start uint64
	End   uint64
}

Range marks an inclusive log entry index range [Start-End].

func (*Range) String

func (sr *Range) String() string

type Stats

type Stats interface {
	fmt.Stringer

	// SentBytes returns the number of bytes
	SentBytes() int64
	// SentMessages returns the number of successfully transmitted messages.
	SentMessages() int64
	// DiscardedMessages returns the number of discarded messages.
	DiscardedMessages() int64
	// Errors returns the number of errors encountered during operation.
	Errors() int64
}

Stats is an interface to query Output statistics.

An Output's ability to keep statistics varies with its implementation details. Currently, Stats are for debugging/information purposes only.

type StatsBase

type StatsBase struct {
	F struct {
		SentBytes         int64 // The number of bytes sent.
		SentMessages      int64 // The number of messages sent.
		DiscardedMessages int64 // The number of messages that have been discarded.
		Errors            int64 // The number of errors encountered.
	}
}

StatsBase is a simple implementation of the Stats interface.

func (*StatsBase) DiscardedMessages

func (s *StatsBase) DiscardedMessages() int64

DiscardedMessages implements Stats.

func (*StatsBase) Errors

func (s *StatsBase) Errors() int64

Errors implements Stats.

func (*StatsBase) Merge

func (s *StatsBase) Merge(o Stats)

Merge merges the values from one Stats block into another.

func (*StatsBase) SentBytes

func (s *StatsBase) SentBytes() int64

SentBytes implements Stats.

func (*StatsBase) SentMessages

func (s *StatsBase) SentMessages() int64

SentMessages implements Stats.

func (*StatsBase) String

func (s *StatsBase) String() string

type StreamEntryRecord

type StreamEntryRecord struct {
	// Ranges is the sorted set of Range observed for this stream.
	Ranges []Range
}

StreamEntryRecord tracks an individual range of indices from the same stream.

Directories

Path Synopsis
Package log implements the "log" Output.
Package log implements the "log" Output.
Package pubsub implements the "pubsub" Output.
Package pubsub implements the "pubsub" Output.

Jump to

Keyboard shortcuts

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