Exemple #1
0
func main() {

	client, err := proxy.NewWithDefaultConfig().ServantByAddr(":9001")
	if err != nil {
		panic(err)
	}
	defer client.Recycle()

	ctx := rpc.NewContext()
	ctx.Reason = "go.duplex"
	ctx.Rid = 189
	for i := 0; i < 10; i++ {
		go func() {
			t1 := time.Now()
			r, err := client.Ping(ctx)
			if err != nil {
				log.Println(err)
			} else {
				log.Println(r, time.Since(t1))
			}

		}()
	}

	<-make(chan struct{})
}
Exemple #2
0
func main() {
	proxy := proxy.NewWithDefaultConfig()
	if host == "" {
		pingCluster(proxy)
		return
	}

	// ping a single faed
	client, err := proxy.ServantByAddr(host + ":" + port)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer client.Recycle()

	ctx := rpc.NewContext()
	ctx.Reason = REASON
	ctx.Rid = time.Now().UnixNano()
	pong, err := client.Ping(ctx)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(pong)
	}

}
Exemple #3
0
func main() {
	t1 := time.Now()

	client, err := proxy.NewWithDefaultConfig().ServantByAddr(":9001")
	if err != nil {
		panic(err)
	}
	defer client.Recycle()

	ctx := rpc.NewContext()
	ctx.Reason = "gotest"
	ctx.Rid = 189
	for i := 0; i < 10; i++ {
		r, err := client.Ping(ctx)
		if err != nil {
			panic(err)
		}

		fmt.Println(r, time.Since(t1))
		t1 = time.Now()
	}

}