package adminrpc
|
|
|
|
import (
|
|
"git.tetele.net/tgo/conf"
|
|
)
|
|
|
|
const DES_KEY = "adminrpc"
|
|
|
|
type Req struct {
|
|
SiteId string
|
|
Dbname string
|
|
}
|
|
|
|
type GetByTokenReq struct {
|
|
Req
|
|
Token string
|
|
}
|
|
type Res struct {
|
|
Errcode int
|
|
Errmsg string
|
|
}
|
|
|
|
func rpc_server_conn(url ...string) (*AdminServiceClient, error) {
|
|
|
|
var rpc_url string
|
|
if len(url) > 0 && url[0] != "" {
|
|
rpc_url = url[0]
|
|
} else if conf.ADMIN_RPC_URL != "" {
|
|
rpc_url = conf.ADMIN_RPC_URL
|
|
} else {
|
|
rpc_url = "127.0.0.1:" + conf.ADMIN_RPC_PORT
|
|
}
|
|
|
|
conn, _, err := DialAdminService("tcp", rpc_url)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return conn, nil
|
|
}
|