當前位置: 首頁>>代碼示例>>Golang>>正文


Golang net.ParseNetwork函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。