コード例 #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
ファイル: scribe.go プロジェクト: EverythingMe/go-pylog
func (l *ScribeLogger) connect() error {
	if l.client != nil {
		return nil
	}

	var conn net.Conn
	var err error
	//try to conect 3 times
	for reconns := 0; reconns < _MAX_RETRIES; reconns++ {
		conn, err = net.Dial("tcp", l.addr)
		if err != nil {
			if reconns >= _MAX_RETRIES-1 {
				log.Printf("ERROR: Could not connect to scribe server: %s\n", err)
				return err
			}
			time.Sleep(100 * time.Millisecond) //wait a bit before retrying
		} else {
			break
		}

	}

	transport := thrift.NewTransport(thrift.NewFramedReadWriteCloser(conn, 0), thrift.BinaryProtocol)
	client := thrift.NewClient(transport, false)
	l.client = &scribe.ScribeClient{Client: client}
	l.enabled = true
	return nil

}
コード例 #3
0
ファイル: scribe.go プロジェクト: sagar8192/fullerite
// Run runs the handler main loop
func (s *Scribe) Run() {
	server := fmt.Sprintf("%s:%d", s.endpoint, s.port)
	conn, err := net.Dial("tcp", server)

	if err != nil {
		s.log.Errorf("Failed to connect to %s. Error: %s", server, err.Error())

	} else {
		t := thrift.NewTransport(thrift.NewFramedReadWriteCloser(conn, 0), thrift.BinaryProtocol)
		client := thrift.NewClient(t, false)
		s.scribeClient = &scribe.ScribeClient{Client: client}
	}

	s.run(s.emitMetrics)
}
コード例 #4
0
ファイル: main.go プロジェクト: jimmysawczuk/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), false)
	scr := scribe.ScribeClient{Client: client}
	res, err := scr.Log([]*scribe.LogEntry{{"category", "message"}})
	if err != nil {
		panic(err)
	}

	fmt.Printf("Response: %+v\n", res)
}
コード例 #5
0
ファイル: client.go プロジェクト: ryyan/thrift-benchmark
func handleClient(addr string, num int) {
	// Open independent client connection
	conn, _ := net.Dial("tcp", addr)
	t := thrift.NewTransport(thrift.NewFramedReadWriteCloser(conn, 0), thrift.BinaryProtocol)
	client := thrift.NewClient(t, false)
	defer client.Close()
	ec := echo.EchoClient{Client: client}

	// UUID
	uid := uuid.NewV4().String()

	for i := 0; i < num; i++ {
		// Make thrift call and increment atomic count
		txt := uid + strconv.Itoa(i)
		ret, _ := ec.Echo(&echo.Message{Text: &txt})
		if txt == ret {
			atomic.AddUint64(&count, 1)
		}
	}
}
コード例 #6
0
ファイル: client.go プロジェクト: nizsheanez/evernote
func newRpcClient(url string) *rpc.Client {
	return thrift.NewClient(NewTHttpClientTransport(url), thrift.NewBinaryProtocol(false, true), false)
}