當前位置: 首頁>>代碼示例>>Golang>>正文


Golang thrift.NewTSimpleServer4函數代碼示例

本文整理匯總了Golang中git/apache/org/thrift/git/lib/go/thrift.NewTSimpleServer4函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewTSimpleServer4函數的具體用法?Golang NewTSimpleServer4怎麽用?Golang NewTSimpleServer4使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewTSimpleServer4函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: runServer

func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
	var transport thrift.TServerTransport
	var err error
	if secure {
		cfg := new(tls.Config)
		if cert, err := tls.LoadX509KeyPair("server.crt", "server.key"); err == nil {
			cfg.Certificates = append(cfg.Certificates, cert)
		} else {
			return err
		}
		transport, err = thrift.NewTSSLServerSocket(addr, cfg)
	} else {
		transport, err = thrift.NewTServerSocket(addr)
	}

	if err != nil {
		return err
	}
	fmt.Printf("%T\n", transport)
	handler := NewCalculatorHandler()
	processor := tutorial.NewCalculatorProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)

	fmt.Println("Starting the simple server... on ", addr)
	return server.Serve()
}
開發者ID:gembler,項目名稱:blade-libs,代碼行數:26,代碼來源:server.go

示例2: Export

func (t *ThriftExporter) Export(serviceName string, processor thrift.TProcessor) (err error) {
	var transport thrift.TServerTransport
	if t.Config.Secure {
		cfg := new(tls.Config)
		if cert, err := tls.LoadX509KeyPair(t.Config.CertFile, t.Config.KeyFile); err == nil {
			cfg.Certificates = append(cfg.Certificates, cert)
		} else {
			return err
		}
		transport, err = thrift.NewTSSLServerSocket(t.Provider.Addr, cfg)
	} else {
		transport, err = thrift.NewTServerSocket(t.Provider.Addr)
	}

	if err != nil {
		return err
	}
	server := thrift.NewTSimpleServer4(processor, transport, t.Config.TransFactory, t.Config.ProtocolFactory)

	err = t.Reg.Register(serviceName, t.Provider)
	if err != nil {
		fmt.Println("error when register service", err.Error())
		return
	}
	fmt.Println("Starting the simple server... on ", t.Provider.Addr)
	return server.Serve()
}
開發者ID:allenma,項目名稱:gosoa,代碼行數:27,代碼來源:thrift.go

示例3: NewHbaseServer

// NewHbaseServer starts an self-implementation hbase
func NewHbaseServer(hb Hbase) (*TestServer, error) {

	port, _ := GetPort()
	addr := fmt.Sprintf(":%d", port)

	// fork a goroutine to serve requests
	var transportFactory thrift.TTransportFactory
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory = thrift.NewTBufferedTransportFactory(8192)
	transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
	transport, err := thrift.NewTServerSocket(addr)
	if err != nil {
		log.Fatal(err)
	}
	srv := thrift.NewTSimpleServer4(
		NewHbaseProcessor(hb),
		transport,
		transportFactory,
		protocolFactory,
	)
	if err := srv.Listen(); err != nil {
		log.Fatal(err)
	}
	go srv.AcceptLoop()

	// TODO: stop server when stop chan is closed
	return &TestServer{
		Port: port,
		stop: make(chan struct{}),
	}, nil
}
開發者ID:csigo,項目名稱:hbase,代碼行數:32,代碼來源:inmem.go

示例4: runServer

