Documentation ¶
Index ¶
- Constants
- Variables
- func CheckFunc(ctx context.Context, num int, fun func() bool) bool
- func Hooks(h zerolog.Hook)
- func NewEtcdClient(Endpoints []string, DialTimeout time.Duration) (*clientv3.Client, error)
- func NewSubLogger(name string, value string) zerolog.Logger
- func OpenPostgresqlClient(conninfo string) (*sql.DB, error)
- func RegisterService(ctx context.Context, cli *clientv3.Client, config *ServiceConfig, ttl int64) error
- type ArrayString
- type NSQQueueProducer
- type QueueConsumer
- type QueueProducer
- type RunEtcdFunc
- type Runner
- type ServiceConfig
- func GetServiceList(ctx context.Context, cli *clientv3.Client, config *ServiceConfig, limit int64) ([]*ServiceConfig, error)
- func Key2ServiceConfig(key string) *ServiceConfig
- func NewServiceConfig(name string) *ServiceConfig
- func ReadServiceInfo(ctx context.Context, cli *clientv3.Client, name string) *ServiceConfig
- type ServiceReg
- type SeverityHook
- type StringArray
Constants ¶
View Source
const ServicePrefix = "flex"
ServicePrefix 默认前缀
Variables ¶
View Source
var Log zerolog.Logger
Log 全局日志对象
Functions ¶
func NewEtcdClient ¶
NewEtcdClient 新建etcd对象
func NewSubLogger ¶
NewSubLogger 生成子日志对象
func OpenPostgresqlClient ¶
OpenPostgresqlClient 打开postgresql数据库
func RegisterService ¶
func RegisterService(ctx context.Context, cli *clientv3.Client, config *ServiceConfig, ttl int64) error
RegisterService 注册服务
Types ¶
type NSQQueueProducer ¶
type NSQQueueProducer struct {
// contains filtered or unexported fields
}
NSQQueueProducer nsq的消息队列接口
type QueueConsumer ¶
type QueueConsumer struct { StopChan chan int // contains filtered or unexported fields }
QueueConsumer 消息队列的消费者
func NewConsumer ¶
func NewConsumer(topic string, channel string) (*QueueConsumer, error)
NewConsumer 新建消费者
func (*QueueConsumer) AddHandler ¶
func (qc *QueueConsumer) AddHandler(hander nsq.Handler)
AddHandler 添加消息回调
func (*QueueConsumer) ConnectToNSQLookupd ¶
func (qc *QueueConsumer) ConnectToNSQLookupd(address string) error
ConnectToNSQLookupd 连接消费队列
type QueueProducer ¶
QueueProducer 消息队列生成者接口
func NewQueueProducer ¶
func NewQueueProducer(address string) (QueueProducer, error)
NewQueueProducer 新的消息生成者
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"-"` Prefix string `json:"-"` Info interface{} `json:"value"` Version string `json:"-"` Host string `json:"host"` Port int64 `json:"port"` }
ServiceConfig 服务信息
func GetServiceList ¶
func GetServiceList(ctx context.Context, cli *clientv3.Client, config *ServiceConfig, limit int64) ([]*ServiceConfig, error)
GetServiceList 得到服务列表
func Key2ServiceConfig ¶
func Key2ServiceConfig(key string) *ServiceConfig
Key2ServiceConfig 由key生成服务信息对象
func ReadServiceInfo ¶
ReadServiceInfo 读取服务信息
func (*ServiceConfig) GetInfoValue ¶
func (sc *ServiceConfig) GetInfoValue() interface{}
GetInfoValue 返回info.value
func (*ServiceConfig) GetServiceName ¶
func (sc *ServiceConfig) GetServiceName() string
GetServiceName 取得服务名称
func (*ServiceConfig) GetValueString ¶
func (sc *ServiceConfig) GetValueString() string
GetValueString 返回配置信息字符串
func (*ServiceConfig) SetValueWithKey ¶
func (sc *ServiceConfig) SetValueWithKey(k string, v interface{})
SetValueWithKey 按属性名更新
type ServiceReg ¶
type ServiceReg struct {
// contains filtered or unexported fields
}
ServiceReg 服务注册对象
func NewServiceReg ¶
func NewServiceReg(ctx context.Context, config *ServiceConfig, cli *clientv3.Client, ttl int64) *ServiceReg
NewServiceReg 服务注册对象
type SeverityHook ¶
type SeverityHook struct{}
type StringArray ¶
type StringArray []string
func (*StringArray) Get ¶
func (a *StringArray) Get() interface{}
func (*StringArray) Set ¶
func (a *StringArray) Set(s string) error
func (*StringArray) String ¶
func (a *StringArray) String() string
Click to show internal directories.
Click to hide internal directories.