config

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 13 Imported by: 2

Documentation

Overview

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Package config implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const Type = "config"

Variables

View Source
var (
	DefaultBuilder = NewBuilder()
)
View Source
var (
	ErrInvalidConfigType = errors.New("invalid config type")
)
View Source
var (
	// ErrNotFound defined error from kratos config package
	ErrNotFound = kratosconfig.ErrNotFound
)

Functions

This section is empty.

Types

type BuildFunc added in v0.1.16

type BuildFunc func(*configv1.SourceConfig, *Options) (KSource, error)

BuildFunc is a function type that takes a KConfig and a list of Options and returns a Selector and an error.

func (BuildFunc) NewSource added in v0.2.0

func (fn BuildFunc) NewSource(cfg *configv1.SourceConfig, opts *Options) (KSource, error)

NewSource is a method that implements the ConfigBuilder interface for ConfigBuildFunc.

type Builder added in v0.1.16

type Builder interface {
	factory.Registry[Factory]
	NewConfig(*configv1.SourceConfig, ...Option) (KConfig, error)
}

Builder is an interface that defines a method for registering a config Builder.

func NewBuilder added in v0.1.16

func NewBuilder() Builder

type Encoder

type Encoder func(v any) ([]byte, error)

Encoder is a function that takes a value and returns a byte slice and an error.

type Factory added in v0.1.16

type Factory interface {
	// NewSource creates a new config using the given KConfig and a list of Options.
	NewSource(*configv1.SourceConfig, *Options) (KSource, error)
}

Factory is an interface that defines a method for creating a new config.

type KConfig added in v0.1.18

type KConfig = kratosconfig.Config

Define types from kratos config package

func NewSourceConfig added in v0.1.17

func NewSourceConfig(opts ...KOption) KConfig

NewSourceConfig returns a new config instance

type KDecoder added in v0.1.18

type KDecoder = kratosconfig.Decoder

Define types from kratos config package

type KKeyValue added in v0.1.18

type KKeyValue = kratosconfig.KeyValue

Define types from kratos config package

type KMerge added in v0.1.18

type KMerge = kratosconfig.Merge

Define types from kratos config package

type KObserver added in v0.1.18

type KObserver = kratosconfig.Observer

Define types from kratos config package

type KOption added in v0.1.18

type KOption = kratosconfig.Option

Define types from kratos config package

func WithDecoder

func WithDecoder(d KDecoder) KOption

WithDecoder sets the decoder

func WithMergeFunc

func WithMergeFunc(m KMerge) KOption

WithMergeFunc sets the merge function

func WithResolveActualTypes

func WithResolveActualTypes(enableConvertToType bool) KOption

WithResolveActualTypes enables resolving actual types

func WithResolver

func WithResolver(r KResolver) KOption

WithResolver sets the resolver

func WithSource

func WithSource(s ...KSource) KOption

WithSource sets the sourceConfig

type KReader added in v0.1.18

type KReader = kratosconfig.Reader

Define types from kratos config package

type KResolver added in v0.1.18

type KResolver = kratosconfig.Resolver

Define types from kratos config package

type KSource added in v0.1.18

type KSource = kratosconfig.Source

Define types from kratos config package

type KValue added in v0.1.18

type KValue = kratosconfig.Value

Define types from kratos config package

type KWatcher added in v0.1.18

type KWatcher = kratosconfig.Watcher

Define types from kratos config package

type Loader added in v0.2.0

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

func New

func New() *Loader

func NewWithBuilder added in v0.2.0

func NewWithBuilder(builder Builder) *Loader

func (*Loader) GetConfig added in v0.2.1

func (c *Loader) GetConfig() (*configv1.SourceConfig, error)

func (*Loader) GetResolved added in v0.2.0

func (c *Loader) GetResolved() (Resolved, error)

func (*Loader) GetResolver added in v0.2.0

func (c *Loader) GetResolver() (Resolver, error)

func (*Loader) GetSource added in v0.2.0