func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string, secure bool) error {
	var transport thrift.TServerTransport
	var err error
	transport, err = thrift.NewTServerSocket(addr)
	if err != nil {
		return err
	}
	fmt.Printf("Transport: %T\n", transport)

	handler := NewAwesomeServiceHandler()

	SharedTypes = awesome_service.NewTypes()
	var f float64 = 1
	b := true
	s := "A"
	SharedTypes.ShortValue = 1
	SharedTypes.IntValue = 1
	SharedTypes.LongValue = 1
	SharedTypes.DoubleValue = &f
	SharedTypes.BoolValue = &b
	SharedTypes.StringValue = &s
	SharedTypes.ListValue = []string{"A"}
	SharedTypes.SetValue = map[string]bool{"A": true}
	SharedTypes.MapValue = make(map[string]int32)
	// var i int32
	for i := 0; i < 50000; i++ {
		SharedTypes.MapValue[strconv.Itoa(i)] = int32(i)
	}

	processor := awesome_service.NewAwesomeServiceProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)

	fmt.Println("Starting the simple server... on ", addr)
	return server.Serve()
}
開發者ID:y-okubo,項目名稱:thrift-test,代碼行數:35,代碼來源:main.go

示例5: Serve

// Serve starts service for the given Computation.
//
// Must be called from main() function of worker.
func Serve(comp Computation) error {
	bindAddr := os.Getenv(bolt.KConcordEnvKeyClientListenAddr)
	proxyAddr := os.Getenv(bolt.KConcordEnvKeyClientProxyAddr)

	// Init transport
	transport, err := thrift.NewTServerSocket(bindAddr)
	if err != nil {
		panic("failed to create server")
	}
	factory := thrift.NewTTransportFactory()
	transportF := thrift.NewTFramedTransportFactory(factory)

	protocolF := thrift.NewTBinaryProtocolFactoryDefault()

	proxy, err := newProxy(proxyAddr, comp.Metadata())
	if err != nil {
		panic("failed to initialize proxy")
	}

	service := newComputationService(comp, proxy)

	processor := bolt.NewComputationServiceProcessor(service)

	srv := thrift.NewTSimpleServer4(processor, transport, transportF, protocolF)
	return srv.Serve()
}
開發者ID:concord,項目名稱:concord-go,代碼行數:29,代碼來源:server.go

示例6: runDummyFlumeAgent

// run a test flume agent
func runDummyFlumeAgent(t *testing.T) {
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTCompactProtocolFactory()
	transport, _ := thrift.NewTServerSocket("localhost:51515")

	handler := thriftSourceProtocolHandler{t}
	processor := flume.NewThriftSourceProtocolProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
	server.Serve()
}
開發者ID:ceocoder,項目名稱:glumelogger,代碼行數:11,代碼來源:glumelogger_test.go

示例7: main

func main() {
	dcacheHandler := NewDcacheHandler()
	dcacheServiceProcessor := dcache.NewDcacheServiceProcessor(dcacheHandler)
	ssock, err := thrift.NewTServerSocket("127.0.0.1:9090")
	if err != nil {
		panic("Problem in creating transport")
	}
	server := thrift.NewTSimpleServer4(dcacheServiceProcessor, ssock,
		thrift.NewTBufferedTransportFactory(204800), thrift.NewTBinaryProtocolFactoryDefault())
	server.Serve()
}
開發者ID:nipuntalukdar,項目名稱:NipunTalukdarExamples,代碼行數:11,代碼來源:dcache_server.go

示例8: runServer

func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string) error {
	transport, err := thrift.NewTServerSocket(addr)
	if err != nil {
		return err
	}
	handler := NewCalculatorHandler()
	processor := tutorial.NewCalculatorProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)

	fmt.Println("Starting the simple server... on ", transport.Addr())
	return server.Serve()
}
開發者ID:Rheeseyb,項目名稱:thrift,代碼行數:12,代碼來源:server.go

示例9: main

func main() {
	handler := NewCoffeeOrderHandler()
	processor := co.NewCoffeeOrderProcessor(handler)
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory := thrift.NewTTransportFactory()
	serverTransport, err := thrift.NewTServerSocket("0.0.0.0:9090")
	if err != nil {
		log.Println(err)
	}
	server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
	server.Serve()
}
開發者ID:RobWC,項目名稱:thrift-coffee,代碼行數:12,代碼來源:coffee_server.go

示例10: main

