示例#1
0
func init() {
	// init server
	server = phonebook.NewPhonebookServer(TEST_HOST)

	// init client
	socket, err := thrift.NewTSocket(TEST_HOST)
	if err != nil {
		panic(err)
	}

	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transport := transportFactory.GetTransport(socket)
	client = contact.NewContactSvcClientFactory(transport, protocolFactory)

	// run server
	go server.Run()

	// run client
	time.Sleep(2 * time.Second) // wait for server
	if err := client.Transport.Open(); err != nil {
		panic(err)
	}
}
示例#2
0
func main() {
	host := "localhost:9090"
	server := phonebook.NewPhonebookServer(host)
	server.Run()
}