config

package
v1.0.1-rc1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfFileNotFound = errors.New("config file not found")
)

Functions

This section is empty.

Types

type ClusterConfig

type ClusterConfig struct {
	Self       string                   `toml:"self"`
	Connection *ClusterConnectionConfig `toml:"connection"`
	Nodes      []*ClusterNodeConfig     `toml:"nodes"`
	Failover   *ClusterFailoverConfig   `toml:"failover"`
}

func (*ClusterConfig) String

func (ccnf *ClusterConfig) String() string

type ClusterConnectionConfig

type ClusterConnectionConfig struct {
	DialTimeout       Duration `toml:"dial_timeout"`
	MaxDelay          Duration `toml:"max_delay"`
	BaseDelay         Duration `toml:"base_delay"`
	Factor            float64  `toml:"factor"`
	Jitter            float64  `toml:"jitter"`
	DisableReqTimeout bool     `toml:"disable_request_timeout"`
	ReqWaitAfter      Duration `toml:"request_wait_after"`
}

func (*ClusterConnectionConfig) String

func (ccc *ClusterConnectionConfig) String() string

type ClusterFailoverConfig

type ClusterFailoverConfig struct {
	Enabled       bool     `toml:"enabled"`
	Heartbeat     Duration `toml:"heartbeat"`
	VoteAfter     int      `toml:"vote_after"`
	NodeFailAfter int      `toml:"node_fail_after"`
}

func (*ClusterFailoverConfig) String

func (cfc *ClusterFailoverConfig) String() string

type ClusterNodeConfig

type ClusterNodeConfig struct {
	Name    string `toml:"name"`
	Address string `toml:"address"`
}

func (*ClusterNodeConfig) String

func (cnc *ClusterNodeConfig) String() string

type Config

type Config struct {
	WsCnf        *WebsocketConfig    `toml:"websocket"`
	ClusterCnf   *ClusterConfig      `toml:"cluster"`
	KafkaCnf     []*KafkaConfig      `toml:"kafkas"`
	PluginsCnf   []*PluginConfig     `toml:"plugins"`
	RouteCnf     *RouteConfig        `toml:"route""`
	RouteHttpCnf *RouteHttpConfig    `toml:"routehttp"`
	SchedulerCnf *SchedulerConfig    `toml:"scheduler"`
	LimitCnf     *LimitConfig        `toml:"limit"`
	LoginMPCnf   *MethodPathConfig   `toml:"login"`
	WhiteList    []*MethodPathConfig `toml:"whiteList"`
}

func Load

func Load(filePath string) (*Config, error)

Load 载入dolphin配置文件 1. 用户指定路径,如果传入的配置文件为空,则按照以下顺序查找配置文件 2. 查询应用程序同路径下是否存在配置文件 3. 查询$HOME/.config/dolphin.d/config.toml 4. 查询/etc/dolphin.d/config.toml

func (*Config) GetClusterConfig

func (cnf *Config) GetClusterConfig() *ClusterConfig

func (*Config) GetKafkaConfig

func (cnf *Config) GetKafkaConfig() []*KafkaConfig

func (*Config) GetLimitConfig

func (cnf *Config) GetLimitConfig() *LimitConfig

func (*Config) GetLoginMPConfig

func (cnf *Config) GetLoginMPConfig() *MethodPathConfig

func (*Config) GetPluginConfigs

func (cnf *Config) GetPluginConfigs() []*PluginConfig

func (*Config) GetRouteConfig

func (cnf *Config) GetRouteConfig() *RouteConfig

func (*Config) GetRouteHttpConfig

func (cnf *Config) GetRouteHttpConfig() *RouteHttpConfig

func (*Config) GetWebsocketConfig

func (cnf *Config) GetWebsocketConfig() *WebsocketConfig

func (*Config) GetWhiteListConfig

func (cnf *Config) GetWhiteListConfig() []*MethodPathConfig

func (*Config) String

