config

package module
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 12 Imported by: 0

README

config

config 是 infrago 的模块

包定位

  • 类型:模块
  • 作用:统一配置模块,负责配置读取与配置源抽象。

主要功能

  • 对上提供统一模块接口
  • 对下通过驱动接口接入具体后端
  • 支持按配置切换驱动实现

快速接入

import _ "github.com/infrago/config"
[config]
driver = "default"

驱动实现接口列表

以下接口由驱动实现(来自模块 driver.go):

  • 当前模块未提供独立驱动接口(或 driver.go 不存在)

全局配置项(所有配置键)

配置段:[config]

  • 未检测到配置键(请查看模块源码的 configure 逻辑)

说明

  • setting 一般用于向具体驱动透传专用参数
  • 多实例配置请参考模块源码中的 Config/configure 处理逻辑

Documentation

Index

Constants

View Source
const (
	KEY  = "infrago-config"
	JSON = "json"
	TOML = "toml"
	YAML = "yaml"
)

Variables

This section is empty.

Functions

func Decode added in v0.26.0

func Decode(data []byte, format string) (Map, error)

func DetectFormat added in v0.26.0

func DetectFormat(data []byte) string

func Drivers added in v0.26.0

func Drivers() []string

func FormatFromPath added in v0.26.0

func FormatFromPath(file string) string

func Redact added in v0.26.0

func Redact(value Map) Map

Types

type Driver

type Driver interface {
	Load(Map) (Map, error)
}

type Module

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

func (*Module) Close

func (c *Module) Close()

func (*Module) Config

func (c *Module) Config(Map)

Module methods (no-op for now)

func (*Module) Drivers added in v0.26.0

func (c *Module) Drivers() []string

func (*Module) LoadConfig

func (c *Module) LoadConfig() (Map, error)

func (*Module) Open

func (c *Module) Open()

func (*Module) Parse

func (c *Module) Parse() (string, Map, error)

Parse reads env (INFRAGO_*) then args (--key) and returns params + driver name.

func (*Module) Register

func (c *Module) Register(name string, value Any)

Register dispatches config driver registrations.

func (*Module) RegisterDriver

func (c *Module) RegisterDriver(name string, driver Driver)

func (*Module) Setup

func (c *Module) Setup()

func (*Module) Start

func (c *Module) Start()

func (*Module) Stop

func (c *Module) Stop()

Jump to

Keyboard shortcuts

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