bootstrap

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(
	wire.FieldsOf(new(*Runtime), "Bootstrap", "Config", "Logger"),
	wire.FieldsOf(new(*corev1.Bootstrap), "Server", "Registry", "Data", "App", "Obs"),
)

ProviderSet exposes stable bootstrap roots for application Wire graphs.

Functions

func Scan added in v0.7.1

func Scan(rt *Runtime, targets ...any) error

Scan loads every target from the runtime's merged kratos config. Targets that implement Section are scanned from Value(SectionKey()); all others are scanned from the whole config. ApplyConf runs only after a successful scan.

Types

type ConfApplier added in v0.6.3

type ConfApplier interface {
	ApplyConf() error
}

ConfApplier is the composite contract for messages processed by protoc-gen-servora-conf. It runs the full post-scan sequence in a single call.

type Defaulter added in v0.6.0

type Defaulter interface {
	ApplyDefaults()
}

Defaulter is the contract for messages that carry literal defaults declared via `(servora.conf.v1.field) = { default: ... }`.

type Option added in v0.7.1

type Option func(*options)

Option 配置 Runtime 创建行为。

func Name added in v0.7.1

func Name(name string) Option

Name 设置配置加载前的服务名默认值。

func Version added in v0.7.1

func Version(version string) Option

Version 设置配置加载前的服务版本默认值。

func WithEnvPrefix

func WithEnvPrefix() Option

WithEnvPrefix 启用基于 Name option 的环境变量前缀。

type OptionalSection added in v0.6.0

type OptionalSection interface {
	SectionOptional() bool
}

OptionalSection marks a Section whose absence from the config source is non-fatal. When SectionOptional reports true and the key is missing, Scan skips both Value(key).Scan and ApplyConf for that target.

type RequiredChecker added in v0.6.3

type RequiredChecker interface {
	CheckRequired() error
}

RequiredChecker is the contract for messages that carry required-field rules. Typically consumed via ConfApplier; exposed for testing and direct use.

type Runtime

type Runtime struct {
	Bootstrap *corev1.Bootstrap
	Config    kconfig.Config
	Logger    *slog.Logger
	// contains filtered or unexported fields
}

Runtime 聚合启动阶段产物与 runtime 级资源清理句柄。

func NewRuntime added in v0.7.1

func NewRuntime(configPath string, opts ...Option) (*Runtime, error)

NewRuntime 加载配置并初始化日志、追踪与 Kratos 应用默认项。

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context) error

Close 释放 Runtime 创建的资源。重复调用返回第一次关闭得到的同一个错误。

func (*Runtime) NewApp added in v0.7.1

func (r *Runtime) NewApp(opts ...kratos.Option) *kratos.App

NewApp 使用 Runtime 默认项构造 Kratos 应用。

func (*Runtime) Run added in v0.7.1

func (r *Runtime) Run(build func() (*kratos.App, func(), error)) (err error)

Run 构建并运行 Kratos 应用,确保业务 cleanup 先于 Runtime 资源关闭。

type Section added in v0.6.0

type Section interface {
	// SectionKey returns the dotted key under which the section lives in the
	// merged kratos config (e.g. "broker", "audit", "data.kafka").
	SectionKey() string
}

Section is the contract implemented by configuration messages that opt into keyed scanning via bootstrap.Scan. Implementations are typically produced by protoc-gen-servora-conf from `(servora.conf.v1.section)`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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