func (cnf *Config) String() string

type Duration

type Duration struct {
	time.Duration
}

func (*Duration) Get

func (d *Duration) Get() time.Duration

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) (err error)

type KafkaConfig

type KafkaConfig struct {
	Brokers   []string `toml:"brokers"`
	Topic     string   `toml:"topic"`
	Offset    int64    `toml:"offset"`
	GroupID   string   `toml:"groupId"`
	Partition int      `toml:"partition"`
	MinBytes  int      `toml:"minBytes"`
	MaxBytes  int      `toml:"maxBytes"`
	MaxWait   Duration `toml:"maxWait"`
}

func (*KafkaConfig) String

func (kcnf *KafkaConfig) String() string

type LimitConfig

type LimitConfig struct {
	//最大请求数
	MaxNum int `toml:"maxNum"`
	//每个bucket每秒钟请求个数
	MaxRate int `toml:"maxRate"`
	//每个bucket可溢出请求个数
	MaxBurst int `toml:"maxBurst"`
}

type MethodPathConfig

type MethodPathConfig struct {
	Resource string `toml:"resource"`
	Version  string `toml:"version"`
	Action   string `toml:"action"`
}

type PluginConfig

type PluginConfig struct {
	Enabled    bool   `toml:"enabled"`
	Name       string `toml:"name"`
	ServerAddr string `toml:"server_addr"`
}

func (*PluginConfig) String

func (pcnf *PluginConfig) String() string

type RouteConfig

type RouteConfig struct {
	//dolphin维护的grpc client的心跳监测周期
	HeartBeat Duration `toml:"heartBeat"`
	//grpc client 回收周期
	Recycle Duration `toml:"recycle"`
	//grpc client 不正常请求个数阙值,超过个数后,在下次回收周期到来后grpc client会被移除
	Threshold int16 `toml:"threshold"`
	//grpc client 请求timeout
	Timeout Duration `toml:"timeout"`
}

type RouteHttpConfig

type RouteHttpConfig struct {
	Address string `toml:"address"`
}

type SchedulerConfig

type SchedulerConfig struct {
	Address string `toml:"address"`
}

type WebsocketConfig

type WebsocketConfig struct {
	//监听端口号
	Listen string `toml:"listen"`
	//读取缓冲区大小设置
	ReadBufSize int `toml:"read_buf_size"`
	//写缓冲区大小设置
	WriteBufSize int `toml:"write_buf_size"`
	//tls配置,证书路径等
	Tls *WsTlsConfig `toml:"tls"`
	//写数据timeout
	WriteWait Duration `toml:"write_time_wait"`
	//读数据timeout
	ReadWait Duration `toml:"read_time_wait"`
	//空闲会话timeout
	IdleSessionTimeout Duration `toml:"idle_session_timeout"`
	//写数据个数缓冲区限制
	SessionQueueSize int `toml:"session_queue_size"`
	//写数据个数缓冲区消费等待时间
	QueueOutTimeout Duration `toml:"queue_out_timeout"`
	//sess.guid 盐
	IDSalt string `toml:"id_salt"`
}

func (*WebsocketConfig) String

func (wscnf *WebsocketConfig) String() string

type WsAutoCertConfig

type WsAutoCertConfig struct {
	CertCache string   `toml:"cert_cache"`
	Email     string   `toml:"email"`
	Domains   []string `toml:"domains"`
}

func (*WsAutoCertConfig) String

func (acc *WsAutoCertConfig) String() string

type WsTlsConfig

type WsTlsConfig struct {
	Enabled      bool              `toml:"enabled"`
	HTTPRedirect string            `toml:"http_redirect"`
	CertFile     string            `toml:"cert_file"`
	KeyFile      string            `toml:"key_file"`
	Autocert     *WsAutoCertConfig `toml:"autocert"`
}

func (*WsTlsConfig) String

func (tcnf *WsTlsConfig) String() string

Jump to

Keyboard shortcuts

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