本文整理汇总了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")
}
示例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)
}
示例3: main
func main() {
flag.Parse()
rpc.Register(server)
rpc.HandleHTTP()
http.HandleFunc("/", Static)
http.HandleFunc("/get", Get)
http.ListenAndServe(*listenAddr, nil)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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
}
示例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)
}
示例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
}
示例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)
}
示例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
}
示例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")
}
示例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")
}