Beispiel #1
0
func main() {
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	serverTransport, err := thrift.NewTServerSocket(NetworkAddr)
	if err != nil {
		log.Printf("NewTServerSocket error: %v\n", err)
		return
	}

	processor := translate.NewProxyTransProcessor(&proxyTrans{})
	server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
	log.Println(server.Serve())
}
Beispiel #2
0
func NewPhonebookServer(host string) *PhonebookServer {
    handler := NewContactHandler()
    processor := contact.NewContactSvcProcessor(handler)
    transport, err := thrift.NewTServerSocket(host)
    if err != nil {
        panic(err)
    }

    transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
    protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
    server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
    return &PhonebookServer{
        host:             host,
        handler:          handler,
        processor:        processor,
        transport:        transport,
        transportFactory: transportFactory,
        protocolFactory:  protocolFactory,
        server:           server,
    }
}
Beispiel #3
0
func NewEchoServer(host string) *EchoServer {
	handler := NewEchoHandler()
	processor := NewEchoSrvProcessor(handler)
	transport, err := thrift.NewTServerSocket(host)
	if err != nil {
		panic(err)
	}

	transportFactory := thrift.NewTTransportFactory()
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
	return &EchoServer{
		host:             host,
		handler:          handler,
		processor:        processor,
		transport:        transport,
		transportFactory: transportFactory,
		protocolFactory:  protocolFactory,
		server:           server,
	}
}