func main() { scribeService := new(scribeServiceImplementation) rpc.RegisterName("Thrift", &scribe.ScribeServer{Implementation: scribeService}) flag.IntVar(&port, "p", 1463, "Scribe Listen Port") flag.StringVar(&kafka_hostname, "o", "localhost:9092", "host:port string for the kafka server") flag.IntVar(&partition, "r", 1, "partition to publish to") flag.IntVar(&buffer_size, "s", 10, "Buffer Size") flag.IntVar(&buffer_time, "t", 10, "Buffer Time") flag.Parse() fmt.Printf("Quiet! I'm trying to listen to port %d and send to kafka at %s", port, kafka_hostname) ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { log.Println(err) } for { conn, err := ln.Accept() if err != nil { fmt.Printf("ERROR: %+v\n", err) continue } fmt.Printf("New connection %+v\n", conn) go rpc.ServeCodec(thrift.NewServerCodec(thrift.NewFramedReadWriteCloser(conn, 0), thrift.NewBinaryProtocol(true, false))) } }
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) }
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) }
func main() { scribeService := new(scribeServiceImplementation) rpc.RegisterName("Thrift", &scribe.ScribeServer{scribeService}) ln, err := net.Listen("tcp", ":1463") if err != nil { panic(err) } for { conn, err := ln.Accept() if err != nil { fmt.Printf("ERROR: %+v\n", err) continue } fmt.Printf("New connection %+v\n", conn) go rpc.ServeCodec(thrift.NewServerCodec(thrift.NewFramedReadWriteCloser(conn, 0), thrift.NewBinaryProtocol(true, false))) } }
func newRpcClient(url string) *rpc.Client { return thrift.NewClient(NewTHttpClientTransport(url), thrift.NewBinaryProtocol(false, true), false) }