config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config 定义 kite 服务的配置结构。

配置分模块:Server / Provider / Redis / Worker 各自独立文件。 通过环境变量加载,KITE_ 前缀 + 模块名 + 字段名。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Server 是 HTTP 服务相关配置。
	Server ServerConfig

	// Provider 是网易云 provider 相关配置。
	Provider ProviderConfig

	// Redis 是 Redis 连接配置(cache / store / asynq 共用)。
	Redis RedisConfig

	// Worker 是 Asynq worker 相关配置。
	Worker WorkerConfig

	// OTel 是 OpenTelemetry 追踪配置。
	OTel OTelConfig
}

Config 是 kite 服务的顶层配置。

func Default

func Default() Config

Default 返回默认配置。

func Load

func Load() Config

Load 从环境变量加载配置,覆盖默认值。

环境变量前缀为 KITE_,格式:KITE_{MODULE}_{FIELD}。 例如 KITE_SERVER_PORT、KITE_REDIS_HOST。

func (Config) String

func (c Config) String() string

String 返回配置摘要,用于启动日志。

type OTelConfig

type OTelConfig struct {
	// Exporter 是 exporter 类型:none(noop,本地开发默认)/ otlp-grpc / otlp-http。
	Exporter string

	// Endpoint 是 OTLP collector 地址(如 localhost:4317)。
	// 仅 Exporter 非 none 时生效。
	Endpoint string

	// ServiceName 是上报到后端的服务名(如 kite)。
	ServiceName string

	// SampleRatio 是根 span 采样率,0.0-1.0,1.0 表示全采样。
	SampleRatio float64
}

OTelConfig 是 OpenTelemetry 追踪配置。

type ProviderConfig

type ProviderConfig struct {
	// UpstreamTimeout 是调用网易云上游的超时时间,单位秒。
	UpstreamTimeout int

	// MaxRetries 是调用上游失败后的最大重试次数。
	MaxRetries int
}

ProviderConfig 是网易云 provider 相关配置。

type RedisConfig

type RedisConfig struct {
	// Host 是 Redis 主机地址。
	Host string

	// Port 是 Redis 端口。
	Port int

	// Password 是 Redis 密码,无密码时为空。
	Password string

	// DB 是 Redis 数据库编号。
	DB int

	// PoolSize 是 Redis 连接池大小(cache / store / asynq 共用)。
	PoolSize int
}

RedisConfig 是 Redis 连接配置。

cache / store / asynq 三个组件共用同一个 Redis 连接。

func (RedisConfig) Addr

func (r RedisConfig) Addr() string

Addr 返回 Redis 地址(host:port 格式)。

type ServerConfig

type ServerConfig struct {
	// Port 是 HTTP 服务监听端口。
	Port int

	// Env 是运行环境(dev / prod)。
	//
	// dev 环境用彩色文本日志,prod 环境用 JSON 日志。
	Env string
}

ServerConfig 是 HTTP 服务相关配置。

type WorkerConfig

type WorkerConfig struct {
	// Concurrency 是 worker 并发处理的任务数。
	Concurrency int

	// CookieCheckInterval 是 Cookie 健康检查的轮询间隔,单位小时。
	CookieCheckInterval int
}

WorkerConfig 是 Asynq worker 相关配置。

Jump to

Keyboard shortcuts

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