podstream

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stream

func Stream(
	stop <-chan struct{},
	podsClient typedcorev1.PodInterface,
	options ...Option,
) error

Stream starts the pod stream. It stops when the stop channel returned, or any terminal error occurs, or all pods logs have been consumed in non-follow mode.

The implemenetation is based on https://github.com/argoproj/argo-workflows/blob/8c77e89fc185ff640e1073692dfc7c043037440a/util/logs/workflow-logger.go .

Types

type LogEntry

type LogEntry struct {
	// Time is the log time.
	Time time.Time `json:"time"`
	// Log is the log message.
	Log string `json:"log"`
}

LogEntry represents a single log entry.

type LogEntryConsumer

type LogEntryConsumer interface {
	// OnLogs is called when new logs are available.
	OnLogs(logs []LogEntry)
}

LogEntryConsumer consumes log entries.

type LogEntryConsumerFunc

type LogEntryConsumerFunc func(logs []LogEntry)

LogEntryConsumerFunc is a function that consumes log entries.

func (LogEntryConsumerFunc) OnLogs

func (f LogEntryConsumerFunc) OnLogs(logs []LogEntry)

type LogEntryConsumers

type LogEntryConsumers []LogEntryConsumer

LogEntryConsumers combines a group of LogEntryConsumer. Each consumer is called one by one with with the slice order.

func (LogEntryConsumers) OnLogs

func (s LogEntryConsumers) OnLogs(logs []LogEntry)

type LogFilter

type LogFilter interface {
	// FilterLog returns true if the log line should be consumed.
	FilterLog(log string) bool
}

LogFilter filters log line.

type LogFilterFunc

type LogFilterFunc func(log string) bool

LogFilterFunc is a LogFilter that implements the FilterLog method.

func (LogFilterFunc) FilterLog

func (f LogFilterFunc) FilterLog(log string) bool

type Option

type Option func(streamer *Streamer) error

Option specifies options for configuring the podstream reader.

func ConsumeLogsWith

func ConsumeLogsWith(first LogEntryConsumer, other ...LogEntryConsumer) Option

ConsumeLogsWithFunc sets the log consumer to use.

func ConsumeLogsWithFunc

func ConsumeLogsWithFunc(first LogEntryConsumerFunc) Option

ConsumeLogsWithFunc sets the log consumer to use with function.

func FilterWithRegex

func FilterWithRegex(expr string) Option

FilterWithRegex filters the logs with the given regex.

func FollowSelectedPods

func FollowSelectedPods(labelSelector string) Option

FollowSelectedPods sets the pod label selector and follow flag. It follows the log streamming until caller stops it.

func FromContainer

func FromContainer(containerName string) Option

FromContainer sets the container name to log from.

func FromSelectedPods

func FromSelectedPods(labelSelector string) Option

FromSelectedPods sets the label selector. It stops the streamer after all logs have been consumed.

func WithLogger

func WithLogger(logger kubekit.Logger) Option

WithLogger sets the logger to be used by the streamer.

type Streamer

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

Streamer streams pods logs.

Jump to

Keyboard shortcuts

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