luci-go: github.com/luci/luci-go/logdog/client/butler/output Index | Files | Directories

package output

import "github.com/luci/luci-go/logdog/client/butler/output"

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

Package Files

doc.go output.go

type Output Uses

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

    // MaxSendBundles is the number of concurrent calls to SendBundle allowed.
    //
    // If <= 0, only one SendBundle will be called at a time.
    MaxSendBundles() int

    // URLConstructionEnv should return a bootstrap.Environment containing
    // any fields necessary for clients to construct a URL pointing to where this
    // Output is sending its data.
    //
    // Returning an empty Environment means that clients will not be able to
    // construct URLs to this data (which may be accurate, depending on the
    // Output implementation).
    //
    // StreamServerURI is ignored and should not be specified.
    //
    // NOTE: This is an awful encapsulation violation. We should change the butler
    // protocol so that opening a new stream has the butler immediately reply with
    // the externally-visible URL to the stream and stop exporting these envvars
    // entirely.
    URLConstructionEnv() bootstrap.Environment

    // 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

    // 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 Stats Uses

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 Uses

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 Uses

func (s *StatsBase) DiscardedMessages() int64

DiscardedMessages implements Stats.

func (*StatsBase) Errors Uses

func (s *StatsBase) Errors() int64

Errors implements Stats.

func (*StatsBase) Merge Uses

func (s *StatsBase) Merge(o Stats)

Merge merges the values from one Stats block into another.

func (*StatsBase) SentBytes Uses

func (s *StatsBase) SentBytes() int64

SentBytes implements Stats.

func (*StatsBase) SentMessages Uses

func (s *StatsBase) SentMessages() int64

SentMessages implements Stats.

func (*StatsBase) String Uses

func (s *StatsBase) String() string

Directories

PathSynopsis
directory
logPackage log implements the "log" Output.
logdogPackage logdog implements output to a Logdog server via PubSub.
null

Package output imports 3 packages (graph). Updated 2019-10-18. Refresh now. Tools for package owners.