runtime

package
v3.0.0-...-7ba4d6b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package runtime contains runtime hooks and utilities for pipeline options and type registration. Most functionality done in init and hence is available both during pipeline-submission and at runtime.

Index

Constants

This section is empty.

Variables

View Source
var GlobalOptions = NewOptions()

GlobalOptions are the global options for the active graph. Options can be defined at any time before execution and are re-created by the harness on remote execution workers. Global options should be used sparingly.

Functions

func Init

func Init()

Init is the hook that all user code must call after flags processing and other static initialization, for now.

func Initialized

func Initialized() bool

Initialized exposes the initialization status for runners.

func LookupType

func LookupType(key string) (reflect.Type, bool)

LookupType looks up a type in the global type registry by external key.

func RegisterFunction

func RegisterFunction(fn any)

RegisterFunction allows function registration. It is beneficial for performance and is needed for functions -- such as custom coders -- serialized during unit tests, where the underlying symbol table is not available. It should be called in `init()` only.

func RegisterInit

func RegisterInit(hook func())

RegisterInit registers an Init hook. Hooks are expected to be able to figure out whether they apply on their own, notably if invoked in a remote execution environment. They are all executed regardless of the runner.

func RegisterType

func RegisterType(t reflect.Type) string

RegisterType inserts "external" types into a global type registry to bypass serialization and preserve full method information. It should be called in init() only. Returns the external key for the type.

func ResolveFunction

func ResolveFunction(name string, t reflect.Type) (any, error)

ResolveFunction resolves the runtime value of a given function by symbol name and type.

func TypeKey

func TypeKey(t reflect.Type) (string, bool)

TypeKey returns the external key of a given type. Returns false if not a candidate for registration.

Types

type Options

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

Options are untyped options.

func NewOptions

func NewOptions() *Options

NewOptions provides an initialized set of options. It is only intended for framework and test use.

func (*Options) Export

func (o *Options) Export() RawOptions

Export returns a JSON-serializable copy of the options.

func (*Options) Get

func (o *Options) Get(key string) string

Get returns the value of the key. If the key has not been set, it returns "".

func (*Options) Import

func (o *Options) Import(opt RawOptions)

Import imports the options from previously exported data and makes the options read-only. It panics if import is called twice.

func (*Options) LoadOptionsFromFlags

func (o *Options) LoadOptionsFromFlags(excludeFlags map[string]bool)

LoadOptionsFromFlags adds any flags not defined in excludeFlags to the options. If the key is already defined, it ignores that flag.

func (*Options) Set

func (o *Options) Set(key, value string)

Set defines the value of the given key. If the key is already defined, it panics.

type RawOptions

type RawOptions struct {
	Options map[string]string `json:"options"`
}

RawOptions represents exported options as JSON-serializable data. Exact representation is subject to change.

type RawOptionsWrapper

type RawOptionsWrapper struct {
	Options      RawOptions `json:"beam:option:go_options:v1"`
	Runner       string     `json:"beam:option:runner:v1"`
	AppName      string     `json:"beam:option:app_name:v1"`
	Experiments  []string   `json:"beam:option:experiments:v1"`
	RetainDocker bool       `json:"beam:option:retain_docker_containers:v1"`
	Parallelism  int        `json:"beam:option:parallelism:v1"`
}

RawOptionsWrapper wraps RawOptions to the form expected by the harness. The extra layer is currently needed due to Dataflow expectations about this representation. Subject to change.

type SymbolResolver

type SymbolResolver interface {
	// Sym2Addr returns the address pointer for a given symbol.
	Sym2Addr(string) (uintptr, error)
}

SymbolResolver resolves a symbol to an unsafe address.

var (
	// Resolver is the accessible symbol resolver the runtime uses to find functions.
	Resolver SymbolResolver
)

Directories

Path Synopsis
Package coderx contains coders for primitive types that aren't included in the beam model.
Package coderx contains coders for primitive types that aren't included in the beam model.
Package contextreg contains the global registrations of functions for extracting ptransform annotations or environment resource hints from context.Context attached to scopes.
Package contextreg contains the global registrations of functions for extracting ptransform annotations or environment resource hints from context.Context attached to scopes.
Package exec contains runtime plan representation and execution.
Package exec contains runtime plan representation and execution.
optimized
Package optimized contains type-specialized shims for faster execution.
Package optimized contains type-specialized shims for faster execution.
Package genx is a convenience package to better support the code generator.
Package genx is a convenience package to better support the code generator.
Package graphx provides facilities to help with the serialization of pipelines into a serializable graph structure suitable for the worker.
Package graphx provides facilities to help with the serialization of pipelines into a serializable graph structure suitable for the worker.
schema
Package schema contains utility functions for relating Go types and Beam Schemas.
Package schema contains utility functions for relating Go types and Beam Schemas.
v1
Package harness implements the SDK side of the Beam FnAPI.
Package harness implements the SDK side of the Beam FnAPI.
init
Package init contains the harness initialization code defined by the FnAPI.
Package init contains the harness initialization code defined by the FnAPI.
statecache
Package statecache implements the state caching feature described by the Beam Fn API
Package statecache implements the state caching feature described by the Beam Fn API
Package pipelinex contains utilities for manipulating Beam proto pipelines.
Package pipelinex contains utilities for manipulating Beam proto pipelines.
Package xlangx contains various low-level utilities needed for adding cross-language transforms to the pipeline.
Package xlangx contains various low-level utilities needed for adding cross-language transforms to the pipeline.
expansionx
Package expansionx contains utilities for starting expansion services for cross-language transforms.
Package expansionx contains utilities for starting expansion services for cross-language transforms.

Jump to

Keyboard shortcuts

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