log

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBufferSize is the default buffer size. This based on the recommended
	// gRPC message size for streamed content, which ranges from 16 to 64 KiB. Choosing 32 KiB as a
	// middle ground between the two.
	DefaultBufferSize = 32 * 1024
)

Variables

View Source
var (
	// NameRegex matches valid name specs for a Result.
	NameRegex = regexp.MustCompile("(^[a-z0-9_-]{1,63})/results/([a-z0-9_-]{1,63})/logs/([a-z0-9_-]{1,63}$)")
)

Functions

func FilePath

func FilePath(log *v1alpha2.Log) (string, error)

FilePath returns file path to store log. This file path can be path in the real file system or virtual value depending on storage type.

func FormatName

func FormatName(parent, name string) string

FormatName takes in a parent ("a/results/b") and record name ("c") and returns the full resource name ("a/results/b/logs/c").

func ParseName

func ParseName(raw string) (parent, result, name string, err error)

ParseName splits a full Result name into its individual (parent, result, name) components.

func ToStorage

func ToStorage(record *pb.Record, config *config.Config) ([]byte, error)

ToStorage converts log record to marshaled json bytes

Types

type Stream

type Stream interface {
	io.ReaderFrom
	io.WriterTo
	Type() string
	Delete() error
	Flush() error
}

Stream is an interface that defines the behavior of a streaming log service.

func NewFileStream

func NewFileStream(ctx context.Context, log *v1alpha2.Log, config *config.Config) (Stream, error)

NewFileStream returns a LogStreamer that streams directly from a log file on local disk.

func NewGCSStream added in v0.8.0

func NewGCSStream(ctx context.Context, log *v1alpha2.Log, config *server.Config) (Stream, error)

NewGCSStream returns a log streamer for the GCS storage type.

func NewS3Stream

func NewS3Stream(ctx context.Context, log *v1alpha2.Log, config *server.Config) (Stream, error)

NewS3Stream returns a log streamer for the S3 log storage type.

func NewStream

func NewStream(ctx context.Context, log *v1alpha2.Log, config *config.Config) (Stream, error)

NewStream returns a LogStreamer for the given Log. LogStreamers do the following:

1. Write log data from their respective source to an io.Writer interface. 2. Read log data from a source, and store it in the respective backend if that behavior is supported.

All LogStreamers support writing log data to an io.Writer from the provided source. LogStreamers do not need to receive and store data from the provided source.

NewStream may mutate the Log object's status, to provide implementation information for reading and writing files.

func ToStream

func ToStream(ctx context.Context, record *db.Record, config *config.Config) (Stream, *v1alpha2.Log, error)

ToStream returns three arguments. First one is a new log streamer created by log record. Second one is log API resource retrieved from log record. Third argument is an error.

Jump to

Keyboard shortcuts

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