flags

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppID

func AppID() string

AppID 返回字符串型的appid

func AttributeConfigOpf

func AttributeConfigOpf(opt *attribute.Option)

func DefaultClusterRedis

func DefaultClusterRedis(addrs ...string) func(*Option)

func DefaultEtcd

func DefaultEtcd(option *Option)

func DefaultMongo

func DefaultMongo(option *Option)

func DefaultMysql

func DefaultMysql(option *Option)

func DefaultQueue

func DefaultQueue(option *Option)

func DefaultRedis

func DefaultRedis(option *Option)

func EtcdConfigOpf

func EtcdConfigOpf(cfg *clientv3.Config)

func MysqlConfigOpf

func MysqlConfigOpf(opt *mysql.Option)

func Parse

func Parse(name string, opts ...func(*Option)) (ctx contextx.Context, wait func())

Parse 解析配置, 启动参数有传参则忽略配置文件

func RedisConfigOpf

func RedisConfigOpf(rdb redis.RdbConfig)

func Source

func Source() string

Source 可用于服务注册中的key或者日志中的source可区别开不同的服务或同个服务不同的结点

Types

type Option

type Option struct {
	ID         int    // 服务id
	AppName    string // 服务名称
	Mode       string // 模式
	Configfile string // 配置文件路径

	// log配置
	LogDir     string // log目录
	LogCaller  bool   // 是否开启记录输出日志的代码文件行号
	LogRequest bool   // 是否开启http请求的日志记录
	LogStat    bool   // 是否开启系统状态日志输出

	// http服务配置
	HttpIp   string
	HttpPort int

	// rpc服务配置
	RpcIp   string
	RpcPort int

	// mysql 配置
	MysqlAddr string
	MysqlUser string
	MysqlPwd  string
	MysqlDB   string

	// MongoDB 配置
	MongoAddr string
	MongoUser string
	MongoPwd  string
	MongoDB   string

	// etcd 配置
	EtcdAddrs  string // 地址集,用;隔开
	EtcdUser   string
	EtcdPasswd string

	// redis配置
	RedisAddrs  string // 数据库地址集,用;隔开
	RedisDBNo   int    // 数据库编号
	RedisUser   string
	RedisPasswd string

	// 消息队列配置
	QueueType  string // 消息队列类型
	QueueAddrs string // 地址

	// websocket注册进etcd的地址(外网地址),将返回给客户端
	FrontendAddr string
}

Option 配置数据结构体

var (
	Options *Option // 全局存储
)

Jump to

Keyboard shortcuts

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