Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCfgValue ¶
func GetCfgValue(key string) interface{}
func NewConfigs ¶
func NewConfigs(cfg *Config, opts ...SetConfigItem)
func SetConfigFile ¶
func SetConfigFile(filename string)
Types ¶
type Config ¶
type Config struct { //服务名称(通过服务名查找可用的服务) Name string `json:"name"` //服务ID(相同服务名不能存在同样的服务ID) Sid string `json:"sid"` Port int `json:"port"` Version string `json:"version"` //静态文件目录 StaticDir []string `json:"staticdir"` //注册服务器配置 RegistryCfg ConfigRegistry `json:"registrycfg"` //扩展配置 Settings map[string]interface{} `json:"settings"` //日志文件 FileLogCfg ConfigFileLog `json:"filelogcfg"` FunInterceptor func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error) }
var (
Conf *Config
)
func ParseConfig ¶
func ParseConfig() *Config
type ConfigFileLog ¶
type ConfigFileLog struct { //服务注册服务类型 LogFilePath string `json:"logfilepath"` //服务注册服务IP地址 LogFileName string `json:"logfilename"` }
文件日志配置
type ConfigRegistry ¶
type ConfigRegistry struct { //服务注册服务类型 Type string `json:"type"` //服务注册服务IP地址 Address string `json:"address"` //注册间隔时间(注册中心掉线可重连) Interval int `json:"interval"` }
注册服务器配置
type SetConfigItem ¶
type SetConfigItem func(*Config)
func Name ¶
func Name(name string) SetConfigItem
func Port ¶
func Port(port int) SetConfigItem
func ServiceID ¶
func ServiceID(sid string) SetConfigItem
func SetInterceptor ¶
func SetInterceptor(v func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error)) SetConfigItem
func Staticdir ¶
func Staticdir(staticDir []string) SetConfigItem
func Version ¶
func Version(v string) SetConfigItem
Click to show internal directories.
Click to hide internal directories.