func (c *Loader) GetSource() (KConfig, error)

func (*Loader) Load added in v0.2.0

func (c *Loader) Load(cfg *configv1.SourceConfig, opts ...Option) error

func (*Loader) Resolve added in v0.2.0

func (c *Loader) Resolve(config KConfig) error

func (*Loader) SetResolver added in v0.2.0

func (c *Loader) SetResolver(resolver Resolver) error

type Option

type Option = func(s *Options)

Option is a function that takes a pointer to a KOption struct and modifies it.

func AppendOptions added in v0.2.0

func AppendOptions(options ...KOption) Option

func WithConfigName added in v0.2.0

func WithConfigName(name string) Option

func WithDecoderOption added in v0.2.0

func WithDecoderOption(decoder KDecoder) Option

WithDecoderOption sets the decoder field of the KOption struct.

func WithEncoderOption added in v0.2.0

func WithEncoderOption(encoder Encoder) Option

WithEncoderOption sets the encoder field of the KOption struct.

func WithEnvPrefixes added in v0.2.0

func WithEnvPrefixes(prefixes ...string) Option

func WithForceReload added in v0.2.0

func WithForceReload() Option

func WithOptions

func WithOptions(options ...KOption) Option

WithOptions sets the options field of the KOption struct.

func WithServiceName added in v0.2.0

func WithServiceName(name string) Option

type Options added in v0.1.56

type Options struct {
	ConfigName    string
	ServiceName   string
	ResolverName  string
	EnvPrefixes   []string
	Sources       []KSource
	ConfigOptions []KOption
	Decoder       KDecoder
	Encoder       Encoder
	ForceReload   bool
}

type ProtoSyncer added in v0.2.0

type ProtoSyncer interface {
	SyncConfig(*configv1.SourceConfig, string, proto.Message, *Options) error
}

ProtoSyncer is an interface that defines a method for synchronizing a protobuf message.

type ResolveFunc added in v0.2.0

type ResolveFunc func(config KConfig) (Resolved, error)

func (ResolveFunc) Resolve added in v0.2.0

func (r ResolveFunc) Resolve(config KConfig) (Resolved, error)

type ResolveObserver added in v0.2.0

type ResolveObserver interface {
	Observer(string, KValue)
}

type Resolved added in v0.2.0

type Resolved interface {
	WithDecode(name string, v any, decode func([]byte, any) error) error
	Value(name string) (any, error)
	Middleware() *middlewarev1.Middleware
	Services() []*configv1.Service
	Logger() *configv1.Logger
	Discovery() *configv1.Discovery
}

type Resolver

type Resolver interface {
	Resolve(config KConfig) (Resolved, error)
}
var DefaultResolver Resolver = ResolveFunc(func(config KConfig) (Resolved, error) {
	var r resolver
	err := config.Scan(&r.values)
	if err != nil {
		return nil, err
	}
	return r, nil
})

type SyncFunc added in v0.2.1

type SyncFunc func(*configv1.SourceConfig, string, any, *Options) error

func (SyncFunc) SyncConfig added in v0.2.1

func (fn SyncFunc) SyncConfig(cfg *configv1.SourceConfig, key string, value any, opts *Options) error

type Syncer added in v0.1.16

type Syncer interface {
	SyncConfig(*configv1.SourceConfig, string, any, *Options) error
}

Syncer is an interface that defines a method for synchronizing a config.

Directories

Path Synopsis
Package customize implements the functions, types, and interfaces for the module.
Package customize implements the functions, types, and interfaces for the module.
Package envsetup implements the functions, types, and interfaces for the module.
Package envsetup implements the functions, types, and interfaces for the module.
Package file implements the functions, types, and interfaces for the module.
Package file implements the functions, types, and interfaces for the module.
internal
reflection
Package reflection implements the functions, types, and interfaces for the module.
Package reflection implements the functions, types, and interfaces for the module.

Jump to

Keyboard shortcuts

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