operator

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package operator implements the generic operator: an instance pushes the module configs and functions its YAML config spells to every gateway.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadRequest

func LoadRequest(method string, path string, files *protoregistry.Files) (proto.Message, error)

LoadRequest reads a module config file, the method's request spelled in YAML, and decodes it against the descriptor set, or against the descriptors linked into this binary when files is nil.

func NewOperator

func NewOperator(cfg *Config, options ...Option) (operator.Runnable, error)

NewOperator builds an instance publishing module configs before functions.

Files are loaded at construction and polled when an interval is configured.

Types

type ChainConfig

type ChainConfig struct {
	// Name is the chain name (e.g. "default").
	Name xcfg.NonEmptyString `yaml:"name"`
	// Modules are the module configs packets traverse, in order.
	Modules []ModuleIdConfig `yaml:"modules"`
}

ChainConfig is an ordered module sequence.

type Config

type Config struct {
	// Name is the instance name. The operator reports readiness and metrics
	// under it, so it must match the name clients address.
	Name      xcfg.NonEmptyString       `yaml:"name"`
	Logging   logging.Config            `yaml:"logging"`
	Debug     debugserver.Config        `yaml:"debug"`
	Server    operator.GRPCServerConfig `yaml:"server"`
	Gateways  []operator.GatewayConfig  `yaml:"gateways"`
	Register  operator.RegisterConfig   `yaml:"register"`
	Reconcile operator.ReconcileConfig  `yaml:"reconcile"`
	// PollInterval paces module config file checks; zero disables polling.
	//
	// Descriptors, functions and the instance configuration stay fixed
	// until restart. A failed file reload preserves the previous snapshot.
	PollInterval time.Duration `yaml:"poll_interval"`
	// Configs are the module configs this instance pushes.
	Configs []ModuleConfig `yaml:"configs"`
	// Functions are the gateway functions published after the configs.
	Functions []FunctionConfig `yaml:"functions"`
}

Config is the top-level YAML configuration for one yanet-generic-operator instance.

The configs section spells the module configs the instance pushes, the functions section the gateway functions published after them.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config populated with sensible defaults.

func (*Config) DebugConfig added in v0.3.0

func (m *Config) DebugConfig() *debugserver.Config

DebugConfig exposes the debug server configuration to the common command lifecycle.

func (*Config) Default

func (m *Config) Default()

Default resets the config to built-in defaults.

func (*Config) LoggingConfig

func (m *Config) LoggingConfig() *logging.Config

LoggingConfig exposes the embedded logging configuration to the generic operator CLI helper.

func (*Config) Validate

func (m *Config) Validate() error

Validate checks that the config is structurally sound.

type FunctionChainConfig

type FunctionChainConfig struct {
	// Chain is the module sequence the weight applies to.
	Chain ChainConfig `yaml:"chain"`
	// Weight must be spelled explicitly, an explicit 0 disables the chain.
	Weight xcfg.Required[uint64] `yaml:"weight"`
}

FunctionChainConfig pairs a chain with its load-balancing weight.

type FunctionConfig

type FunctionConfig struct {
	// Name is the function identifier (e.g. "fn:decap").
	Name xcfg.NonEmptyString `yaml:"name"`
	// Chains are the function's weighted processing chains.
	Chains []FunctionChainConfig `yaml:"chains"`
	// IgnorePdump skips function updates when the existing chain already
	// matches once every pdump:* module is filtered out.
	//
	// Defaults to true when the field is omitted from the YAML input.
	IgnorePdump bool `yaml:"ignore_pdump"`
}

FunctionConfig is one gateway function this instance publishes after the configs.

func (*FunctionConfig) AsFunction

func (m *FunctionConfig) AsFunction() *ynpb.Function

AsFunction converts the spelled function to its proto form.

func (*FunctionConfig) UnmarshalYAML

func (m *FunctionConfig) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler so that IgnorePdump defaults to true when the field is absent from the YAML input.

type ModuleConfig

type ModuleConfig struct {
	// Name is the module config name.
	//
	// It is filled into the request when the file omits its own name, so a
	// payload file does not have to repeat it.
	Name xcfg.NonEmptyString `yaml:"name"`
	// Method is the unary gRPC method that replaces the module config,
	// spelled as "package.Service/Method".
	//
	// The reconcile loop repeats the call, so the method must replace
	// whole state, not accumulate it.
	Method xcfg.NonEmptyString `yaml:"method"`
	// File is the path to the module config file, the method's request in
	// YAML.
	File xcfg.NonEmptyString `yaml:"file"`
	// Descriptors is the path to the module's descriptor set, which the
	// module's package installs.
	//
	// When set, the method, its request and its reply are resolved from
	// the set, even for a module linked into this binary, so a module built
	// outside this tree is configured by the same binary. Empty resolves
	// them among the descriptors linked into this binary.
	Descriptors string `yaml:"descriptors"`
}

ModuleConfig describes one module config this instance pushes.

type ModuleIdConfig

type ModuleIdConfig struct {
	// Type is the module type (e.g. "decap").
	Type xcfg.NonEmptyString `yaml:"type"`
	// Name is the module config name (e.g. "decap0").
	Name xcfg.NonEmptyString `yaml:"name"`
}

ModuleIdConfig references one module config by type and name.

type Option

type Option func(*options)

Option configures NewOperator.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the logger for the Operator and all sub-components.

Jump to

Keyboard shortcuts

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