config

package module
v0.0.0-...-0025b7e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package config 提供动态配置的接口

Index

Constants

View Source
const (
	// ErrConfig 表示 config 错误
	ErrConfig = E("amc config error")
)

Variables

This section is empty.

Functions

func Bind

func Bind[T any](
	ctx context.Context, api API, encoding Encoding, key string, holder **T,
) error

Bind 绑定一个远端配置和本地存储

func Watch

func Watch[T any](
	ctx context.Context, api API, encoding Encoding, key string,
) (firstValue *T, watcher <-chan *T, err error)

Watch 获取第一个配置并持续监听变化

Types

type API

type API interface {
	GetConfig() config.KVConfig
}

API 定义配置配置 API

type E

type E string

E 表示内部错误

func (E) Error

func (e E) Error() string

type Encoding

type Encoding string

Encoding 定义了编解码格式

const (
	JSON Encoding = "json"
	YAML Encoding = "yaml"
	TEXT Encoding = "text"
)

Directories

Path Synopsis
etcd module
Package file 封装本地文件配置 API, 支持热更新
Package file 封装本地文件配置 API, 支持热更新

Jump to

Keyboard shortcuts

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