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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(path string) (err error)

Types

type Bucket

type Bucket struct {
	HashNum            int `yaml:"hashNum"`            // Hash切片数量(每个切片是一个Bucket)
	InitSizeChannelMap int `yaml:"initSizeChannelMap"` // Channel Map的大小(初始大小)
	InitSizeRoomMap    int `yaml:"initSizeRoomMap"`    // Room Map的大小(初始大小)
	RoutineAmount      int `yaml:"routineHashNum"`     // Hash切片数量:每个切片是一个协程
	RoutineChannelSize int `yaml:"routineChannelSize"` // 每个协程拥有一个指定缓冲大小的Channel
}

type Config

type Config struct {
	Env       *Env       `yaml:"env"`
	Name      string     `yaml:"name"`      // 服务名
	Debug     bool       `yaml:"debug"`     // 是否开启debug
	Discovery *Discovery `yaml:"discovery"` // etcd的配置
	Connect   *Connect   `yaml:"connect"`   // 长连接配置
	RPC       *RPC       `yaml:"rpc"`       // RPC配置
	Protocol  *Protocol  `yaml:"protocol"`  // 协议配置
	Bucket    *Bucket    `yaml:"bucket"`    // 桶配置
}

Config is comet config.

var Conf *Config

type Connect

type Connect struct {
	TCP           *TCP           `yaml:"tcp"`
	Websocket     *Websocket     `yaml:"websocket"`
	BufferOptions *bytes.Options `yaml:"bufferOptions"`
}

func DefaultConnect

func DefaultConnect() *Connect

type Discovery

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

type Env

type Env struct {
	Region    string   `yaml:"region"`    // 地域
	Zone      string   `yaml:"zone"`      // 可用区
	DeployEnv string   `yaml:"deployEnv"` // 部署环境
	HostName  string   `yaml:"host"`      // 主机
	Weight    int64    `yaml:"weight"`    // 权重(负载均衡权重)
	Offline   bool     `yaml:"offline"`
	Addrs     []string `yaml:"addrs"`
}

Env is env config.(暂无使用)

func DefaultEnv

func DefaultEnv() *Env

type Proto

type Proto struct {
	ChannelSize   int `yaml:"channelSize"`   // 每个TCP链接都有一个缓冲大小ChannelSize的Channel接收Proto
	AllocatorSize int `yaml:"allocatorSize"` // 一个Proto分配器的最大容量
}

type Protocol

type Protocol struct {
	TimerPool        *TimerPool       `yaml:"timerPool"`        // Timer池子的配置
	Proto            *Proto           `yaml:"proto"`            // proto相关的配置
	HandshakeTimeout newtime.Duration `yaml:"handshakeTimeout"` // TCP 握手超时
}

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 TCP

type TCP struct {
	Bind      []string `yaml:"bind"`      // 绑定的地址
	Sndbuf    int      `yaml:"sndbuf"`    // 内核缓冲区
	Rcvbuf    int      `yaml:"rcvbuf"`    // 内核缓冲区
	Keepalive bool     `yaml:"keepalive"` // 操作系统的Keepalive机制(自带的心跳机制)
}

type TimerPool

type TimerPool struct {
	HashNum        int `yaml:"hashNum"`        // Hash切片数量:每个切片是一个Timer池子
	InitSizeInPool int `yaml:"initSizeInPool"` // 每个Timer池子中,拥有的Timer初始数量
}

TimerPool Timer池子的配置

type Websocket

type Websocket struct {
	Bind        []string `yaml:"bind"`        // 绑定的地址
	TLSOpen     bool     `yaml:"tlsOpen"`     // 是否开启TLS
	TLSBind     []string `yaml:"tlsBind"`     // TLS的绑定地址
	CertFile    string   `yaml:"certFile"`    // 证书文件
	PrivateFile string   `yaml:"privateFile"` // 私钥文件
}

Jump to

Keyboard shortcuts

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