conf

package
v0.0.0-...-31a32bb Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKafka

func DefaultKafka() []kafka.ProducerConf

func InitConfig

func InitConfig(path string) (err error)

Types

type Backoff

type Backoff struct {
	BaseDelay  int32   `yaml:"baseDelay"`
	Multiplier float32 `yaml:"multiplier"`
	Jitter     float32 `yaml:"jitter"`
	MaxDelay   int32   `yaml:"maxDelay"`
}

Backoff GRPC Client用到的配置

type Config

type Config struct {
	Name       string               `yaml:"name"`      // 服务名
	Debug      bool                 `yaml:"debug"`     // 是否开启debug
	Discovery  *Discovery           `yaml:"discovery"` // etcd的配置
	RPC        *RPC                 `yaml:"rpc"`       // RPC配置
	HTTPServer *HTTPServer          `yaml:"http"`      // HTTP配置
	Kafka      []kafka.ProducerConf `yaml:"kafka"`     // Kafka的配置
	Redis      []Redis              `yaml:"redis"`     // Redis的配置
	MySQL      []MySQL              `yaml:"mysql"`     // MySQL的配置
	Node       *Node                `yaml:"node"`      // 节点配置(客户端获取节点配置,然后根据配置进行TCP连接)
	Backoff    *Backoff             `yaml:"backoff"`   // GRPC Client用到的配置
	Regions    map[string][]string  `yaml:"regions"`   // 省份与Region的映射关系
}
var Conf *Config

type Discovery

type Discovery struct {
	Addr string `yaml:"addr"`
}

type HTTPServer

type HTTPServer struct {
	Network      string           `yaml:"network"` //
	Addr         string           `yaml:"addr"`
	ReadTimeout  newtime.Duration `yaml:"readTimeout"`
	WriteTimeout newtime.Duration `yaml:"writeTimeout"`
}

HTTPServer is http server config.

type Heartbeat

type Heartbeat struct {
	Interval  newtime.Duration `yaml:"interval"`  // 每次心跳发送的间隔
	FailCount int64            `yaml:"failCount"` // 允许心跳失败的次数(超过次数才算是心跳失败)
}

type MySQL

type MySQL struct {
	Addr     string `yaml:"addr"`
	Port     string `yaml:"port"`
	UserName string `yaml:"userName"`
	Password string `yaml:"password"`
	DbName   string `yaml:"dbName"`
}

func DefaultMySQL

func DefaultMySQL() []MySQL

type Node

type Node struct {
	DefaultDomain string    `yaml:"defaultDomain"` // 默认域名
	HostDomain    string    `yaml:"hostDomain"`    // 主机域名
	TCPPort       int32     `yaml:"tcpPort"`       // 如果采用TCP连接,采用哪个端口?
	WSPort        int32     `yaml:"wsPort"`        // 如果采用WS连接,采用哪个端口?
	WSSPort       int32     `yaml:"wssPort"`       // 如果采用WSS连接,采用哪个端口?
	Heartbeat     Heartbeat `yaml:"heartbeat"`     // 心跳配置
	RegionWeight  float64   `yaml:"regionWeight"`  // 权重扩大比例(如果节点地址所属的Region与当前客户端Region一致,则增加该节点的权重值)
}

Node node config.

type RPC

type RPC struct {
	Server *RPCServer `yaml:"server"`
	Client *RPCClient `yaml:"client"`
}

func DefaultRPC

func DefaultRPC() *RPC

type RPCClient

type RPCClient struct {
	Dial    newtime.Duration `yaml:"dial"`
	Timeout newtime.Duration `yaml:"timeout"`
}

RPCClient is RPC client config.

type RPCServer

type RPCServer struct {
	Network           string           `yaml:"network"` // 使用协议,如:tcp
	Addr              string           `yaml:"addr"`    // 服务器地址
	Timeout           newtime.Duration `yaml:"timeout"`
	IdleTimeout       newtime.Duration `yaml:"idleTimeout"`
	MaxLifeTime       newtime.Duration `yaml:"maxLifeTime"`
	ForceCloseWait    newtime.Duration `yaml:"forceCloseWait"`
	KeepAliveInterval newtime.Duration `yaml:"keepAliveInterval"`
	KeepAliveTimeout  newtime.Duration `yaml:"keepAliveTimeout"`
}

RPCServer is RPC server config.

type Redis

type Redis struct {
	Network      string           `yaml:"network"`
	Addr         string           `yaml:"addr"`
	Auth         string           `yaml:"auth"`
	Active       int              `yaml:"active"`
	Idle         int              `yaml:"idle"`
	DialTimeout  newtime.Duration `yaml:"dialTimeout"`
	ReadTimeout  newtime.Duration `yaml:"readTimeout"`
	WriteTimeout newtime.Duration `yaml:"writeTimeout"`
	IdleTimeout  newtime.Duration `yaml:"idleTimeout"`
	KeyExpire    newtime.Duration `yaml:"keyExpire"`
}

Redis .

func DefaultRedis

func DefaultRedis() []Redis

Jump to

Keyboard shortcuts

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