Documentation ¶
Overview ¶
http server library.
log provides log api. thanks to the helpful log tool logrus(https://github.com/Sirupsen/logrus)
RPCClient implements a rpc client tool with reconnect and load balance.
rpc server
package server provides service interfaces and libraries. including: tcp/http server library. rpc service library with addon functionality. service discory and registration Logic. statistic lib.
tcp server library.
Index ¶
- Constants
- Variables
- func GetRPCHost() string
- func GetServerHosts(serverName string, hostType string) ([]string, error)
- func Init(name string) error
- func RPCCallByHost(host string, serverMethod string, args interface{}, reply interface{}) error
- func RPCCallByName(serverName string, serverMethod string, args interface{}, reply interface{}) error
- func RegisterHTTPHandler(handler http.Handler) error
- func RegisterRPCHandler(rcvr interface{}) error
- func RegisterTCPHandler(handler TCPHandler) error
- func RegisterTimerTask(task TimerTask) error
- func Run() error
- type HTTPServer
- type RPCClient
- type RPCServer
- type Server
- type ServerManager
- type TCPHandler
- type TCPServer
- type TimerTask
Constants ¶
const ( FlagTCPHost = "tcphost" FlagUseTls = "usetls" FlagHTTPHost = "httphost" FlagUseHttps = "usehttps" FlagCAFile = "cafile" FlagKeyFile = "keyfile" FlagRPCHost = "rpchost" FlagEtcd = "etcd" FlagLogLevel = "loglevel" )
const ( EtcdServersPrefix = "/pando/servers/" EtcdServersPrefixCnt = 2 )
Variables ¶
var ( InternalIP string ExternalIP string )
var Log *logrus.Entry
Functions ¶
func GetServerHosts ¶
get server's hosts by server name and service type
func RPCCallByHost ¶
rpc call by host
func RPCCallByName ¶
func RPCCallByName(serverName string, serverMethod string, args interface{}, reply interface{}) error
rpc call by name
func RegisterHTTPHandler ¶
register HTTP handler class
func RegisterRPCHandler ¶
func RegisterRPCHandler(rcvr interface{}) error
register RPC handler class
func RegisterTCPHandler ¶
func RegisterTCPHandler(handler TCPHandler) error
register TCP handler class
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func (*HTTPServer) Start ¶
func (hs *HTTPServer) Start() error
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func NewRPCClient ¶
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
func NewServerManager ¶
func NewServerManager(name string, etcd string) (*ServerManager, error)
etcd hosts is config as http://ip1:port1;http://ip2:port2;http://ip3:port3
func (*ServerManager) GetServerHosts ¶
func (mgr *ServerManager) GetServerHosts(serverName string, hostType string) ([]string, error)
get host ips for the server, now return all hosts
func (*ServerManager) RegisterServer ¶
func (mgr *ServerManager) RegisterServer() error
register server to etcd
func (*ServerManager) UpdateServerHosts ¶
func (mgr *ServerManager) UpdateServerHosts() error
update server hosts