lib

package
v0.0.0-...-0e6f1c7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PASSWD_SALT_LEN                   = 32
	LOGIN_LOCK_LIFE                   = 20                 //login lock life (second)
	FORMAT_TAB_USER_GLOBAL            = "users:global:%s"  //users:global:[name]  ++ hash ++ name | pass | uid | salt
	FORMAT_TAB_USER_INFO_REFIX        = "user:"            // user:[uid] ++ hash ++ uid | name | age | sex  | addr | level | online_logic | blob_info
	FORMAT_TAB_USER_LOGIN_LOCK_PREFIX = "user:login_lock:" //user:login:[uid] <string> valid_second
	FORMAT_TAB_GLOBAL_UID             = "global:uid"       // ++ string

	//Useful FIELD
	FIELD_USER_INFO_ONLINE_LOGIC = "online_logic"

	//REDIS METHOD
	REDIS_METHOD_SINGLE = 0 //simplest method ,only use addr[0] as read and write candidate
	REDIS_METHOD_SM     = 1 //1 master and many slaves. ps:addr[0] is defined as master

	//REDIS OPERATION
	REDIS_OPT_R  = 1 //only for read operation,may dispatch to slave
	REDIS_OPT_W  = 2 //write operation will only disaptch to master
	REDIS_OPT_RW = REDIS_OPT_R | REDIS_OPT_W
)
View Source
const (
	MESSAGE_LEN = ss.MAX_SS_MSG_SIZE //200k
)

Variables

This section is empty.

Functions

func AfterReLoadConfig

func AfterReLoadConfig(pconfig *Config, old_config *FileConfig, new_config *FileConfig)

After ReLoad Config If Need Handle

func CalcRedisConn

func CalcRedisConn(pconfig *Config) int

all conn

func CloseRedis

func CloseRedis(pconfig *Config)

close redis client

func CommSet

func CommSet(pconfig *Config) bool

Comm Config Setting

func HandleReportCmd

func HandleReportCmd(pconfig *Config, pmsg *comm.ReportMsg)

func HeartBeatToRedis

func HeartBeatToRedis(arg interface{})

func InitRedisDb

func InitRedisDb(arg interface{})

init db info when first started only use addr[0] as master

func LocalSet

func LocalSet(pconfig *Config) bool

Local Proc Setting

func OpenRedis

func OpenRedis(pconfig *Config) bool

open redis client

func RecvHeartBeatReq

func RecvHeartBeatReq(pconfig *Config, preq *ss.MsgHeartBeatReq, from int)

func RecvMsg

func RecvMsg(pconfig *Config) int64

func RecvRegReq

func RecvRegReq(pconfig *Config, preq *ss.MsgRegReq, from int)

func RecvReportCmd

func RecvReportCmd(arg interface{})

func RecvUserLoginReq

func RecvUserLoginReq(pconfig *Config, preq *ss.MsgLoginReq, from int)

user login

func RecvUserLogoutReq

func RecvUserLogoutReq(pconfig *Config, preq *ss.MsgLogoutReq, from int)

user logout

func ReportSyncServer

func ReportSyncServer(arg interface{})

func ResetRedis

func ResetRedis(pconfig *Config, old_config *FileConfig, new_config *FileConfig)

ResetRedis must ensure pconfig.RedisClients all member not nil!

func SelectRedisClient

func SelectRedisClient(pconfig *Config, redis_opt int) *comm.RedisClient

select a proper client to exe cmd

func SendHeartBeatMsg

func SendHeartBeatMsg(arg interface{})

func SendRegRsp

func SendRegRsp(pconfig *Config, preq *ss.MsgRegReq, target_serv int, result ss.REG_RESULT)

func SendToServ

func SendToServ(pconfig *Config, target_serv int, pss_msg *ss.SSMsg) bool

send to other server

func ServerExit

func ServerExit(pconfig *Config)

Server Exit

func ServerStart

func ServerStart(pconfig *Config)

Main Proc

Types

type Config

type Config struct {
	//comm
	NameSpace      string
	ProcId         int
	ProcName       string
	ConfigFile     string
	Daemon         bool
	FileConfig     *FileConfig
	Comm           *comm.CommConfig
	ReportCmd      string //used for report cmd
	ReportCmdToken int64
	ReportServ     *comm.ReportServ //report to manger
	//local
	RedisClients []*RedisClientInfo
}

type FileConfig

type FileConfig struct {
	//	ProcName string `json:"proc_name"`
	TargetServs    []int    `json:"target_servs"` //target serv set
	LogFile        string   `json:"log_file"`
	RedisMethod    int      `json:"redis_method"`
	RedisAddr      []string `json:"redis_addr"`
	MaxConn        int      `json:"max_conn"`    //max redis-conn of process
	NormalConn     int      `json:"normal_conn"` //normal redis-conn
	AuthPass       string   `json:"auth_pass"`
	ManageAddr     []string `json:"manage_addr"`
	InitRedisAfter int      `json:"init_redis_after"` //init redis db info after start xx seconds
	InitUid        int64    `json:"init_uid"`         //init uid number
	UidIncr        int      `json:"uid_incr"`         //uid incr step
	MonitorInv     int      `json:"monitor_inv"`      //monitor interval seconds
}

type Msg

type Msg struct {
	// contains filtered or unexported fields
}

type RedisClientInfo

type RedisClientInfo struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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