package tools
import "github.com/apache/beam/sdks/v2/go/container/tools"
Package tools contains utilities for Beam bootloader containers, such as for obtaining runtime provision information -- such as pipeline options. or for logging to the log service.
For Beam Internal use.
Index ¶
- func JSONToProto(data string) (*google_pb.Struct, error)
- func MakePipelineOptionsFileAndEnvVar(options string) error
- func OptionsToProto(v any) (*google_pb.Struct, error)
- func ProtoToJSON(opt *google_pb.Struct) (string, error)
- func ProtoToOptions(opt *google_pb.Struct, v any) error
- func ProvisionInfo(ctx context.Context, endpoint string) (*fnpb.ProvisionInfo, error)
- type BufferedLogger
- func NewBufferedLogger(logger *Logger) *BufferedLogger
- func NewBufferedLoggerWithFlushInterval(ctx context.Context, logger *Logger, interval time.Duration) *BufferedLogger
- func (b *BufferedLogger) FlushAtDebug(ctx context.Context)
- func (b *BufferedLogger) FlushAtError(ctx context.Context)
- func (b *BufferedLogger) Printf(ctx context.Context, format string, args ...any)
- func (b *BufferedLogger) Write(p []byte) (int, error)
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Errorf(ctx context.Context, format string, args ...any)
- func (l *Logger) Fatalf(ctx context.Context, format string, args ...any)
- func (l *Logger) Log(ctx context.Context, sev fnpb.LogEntry_Severity_Enum, message string)
- func (l *Logger) Printf(ctx context.Context, format string, args ...any)
- func (l *Logger) Warnf(ctx context.Context, format string, args ...any)
Functions ¶
func JSONToProto ¶
JSONToProto converts JSON-encoded pipeline options to a proto struct.
func MakePipelineOptionsFileAndEnvVar ¶
MakePipelineOptionsFileAndEnvVar writes the pipeline options to a file. Assumes the options string is JSON formatted.
Stores the file name in question in PIPELINE_OPTIONS_FILE for access by the SDK.
func OptionsToProto ¶
OptionsToProto converts pipeline options to a proto struct via JSON.
func ProtoToJSON ¶
ProtoToJSON converts pipeline options from a proto struct to JSON.
func ProtoToOptions ¶
ProtoToOptions converts pipeline options from a proto struct via JSON.
func ProvisionInfo ¶
ProvisionInfo returns the runtime provisioning info for the worker.
Types ¶
type BufferedLogger ¶
type BufferedLogger struct {
// contains filtered or unexported fields
}
BufferedLogger is a wrapper around the FnAPI logging client meant to be used in place of stdout and stderr in bootloader subprocesses. Not intended for Beam end users.
func NewBufferedLogger ¶
func NewBufferedLogger(logger *Logger) *BufferedLogger
NewBufferedLogger returns a new BufferedLogger type by reference.
func NewBufferedLoggerWithFlushInterval ¶
func NewBufferedLoggerWithFlushInterval(ctx context.Context, logger *Logger, interval time.Duration) *BufferedLogger
NewBufferedLoggerWithFlushInterval returns a new BufferedLogger type by reference. This type will flush logs periodically on Write() calls as well as when Flush*() functions are called.
func (*BufferedLogger) FlushAtDebug ¶
func (b *BufferedLogger) FlushAtDebug(ctx context.Context)
FlushAtDebug flushes the contents of the buffer to the logging service at Debug.
func (*BufferedLogger) FlushAtError ¶
func (b *BufferedLogger) FlushAtError(ctx context.Context)
FlushAtError flushes the contents of the buffer to the logging service at Error.
func (*BufferedLogger) Printf ¶
func (b *BufferedLogger) Printf(ctx context.Context, format string, args ...any)
Prints directly to the logging service. If the logger is nil, prints directly to the console. Used for the container pre-build workflow.
func (*BufferedLogger) Write ¶
func (b *BufferedLogger) Write(p []byte) (int, error)
Write implements the io.Writer interface, converting input to a string and storing it in the BufferedLogger's buffer. If a logger is not provided, the output is sent directly to os.Stderr.
type Logger ¶
type Logger struct { Endpoint string // contains filtered or unexported fields }
Logger is a wrapper around the FnAPI Logging Client, intended for container boot loader use. Not intended for Beam end users.
func (*Logger) Close ¶
func (l *Logger) Close()
Close closes the grpc logging client.
func (*Logger) Errorf ¶
Errorf logs the message with Error severity.
func (*Logger) Fatalf ¶
Fatalf logs the message with Critical severity, and then calls os.Exit(1).
func (*Logger) Log ¶
Log a message with the given severity.
func (*Logger) Printf ¶
Printf logs the message with Debug severity.
func (*Logger) Warnf ¶
Warnf logs the message with Warning severity.
Source Files ¶
buffered_logging.go logging.go pipeline_options.go provision.go
- Version
- v2.65.0 (latest)
- Published
- May 6, 2025
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 2 days ago –
Tools for package owners.