config

package
v0.0.0-...-6a0a93c Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config *config

Functions

func GetServiceAddress

func GetServiceAddress() string

func GetServiceID

func GetServiceID() string

func GetServiceName

func GetServiceName() string

func LoadConfig

func LoadConfig() error

func LoadConfigFromConsul

func LoadConfigFromConsul(key string) error

从 Consul 加载

Types

type ConsulConfig

type ConsulConfig struct {
	Address string `yaml:"address" json:"address"`
	Token   string `yaml:"token" json:"token"` // 可选,ACL Token
}

新增 Consul 配置结构体

type DatabaseConfig

type DatabaseConfig struct {
	Dialect  string `yaml:"dialect" json:"dialect"`
	Host     string `yaml:"host" json:"host"`
	Port     int    `yaml:"port" json:"port"`
	Database string `yaml:"database" json:"database"`
	User     string `yaml:"user" json:"user"`
	Password string `yaml:"password" json:"password"`
	Schema   string `yaml:"schema" json:"schema"`
	Level    string `yaml:"level" json:"level"`
}

type JWTConfig

type JWTConfig struct {
	Secret        string `yaml:"secret" json:"secret"`
	ExpireSeconds int    `yaml:"expireSeconds" json:"expireSeconds"`
}

type KafkaConfig

type KafkaConfig struct {
	Brokers []string `yaml:"brokers" json:"brokers"`
	Topic   string   `yaml:"topic" json:"topic"`
	GroupID string   `yaml:"groupId" json:"groupId"` // Kafka 消费者组 ID
}

type RedisConfig

type RedisConfig struct {
	Host         string `yaml:"host" json:"host"`
	Port         int    `yaml:"port" json:"port"`
	Password     string `yaml:"password" json:"password"`
	DB           int    `yaml:"db" json:"db"`
	PoolSize     int    `yaml:"poolSize" json:"poolSize"`
	MinIdleConns int    `yaml:"minIdleConns" json:"minIdleConns"`
}

type RocketMQConfig

type RocketMQConfig struct {
	NameServer    string `yaml:"nameServer" json:"nameServer"`       // RocketMQ NameServer 地址
	GroupName     string `yaml:"groupName" json:"groupName"`         // Producer 分组
	ProducerTopic string `yaml:"producerTopic" json:"producerTopic"` // Producer 使用的 topic
	ConsumerTopic string `yaml:"consumerTopic" json:"consumerTopic"` // Consumer 订阅的 topic
	RetryTimes    int    `yaml:"retryTimes" json:"retryTimes"`       // 发送失败重试次数
}

type SMSConfig

type SMSConfig struct {
	Provider          string `yaml:"provider" json:"provider"`
	AccessKeyID       string `yaml:"accessKeyId" json:"accessKeyId"`
	AccessKeySecret   string `yaml:"accessKeySecret" json:"accessKeySecret"`
	SignName          string `yaml:"signName" json:"signName"`
	TemplateCode      string `yaml:"templateCode" json:"templateCode"`
	Region            string `yaml:"region" json:"region"`
	CodeExpireSeconds int    `yaml:"codeExpireSeconds" json:"codeExpireSeconds"`
}

type ServerConfig

type ServerConfig struct {
	User    ServiceConfig `yaml:"user" json:"user"`
	Order   ServiceConfig `yaml:"order" json:"order"`
	Gateway ServiceConfig `yaml:"gateway" json:"gateway"` // 新增 Gateway 服务配置
}

type ServiceConfig

type ServiceConfig struct {
	Host     string `yaml:"host" json:"host"`
	GRPCPort string `yaml:"grpcPort" json:"grpcPort"` // gRPC 服务端口
	Name     string `yaml:"name" json:"name"`         // 服务名称
	HTTPPort string `yaml:"httpPort" json:"httpPort"` // HTTP 服务端口
}

Jump to

Keyboard shortcuts

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