config

package
v3.65.6 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package config defines the full configuration structure used by the Benthos service, including methods of normalising and linting user configuration.

Index

Constants

This section is empty.

Variables

View Source
var ErrExceededRefLimit = errors.New("exceeded limit of nested references")

ErrExceededRefLimit is returned when a configuration hierarchy results in nested references beyond a hard coded limit. This is intended to prevent looped references from blocking the service.

View Source
var TestsField = docs.FieldCommon("tests", "Optional unit tests for the config, to be run with the `benthos test` subcommand.").Array().HasType(docs.FieldTypeUnknown).HasDefault([]interface{}{})

TestsField describes the optional test definitions field at the root of a benthos config.

Functions

func AddExamples

func AddExamples(conf *Type, examples ...string)

AddExamples takes a configuration struct and a variant list of type names to add to it and injects those types appropriately.

For example, your variant arguments could be "kafka" and "amqp", which case this function will create a configuration that reads from Kafka and writes over AMQP.

func JSONPointer

func JSONPointer(path string, object interface{}) (interface{}, error)

JSONPointer parses a JSON pointer path (https://tools.ietf.org/html/rfc6901) and either returns an interface{} containing the result or an error if the referenced item could not be found.

func Lint

func Lint(rawBytes []byte, _ Type) ([]string, error)

Lint attempts to report errors within a user config. Returns a slice of lint results.

TODO: V4 remove this

func LintV2

func LintV2(ctx docs.LintContext, rawBytes []byte) ([]string, error)

LintV2 attempts to report errors within a user config. Returns a slice of lint results.

func Read

func Read(path string, replaceEnvs bool, config *Type) ([]string, error)

Read will attempt to read a configuration file path into a structure. Returns an array of lint messages or an error.

TODO: V4 Remove this and force everything through internal/config

func ReadV2

func ReadV2(path string, replaceEnvs, rejectDeprecated bool, config *Type) ([]string, error)

ReadV2 will attempt to read a configuration file path into a structure. Returns an array of lint messages or an error.

TODO: V4 Remove this and force everything through internal/config

func ReadWithJSONPointers

func ReadWithJSONPointers(path string, replaceEnvs bool) ([]byte, error)

ReadWithJSONPointers takes a config file path, reads the contents, performs a generic parse, resolves any JSON Pointers, marshals the result back into bytes and returns it so that it can be unmarshalled into a typed structure.

func ReadWithJSONPointersLinted

func ReadWithJSONPointersLinted(path string, replaceEnvs bool) (configBytes []byte, lints []string, err error)

ReadWithJSONPointersLinted takes a config file path, reads the contents, performs a generic parse, resolves any JSON Pointers, marshals the result back into bytes and returns it so that it can be unmarshalled into a typed structure.

If any non-fatal errors occur lints are returned along with the result.

func Spec

func Spec() docs.FieldSpecs

Spec returns a docs.FieldSpec for an entire Benthos configuration.

func SpecWithoutStream

func SpecWithoutStream() docs.FieldSpecs

SpecWithoutStream describes a stream config without the core stream fields.

Types

type SanitisedConfig

type SanitisedConfig struct {
	HTTP               interface{} `json:"http" yaml:"http"`
	Input              interface{} `json:"input" yaml:"input"`
	Buffer             interface{} `json:"buffer" yaml:"buffer"`
	Pipeline           interface{} `json:"pipeline" yaml:"pipeline"`
	Output             interface{} `json:"output" yaml:"output"`
	Manager            interface{} `json:"resources" yaml:"resources"`
	Logger             interface{} `json:"logger" yaml:"logger"`
	Metrics            interface{} `json:"metrics" yaml:"metrics"`
	Tracer             interface{} `json:"tracer" yaml:"tracer"`
	SystemCloseTimeout interface{} `json:"shutdown_timeout" yaml:"shutdown_timeout"`
	Tests              interface{} `json:"tests,omitempty" yaml:"tests,omitempty"`
}

SanitisedConfig is deprecated and will be removed in V4.

TODO: V4 Remove this

type SanitisedV2Config

type SanitisedV2Config struct {
	RemoveTypeField        bool
	RemoveDeprecatedFields bool
}

SanitisedV2Config describes custom options for how a config is sanitised using the V2 API.

type Type

type Type struct {
	HTTP                   api.Config `json:"http" yaml:"http"`
	stream.Config          `json:",inline" yaml:",inline"`
	manager.ResourceConfig `json:",inline" yaml:",inline"`
	Logger                 log.Config     `json:"logger" yaml:"logger"`
	Metrics                metrics.Config `json:"metrics" yaml:"metrics"`
	Tracer                 tracer.Config  `json:"tracer" yaml:"tracer"`
	SystemCloseTimeout     string         `json:"shutdown_timeout" yaml:"shutdown_timeout"`
	Tests                  []interface{}  `json:"tests,omitempty" yaml:"tests,omitempty"`
}

Type is the Benthos service configuration struct.

func New

func New() Type

New returns a new configuration with default values.

func (Type) Sanitised

func (c Type) Sanitised() (*SanitisedConfig, error)

Sanitised is deprecated and will be removed in V4.

TODO: V4 Remove this

func (Type) SanitisedNoDeprecated

func (c Type) SanitisedNoDeprecated() (*SanitisedConfig, error)

SanitisedNoDeprecated is deprecated and will be removed in V4.

TODO: V4 Remove this

func (Type) SanitisedV2

func (c Type) SanitisedV2(conf SanitisedV2Config) (yaml.Node, error)

SanitisedV2 returns a sanitised version of the config as a yaml.Node.

Jump to

Keyboard shortcuts

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