本文整理汇总了Golang中github.com/Terry-Mao/goim/libs/net.ParseNetwork函数的典型用法代码示例。如果您正苦于以下问题:Golang ParseNetwork函数的具体用法?Golang ParseNetwork怎么用?Golang ParseNetwork使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ParseNetwork函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: InitRouter
func InitRouter() (err error) {
var (
network, addr string
)
routerRing = ketama.NewRing(ketama.Base)
for serverId, addrs := range Conf.RouterRPCAddrs {
// WARN r must every recycle changed for reconnect
var (
r *rpc.Client
routerQuit = make(chan struct{}, 1)
)
if network, addr, err = inet.ParseNetwork(addrs); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
r, err = rpc.Dial(network, addr)
if err != nil {
log.Error("rpc.Dial(\"%s\", \"%s\") error(%s)", network, addr, err)
}
go rpc.Reconnect(&r, routerQuit, network, addr)
log.Debug("router rpc addr:%s connect", addr)
routerServiceMap[serverId] = &r
routerRing.AddNode(serverId, 1)
}
routerRing.Bake()
return
}
开发者ID:nevermatch,项目名称:goim,代码行数:27,代码来源:router.go
示例2: InitCometRpc
func InitCometRpc(addrs map[int32]string) (err error) {
for serverID, addrs := range addrs {
var (
rpcClient *protorpc.Client
quit chan struct{}
network, addr string
)
if network, addr, err = inet.ParseNetwork(addrs); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
rpcClient, err = protorpc.Dial(network, addr)
if err != nil {
log.Error("protorpc.Dial(\"%s\") error(%s)", addr, err)
return
}
go protorpc.Reconnect(&rpcClient, quit, network, addr)
log.Info("rpc addr:%s connected", addr)
cometServiceMap[serverID] = &rpcClient
}
return
}
开发者ID:huweixuan,项目名称:goim,代码行数:25,代码来源:comet.go
示例3: InitLogicRpc
func InitLogicRpc(addrs string) (err error) {
var network, addr string
if network, addr, err = inet.ParseNetwork(addrs); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
logicRpcClient, err = protorpc.Dial(network, addr)
if err != nil {
log.Error("rpc.Dial(\"%s\", \"%s\") error(%s)", network, addr, err)
}
go protorpc.Reconnect(&logicRpcClient, logicRpcQuit, network, addr)
log.Debug("logic rpc addr %s:%s connected", network, addr)
return
}
开发者ID:hudangwei,项目名称:goim,代码行数:14,代码来源:logic.go
示例4: InitHTTPPush
func InitHTTPPush() (err error) {
var network, addr string
for i := 0; i < len(Conf.HTTPPushAddrs); i++ {
httpServeMux := http.NewServeMux()
httpServeMux.HandleFunc("/1/push", Push)
log.Info("start http push listen:\"%s\"", Conf.HTTPPushAddrs[i])
if network, addr, err = inet.ParseNetwork(Conf.HTTPPushAddrs[i]); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
go httpListen(httpServeMux, network, addr)
}
return
}
开发者ID:huweixuan,项目名称:goim,代码行数:14,代码来源:http_push.go
示例5: InitRPC
func InitRPC(auther Auther) (err error) {
var (
network, addr string
c = &RPC{auther: auther}
)
rpc.Register(c)
for i := 0; i < len(Conf.RPCAddrs); i++ {
log.Info("start listen rpc addr: \"%s\"", Conf.RPCAddrs[i])
if network, addr, err = inet.ParseNetwork(Conf.RPCAddrs[i]); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
go rpcListen(network, addr)
}
return
}
开发者ID:1d7500,项目名称:goim,代码行数:16,代码来源:rpc.go
示例6: InitRPC
func InitRPC(bs []*Bucket) (err error) {
var (
network, addr string
c = &RouterRPC{Buckets: bs, BucketIdx: int64(len(bs))}
)
rpc.Register(c)
for i := 0; i < len(Conf.RPCAddrs); i++ {
log.Info("start listen rpc addr: \"%s\"", Conf.RPCAddrs[i])
if network, addr, err = inet.ParseNetwork(Conf.RPCAddrs[i]); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
go rpcListen(network, addr)
}
return
}
开发者ID:james4e,项目名称:goim,代码行数:16,代码来源:rpc.go
示例7: InitRPCPush
func InitRPCPush(addrs []string) (err error) {
var (
bind string
network, addr string
c = &PushRPC{}
)
rpc.Register(c)
for _, bind = range addrs {
if network, addr, err = inet.ParseNetwork(bind); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
go rpcListen(network, addr)
}
return
}
开发者ID:dulumao,项目名称:goim,代码行数:16,代码来源:rpc.go
示例8: InitHTTP
func InitHTTP() (err error) {
// http listen
var network, addr string
for i := 0; i < len(Conf.HTTPAddrs); i++ {
httpServeMux := http.NewServeMux()
httpServeMux.HandleFunc("/1/push", Push)
httpServeMux.HandleFunc("/1/pushs", Pushs)
httpServeMux.HandleFunc("/1/push/all", PushAll)
httpServeMux.HandleFunc("/1/server/del", DelServer)
httpServeMux.HandleFunc("/1/count", Count)
log.Info("start http listen:\"%s\"", Conf.HTTPAddrs[i])
if network, addr, err = inet.ParseNetwork(Conf.HTTPAddrs[i]); err != nil {
log.Error("inet.ParseNetwork() error(%v)", err)
return
}
go httpListen(httpServeMux, network, addr)
}
return
}
开发者ID:dulumao,项目名称:goim,代码行数:19,代码来源:http.go
注:本文中的github.com/Terry-Mao/goim/libs/net.ParseNetwork函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论