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)))
	}
}
Example #2
0
func runServer(port string) {
	// Set processor
	rpc.RegisterName("Thrift", &echo.EchoServer{Implementation: new(echoHandler)})
	ln, _ := net.Listen("tcp", port)

	for {
		conn, _ := ln.Accept()
		go func(c net.Conn) {
			t := thrift.NewTransport(thrift.NewFramedReadWriteCloser(c, 0), thrift.BinaryProtocol)
			rpc.ServeCodec(thrift.NewServerCodec(t))
		}(conn)
	}
}
Example #3
0
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)))
	}
}