コード例 #1
0
func main() {
	flag.IntVar(&port, "p", 1463, "Scribe Port")
	flag.IntVar(&count, "c", 100, "Test messages")
	flag.StringVar(&host, "h", "localhost", "Scribe Host")
	flag.StringVar(&category, "c", "category", "Scribe Category")
	flag.Parse()
	message, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	fmt.Println(os.Args)
	conn, err := net.Dial("tcp", fmt.Sprintf("%s:1463", host))
	if err != nil {
		panic(err)
	}

	client := thrift.NewClient(thrift.NewFramedReadWriteCloser(conn, 0), thrift.NewBinaryProtocol(true, false), false)
	scr := scribe.ScribeClient{Client: client}
	arr := make([]*scribe.LogEntry, count)
	for i := 0; i < count; i++ {
		arr[i] = &scribe.LogEntry{category, string(message)}
	}
	res, err := scr.Log(arr)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Response: %+v\n", res)
}
コード例 #2
0
ファイル: main.go プロジェクト: xianxu/go-thrift
func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:1463")
	if err != nil {
		panic(err)
	}

	client := thrift.NewClient(thrift.NewFramedReadWriteCloser(conn, 0), thrift.NewBinaryProtocol(true, false))
	scr := scribe.ScribeClient{client}
	res, err := scr.Log([]*scribe.LogEntry{{"category", "message"}})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Response: %+v\n", res)
}