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.") )
设计规则
每个逻辑服务器都有一个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
Functions ¶
func ConnectRedis ¶
func ConnectRedisCluster ¶ added in v0.5.11
@data: redis 连接参数 json,来自 zookeeper @conf
func GetFuncIdByLogicId ¶ added in v0.5.3
sugar functions
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) EnableLog ¶
type HttpClient ¶ added in v0.4.6
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶ added in v0.4.6
func NewHttpClient() *HttpClient
func (*HttpClient) LastStatusCode ¶ added in v0.4.6
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 ¶ added in v0.4.6
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 ¶ added in v0.5.7
func EnableHTML(enable bool, ptn string) HttpGinOptions
func EnableSession ¶ added in v0.4.6
func EnableSession(enable bool, store sessions.Store) HttpGinOptions
func EnableWhitelist ¶ added in v0.4.6
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)
func (*JwtTokener) Token ¶
func (self *JwtTokener) Token(m map[string]interface{}) (string, error)
type LogicID ¶
type LogicID struct {
// contains filtered or unexported fields
}
func NewLogicIDByParts ¶
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 Mailer ¶ added in v0.5.1
type Mailer struct {
// contains filtered or unexported fields
}
func NewMailer ¶ added in v0.5.1
func (*Mailer) Send ¶ added in v0.5.1
func (self *Mailer) Send(receivers ...MailReceiver) error
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
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.