func main() {
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transport, err := thrift.NewTServerSocket("localhost:8090")
	if err != nil {
		fmt.Printf("There was an error creating your socket! Here it is %v", err)
	}
	transportFactory := thrift.NewTTransportFactory()
	processor := service.NewMakeTagsProcessor(handler.NewTagsHandler(os.Getenv("ACCESS_TOKEN")))
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
	fmt.Printf("server listening on %s\n", "localhost:8090")
	server.Serve()
}
開發者ID:faiq,項目名稱:intro-to-rpc,代碼行數:12,代碼來源:server.go

示例11: launchRpcServe

func (this *Engine) launchRpcServe() (done chan interface{}) {
	var protocolFactory thrift.TProtocolFactory
	switch this.conf.rpc.protocol {
	case "binary":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()

	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()

	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()

	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()

	default:
		panic(fmt.Sprintf("Invalid protocol: %s", this.conf.rpc.protocol))
	}

	transportFactory := thrift.NewTTransportFactory()
	if this.conf.rpc.framed {
		transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
	}

	serverTransport, err := thrift.NewTServerSocketTimeout(this.conf.rpc.listenAddr,
		this.conf.rpc.clientTimeout)
	if err != nil {
		panic(err)
	}

	this.rpcServer = thrift.NewTSimpleServer4(this.rpcProcessor,
		serverTransport, transportFactory, protocolFactory)
	log.Info("RPC server ready at %s", this.conf.rpc.listenAddr)

	done = make(chan interface{})
	go func() {
		for {
			err = this.rpcServer.Serve()
			if err != nil {
				log.Error(err)
				break
			}
		}

		done <- 1

	}()

	return done
}
開發者ID:jlyt898,項目名稱:fae,代碼行數:50,代碼來源:rpc.go

示例12: main

func main() {
	transport, err := thrift.NewTServerSocket("localhost:3636")
	if err != nil {
		panic(err)
	}

	proc := hello.NewHelloProcessor(&HelloHandler{})
	server := thrift.NewTSimpleServer4(
		proc,
		transport,
		thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory()),
		thrift.NewTBinaryProtocolFactoryDefault())

	println(server.Serve())
}
開發者ID:sayden,項目名稱:thrift-minimal-example,代碼行數:15,代碼來源:server.go

示例13: startRpcServe

func startRpcServe(port string) {
	socket, err := thrift.NewTServerSocketTimeout(fmt.Sprintf(":%s", port), TIMEOUT)
	if err != nil {
		log.Fatalln("Unable to create server socket", err)
	}

	protocol := thrift.NewTBinaryProtocolFactoryDefault()
	transport := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	processor := thrift.NewTMultiplexedProcessor()

	registerProcessors(processor)

	server := thrift.NewTSimpleServer4(processor, socket, transport, protocol)
	server.Serve()
}
開發者ID:citysir,項目名稱:webbase,代碼行數:15,代碼來源:rpc.go

示例14: main

func main() {
	var protocolFactory thrift.TProtocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
	var transportFactory thrift.TTransportFactory = thrift.NewTBufferedTransportFactory(8192)
	transport, err := thrift.NewTServerSocket(NetworkAddr)
	if err != nil {
		fmt.Println("Error!", err)
		os.Exit(1)
	}

	handler := NewGreeterHandler()
	processor := greeter.NewGreeterProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
	fmt.Println("Starting the simple server... on ", NetworkAddr)
	server.Serve()
}
開發者ID:smallnest,項目名稱:RPC-TEST,代碼行數:15,代碼來源:main.go

示例15: main

func main() {
	var listen string = ":10001"

	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	serverTransport, err := thrift.NewTServerSocket(listen)
	if err != nil {
		fmt.Println("error, thrift init!")
		return
	}
	handler := &Puller{0}
	processor := puller.NewPullerProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
	fmt.Printf("server started\n")
	server.Serve()
}
開發者ID:visilicon,項目名稱:thrift-go,代碼行數:16,代碼來源:main.go


注:本文中的git/apache/org/thrift/git/lib/go/thrift.NewTSimpleServer4函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。