コード例 #1
0
ファイル: example.go プロジェクト: tradia/gotable
func testAsync(tc *table.Context) {
	//var done = make(chan *table.Call, 2)
	c1, err := tc.GoScan(1, []byte("row1"), true, 10, nil)
	if err != nil {
		fmt.Printf("GoScan failed: %s\n", err)
		return
	}

	c2, err := tc.GoZScan(1, []byte("row2"), true, true, 10, nil)
	if err != nil {
		fmt.Printf("GoZScan failed: %s\n", err)
		return
	}

	// Wait for reply
	<-c1.Done
	<-c2.Done

	r1, err := c1.Reply()
	if err != nil {
		fmt.Printf("Reply failed: %s\n", err)
		return
	} else {
		fmt.Println("ASYNC C1 result:")
		printScanReply(r1.(table.ScanReply))
	}

	r2, err := c2.Reply()
	if err != nil {
		fmt.Printf("Reply failed: %s\n", err)
		return
	} else {
		fmt.Println("ASYNC C2 result:")
		printScanReply(r2.(table.ScanReply))
	}
}