Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectRedis(addr string, password string, db int32) (*redis.Client, error)
- func ConnectRedisCluster(addrs []string, password string, db int32) (*redis.ClusterClient, error)
- func GetCataIdByLogicId(logicId uint64) (uint64, error)
- func GetFuncIdByLogicId(logicId uint64) (uint64, error)
- func GetGameIdByLogicId(logicId uint64) (uint64, error)
- func GetMacInfoImmutablePart(mac *MachMeta)
- func GetMachInfo(mac *MachMeta)
- func GetMachInfoMutablePart(mac *MachMeta)
- func GetSubIdByLogicId(logicId uint64) (uint64, error)
- func SendSmsTo(phone string, text string) error
- type AppInfo
- type AppInfoOptions
- type Event
- type HttpClient
- type HttpGin
- type HttpGinOptions
- func EnableBlacklist(b []string) HttpGinOptions
- func EnableCors(enable bool) HttpGinOptions
- func EnableDebug(enable bool) HttpGinOptions
- func EnableFlowControl(enable bool) HttpGinOptions
- func EnableHTML(enable bool, ptn string) HttpGinOptions
- func EnableSession(enable bool, store sessions.Store) HttpGinOptions
- func EnableWhitelist(b []string) HttpGinOptions
- type JwtTokener
- type LogicID
- type MachMeta
- type Mail
- type MailReceiver
- type Mailer
- type Version
- type ZkCallback
- type ZkClient
- func (self *ZkClient) Close()
- func (self *ZkClient) CreateEmpNode(name string, data []byte) error
- func (self *ZkClient) Exists(name string) bool
- func (self *ZkClient) GetChildren(name string) ([]string, error)
- func (self *ZkClient) GetNodeData(name string) ([]byte, error)
- func (self *ZkClient) SetNodeData(path string, data []byte) error
- func (self *ZkClient) WatchChildren(name string) error
- func (self *ZkClient) WatchNode(name string) error
Constants ¶
View Source
const ( LI_FUNC_MULTI = 1000000 LI_CATA_MULTI = 10000 LI_SUB_MULTI = 100 LI_INST_MULTI = 1 LI_MAX_ID = 100 )
Variables ¶
View Source
var ( MESSAGE_SUCCESS string = "OK" ACCESS_KEY_ID string = "LTAIDquqdpFdYVmW" ACCESS_KEY_SECRET string = "ozeRm4LWSqEnpPEw9spdOfylSNprY1" SIGN_NAME string = "海拉科技" TEMPLATE_CODE string = "SMS_127790203" PRODUCT string = "Dysmsapi" VERSION string = "2017-05-25" DOMAIN string = "dysmsapi.aliyuncs.com" REGION string = "cn-hangzhou" ErrReturnValue = errors.New("sms return message means failed.") )
View Source
var (
ErrHttpStatusCode = errors.New("http return bad status code.")
)
View Source
var (
ErrInvalidLogicId = errors.New("Invalid logic id")
)
设计规则
每个逻辑服务器都有一个ID,叫 logicId,对应一个逻辑服务器"实例" logicId = funcId(1-999) + cataId(1-99) + subId(1-99) + instId(1-99) 其中 funcId 代表一个逻辑功能 比如斗地主游戏 cataId 代表一个分类,比如中级场 subId 子分类, 比如癞子 instId 实例, 比如癞子斗地主中级场启动了 2 个实例用于负载均衡,可能 instId 分别对应1,2 gameId 对应一个游戏,忽略 instId 由其他部分组成
实例: 1 斗地主, 1 初级场 1 普通斗地主 两个实例分别为 1, 2 则这两个进程的ID 分别为 1010101, 1010102 gameId 都为 1010100
View Source
var (
ErrInvalidParams = errors.New("invalid parameters")
)
Functions ¶
func ConnectRedis ¶
func ConnectRedisCluster ¶
@data: redis 连接参数 json,来自 zookeeper @conf
func GetCataIdByLogicId ¶
func GetGameIdByLogicId ¶
func GetMacInfoImmutablePart ¶
func GetMacInfoImmutablePart(mac *MachMeta)
func GetMachInfo ¶
func GetMachInfo(mac *MachMeta)
func GetMachInfoMutablePart ¶
func GetMachInfoMutablePart(mac *MachMeta)
func GetSubIdByLogicId ¶
Types ¶
type AppInfo ¶
type AppInfo struct { Name string // 程序名,和文件名无关,编译时指定 InstName string // 进程实例名称 BootAt time.Time // 启动时间 Ver *Version // 版本号 ConfFile string // 配置文件名 Log *log.SLogger // 日志对象 Rdb *redis.Client // redis 客户端 Ev *mq.Eventbus // 事件总线 Mq *mq.Mq // 消息队列 Zk *ZkClient // zookeeper Debug bool Mode string Offline int32 // 是否下线 0 不下线 ChQuit chan struct{} // 进程退出 // contains filtered or unexported fields }
一个程序的基本信息
func NewAppInfo ¶
func (*AppInfo) RegisterSelf ¶
add a node to zookeeper
type AppInfoOptions ¶
type AppInfoOptions func(info *AppInfo)
func AppEnableLogger ¶
func AppEnableLogger(enable bool, logLevel int32, logPath string, logStdout bool) AppInfoOptions
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient() *HttpClient
func (*HttpClient) LastStatusCode ¶
func (self *HttpClient) LastStatusCode() int
type HttpGin ¶
type HttpGin struct {
// contains filtered or unexported fields
}
func NewHttpGinServer ¶
func NewHttpGinServer(addr string, options ...HttpGinOptions) *HttpGin
type HttpGinOptions ¶
type HttpGinOptions func(*HttpGin)
func EnableBlacklist ¶
func EnableBlacklist(b []string) HttpGinOptions
func EnableCors ¶
func EnableCors(enable bool) HttpGinOptions
func EnableDebug ¶
func EnableDebug(enable bool) HttpGinOptions
func EnableFlowControl ¶
func EnableFlowControl(enable bool) HttpGinOptions
func EnableHTML ¶
func EnableHTML(enable bool, ptn string) HttpGinOptions
func EnableSession ¶
func EnableSession(enable bool, store sessions.Store) HttpGinOptions
func EnableWhitelist ¶
func EnableWhitelist(b []string) HttpGinOptions
type JwtTokener ¶
type JwtTokener struct {
// contains filtered or unexported fields
}
func NewJwtTokener ¶
func NewJwtTokener(key string) *JwtTokener
func (*JwtTokener) Parse ¶
func (self *JwtTokener) Parse(token string) (jwt.MapClaims, error)
type LogicID ¶
type LogicID struct {
// contains filtered or unexported fields
}
func NewLogicIDByID ¶
func NewLogicIDByParts ¶
func (*LogicID) HeaderCata ¶
type MachMeta ¶
type MachMeta struct { MemTotal uint64 MemUsed uint64 MemAvailable uint64 MemPercent float64 CpuNum int CpuCoreNum int32 CpuModelName string CpuPercent []float64 Hostname string UpTime uint64 BootTime uint64 OS string Platform string KernelVer string Arch string }
服务器硬件信息
type MailReceiver ¶
type ZkCallback ¶
/ 路径规则根据 unix 路径规则
type ZkClient ¶
type ZkClient struct {
// contains filtered or unexported fields
}
一个到 zookeeper 的连接
func NewZkClient ¶
func NewZkClient(hosts []string, root string, user string, password string, timeout int, cb ZkCallback) (*ZkClient, error)
创建 zookeeper 连接 timeout 秒
func (*ZkClient) CreateEmpNode ¶
更新节点数据,不存在则创建
func (*ZkClient) GetChildren ¶
获取子节点列表
func (*ZkClient) GetNodeData ¶
获得节点数据
func (*ZkClient) WatchChildren ¶
节点监控,目前通知不能详细到
Source Files ¶
Click to show internal directories.
Click to hide internal directories.