当前位置: 首页>>代码示例>>Golang>>正文


Golang rpc.Register函数代码示例

本文整理汇总了Golang中rpc.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	log.Println("Starting Server")

	arith := new(Arith)
	rpc.Register(arith)

	rpc.Register(&Server{})

	go serveUDP(":1234")
	go serveTCP(":1234")
	go serveTLS(":1235")
	serveHTTP(":1236")
}
开发者ID:nathankerr,项目名称:negotiation,代码行数:13,代码来源:server.go

示例2: main

func main() {

	// Pull in command line options or defaults if none given
	flag.Parse()

	f, err := os.OpenFile(*skylib.LogFileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
	if err == nil {
		defer f.Close()
		log.SetOutput(f)
	}

	skylib.Setup(sName)

	r := NewGetUserDataService()

	rpc.Register(r)

	rpc.HandleHTTP()

	portString := fmt.Sprintf("%s:%d", *skylib.BindIP, *skylib.Port)

	l, e := net.Listen("tcp", portString)
	if e != nil {
		log.Fatal("listen error:", e)
	}

	log.Println("Starting server")
	http.Serve(l, nil)

}
开发者ID:paulbellamy,项目名称:skynet,代码行数:30,代码来源:service.go

示例3: main

func main() {
	flag.Parse()
	rpc.Register(server)
	rpc.HandleHTTP()
	http.HandleFunc("/", Static)
	http.HandleFunc("/get", Get)
	http.ListenAndServe(*listenAddr, nil)
}
开发者ID:andradeandrey,项目名称:stat,代码行数:8,代码来源:stats.go

示例4: main

func main() {
	arith := new(arith.Arith)
	rpc.Register(arith)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Exit("listen error: ", e)
	}
	http.Serve(l, nil)
}
开发者ID:tokuhirom,项目名称:go-examples,代码行数:10,代码来源:server.go

示例5: server

func server() {
	ps := new(ProcessStarter)
	rpc.Register(ps)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Exit("listen error:", e)
	}
	go http.Serve(l, nil)
}
开发者ID:psychobob666,项目名称:MediaEncodingCluster,代码行数:10,代码来源:mainrpc.go

示例6: RunServer

func RunServer(addr string) {
	self := new(Server).Init()
	rpc.Register(self)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", addr)
	if e != nil {
		log.Exit("listen error: ", e)
	}
	http.Serve(l, nil)
}
开发者ID:ike-dai,项目名称:go-simple-kvs,代码行数:10,代码来源:kvs.go

示例7: main

//Starts the server
func main() {
	md := NewMatrixDatabase()
	rpc.Register(md)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
}
开发者ID:Altece,项目名称:Go-Go-Gadget-Repo,代码行数:11,代码来源:matrixserver.go

示例8: main

func main() {
	flag.Parse()
	t := &LunchTracker{NewPoll()}
	rpc.Register(t)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", ":"+strconv.Uitoa(*port))
	if e != nil {
		log.Exit("listen error:", e)
	}
	http.Serve(l, nil)
}
开发者ID:PrincessJessie,项目名称:Go2Lunch,代码行数:11,代码来源:server.go

示例9: NewRpcService

func NewRpcService(sig interface{}) *RpcService {
	////star_name := reflect.TypeOf(sig).String())
	type_name := reflect.Indirect(reflect.ValueOf(sig)).Type().Name()
	rpc.Register(sig)
	r := &RpcService{
		Port:      *Port,
		IPAddress: *BindIP,
		Provides:  type_name,
		Protocol:  strings.ToLower(*Protocol),
	}
	return r
}
开发者ID:andradeandrey,项目名称:skynet,代码行数:12,代码来源:rpcservice.go

示例10: main

func main() {
	flag.Parse()
	log.Printf("Server starting on port %d\n", *portnum)
	if *nodeID == 0 {
		rand.Seed(time.Nanoseconds())
		*nodeID = uint(rand.Uint32())
	}
	ss := storageserver.NewStorageserver(*storageMasterNodePort, *numNodes, *portnum, uint32(*nodeID))
	ts := NewTribserver(ss)
	rpc.Register(ts)
	srpc := storagerpc.NewStorageRPC(ss)
	rpc.Register(srpc)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", fmt.Sprintf(":%d", *portnum))
	if e != nil {
		log.Fatal("listen error:", e)
	}
	log.Printf("Establishing connection with storage servers")
	go ss.Connect(l.Addr())
	http.Serve(l, nil)
}
开发者ID:ahuseynov,项目名称:distTrib,代码行数:21,代码来源:server.go

示例11: run

// Start this server.
func (s *PBServer) run() error {
	logger.Info(fmt.Sprintf("Server %s is running...", s.addr))

	// Start rpc server to dispatch client's request.
	if err := rpc.Register(s, s.addr); err != nil {
		return err
	}
	s.group.Run()
	// Start heart beat.
	go s.tick()

	return nil
}
开发者ID:mlmhl,项目名称:DistributedSystemLearning,代码行数:14,代码来源:pbserver.go

示例12: main

func main() {
	flag.Parse()

	httperf := new(HTTPerf)
	rpc.Register(httperf)
	rpc.HandleHTTP()
	l, e := net.Listen("tcp", fmt.Sprintf("%s:%d", *host, *port))
	if e != nil {
		log.Fatalf("listen error:", e)
	}

	log.Printf("Now listening for requests on %s:%d", *host, *port)
	http.Serve(l, nil)
}
开发者ID:kthguru,项目名称:autohttperf,代码行数:14,代码来源:server.go

示例13: serve

func serve(configs *ConfigOpts) os.Error {
	ks := NewKeySpace(configs.ZkRootNode, configs.ZkHosts, 5e6)
	ks.Connect()
	rs := &SimpleRep{N: configs.ReplicationFactor}
	ls := NewDiskStore(configs.RootDir)
	rsf := &RemoteStoreFactory{}
	b := NewBlobStore(ks, rs, ls, rsf, configs.Port)
	rpc.Register(b)
	rpc.HandleHTTP()
	addr := fmt.Sprintf(":%d", configs.Port)
	l4g.Info("Serving on %s", addr)
	http.ListenAndServe(addr, nil)
	return nil
}
开发者ID:srijak,项目名称:blobstore,代码行数:14,代码来源:main.go

示例14: main

func main() {
	sfs := new(SFS)
	status := new(Status)
	Init(status)
	rpc.Register(sfs)
	rpc.HandleHTTP()

	l, e := net.Listen("tcp", ":1234")
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
	fmt.Println("done")
}
开发者ID:alangenfeld,项目名称:cs639,代码行数:14,代码来源:chunkServerE.go

示例15: main

func main() {
	m := new(master.Master)

	flag.Parse()

	rpc.Register(m)

	l, _ := net.Listen("tcp", ":1338")
	/*if e != nil {
		log.Fatal("listen error:", e)
	}*/
	rpc.Accept(l)
	fmt.Println("done")

}
开发者ID:alangenfeld,项目名称:cs639,代码行数:15,代码来源:runmaster.go


注:本文中的rpc.Register函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。