• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang thrift.NewTServerSocket函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中git/apache/org/thrift/git/lib/go/thrift.NewTServerSocket函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTServerSocket函数的具体用法?Golang NewTServerSocket怎么用?Golang NewTServerSocket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewTServerSocket函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: 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


示例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: 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


示例4: 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


示例5: 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


示例6: Run

//
// 两参数是必须的:  ProductName, zkAddress, frontAddr可以用来测试
//
func (p *ProxyServer) Run() {

	var transport thrift.TServerTransport
	var err error

	log.Printf(Magenta("Start Proxy at Address: %s"), p.proxyAddr)
	// 读取后端服务的配置
	isUnixDomain := false
	if !strings.Contains(p.proxyAddr, ":") {
		if FileExist(p.proxyAddr) {
			os.Remove(p.proxyAddr)
		}
		transport, err = NewTServerUnixDomain(p.proxyAddr)
		isUnixDomain = true
	} else {
		transport, err = thrift.NewTServerSocket(p.proxyAddr)
	}
	if err != nil {
		log.ErrorErrorf(err, "Server Socket Create Failed: %v, Front: %s", err, p.proxyAddr)
	}

	// 开始监听
	//	transport.Open()
	transport.Listen()

	ch := make(chan thrift.TTransport, 4096)
	defer close(ch)

	go func() {
		var address string
		for c := range ch {
			// 为每个Connection建立一个Session
			socket, ok := c.(SocketAddr)
			if isUnixDomain {
				address = p.proxyAddr
			} else if ok {
				address = socket.Addr().String()
			} else {
				address = "unknow"
			}
			x := NewSession(c, address, p.verbose)
			// Session独立处理自己的请求
			go x.Serve(p.router, 1000)
		}
	}()

	// Accept什么时候出错,出错之后如何处理呢?
	for {
		c, err := transport.Accept()
		if err != nil {
			log.ErrorErrorf(err, "Accept Error: %v", err)
			break
		} else {
			ch <- c
		}
	}
}
开发者ID:jinhy,项目名称:rpc_proxy,代码行数:60,代码来源:server_proxy.go


示例7: 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


示例8: 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


示例9: runServer

func runServer(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory, addr string) error {
	transport, err = thrift.NewTServerSocket(addr) //simple case
	if err != nil {
		return err
	}
	handler := &dataServiceProcessorPull{}
	processor := crawler.NewDataServiceProcessor(handler)
	server := thrift.NewTSimpleServer(processor, transport, transportFactory, protocolFactory)
	fmt.Println("Starting the simple server... on ", transport.Addr())
	server.serve()
}
开发者ID:tuhao,项目名称:Thrift4AsyncMsg,代码行数:11,代码来源:server.go


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例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: New

func New(addr string, processor *thrift.TProcessor) (*Server, error) {
	// Instantiate the thrift server components
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
	transportFactory := thrift.NewTTransportFactory()
	transport, err := thrift.NewTServerSocket(addr)
	if err != nil {
		return nil, err
	}

	wait := make(chan error)

	s := Server{Addr: addr, wait: wait, Wait: wait}
	s.server = thrift.NewTSimpleServer4(*processor, transport, transportFactory, protocolFactory)

	return &s, nil
}
开发者ID:karmakaze,项目名称:ruby-go-thrift,代码行数:16,代码来源:server.go


示例16: runServer

func runServer(listenIp *string, listenPort *int, backendIp *string, backendPort *int, debug *bool) error {
	transport, err := thrift.NewTServerSocket(fmt.Sprintf("%s:%d", *listenIp, *listenPort))
	if err != nil {
		return err
	}

	transportFactory := thrift.NewTTransportFactory()
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()

	handler := NewDataStoreHandler(backendIp, backendPort, debug)
	processor := messages.NewDataStoreProcessor(handler)
	server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)

	logger.Printf("Thrift Service configured")
	return server.Serve()
}
开发者ID:jamwyatt,项目名称:ServicesWebThriftEtcd,代码行数:16,代码来源:backEndProcessor.go


示例17: 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


示例18: main

func main() {
	handler := &HelloServiceImpl{}
	processor := hello.NewHelloServiceProcessor(handler)

	listenSocket, err := thrift.NewTServerSocket(":8787")
	if err != nil {
		panic(err)
	}

	server := thrift.NewTSimpleServer2(processor, listenSocket)
	fmt.Println("Server ready")

	if err := server.Serve(); err != nil {
		panic(err)
	}
}
开发者ID:xinghuwang,项目名称:toolbox,代码行数:16,代码来源:hello_server.go


示例19: runThriftServer

func runThriftServer(host string, port int, protocol string, framed bool, buffered bool, workerId uint64, datacenterId uint64) {
	var protocolFactory thrift.TProtocolFactory
	switch protocol {
	case "compact":
		protocolFactory = thrift.NewTCompactProtocolFactory()
	case "simplejson":
		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
	case "json":
		protocolFactory = thrift.NewTJSONProtocolFactory()
	case "binary", "":
		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
	default:
		fmt.Fprint(os.Stderr, "Invalid protocol specified", protocol, "\n")
		Usage()
		os.Exit(1)
	}

	var transportFactory thrift.TTransportFactory
	if buffered {
		transportFactory = thrift.NewTBufferedTransportFactory(8192)
	} else {
		transportFactory = thrift.NewTTransportFactory()
	}

	if framed {
		transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
	}

	var err error
	var transport thrift.TServerTransport
	transport, err = thrift.NewTServerSocket(fmt.Sprintf("%s:%d", host, port))
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	worker, err := idworker.NewIdWorker(workerId, datacenterId)

	processor := snowflake.NewSnowflakeProcessor(worker)

	if err == nil {
		server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
		server.Serve()
	} else {
		log.Fatal(err)
	}
}
开发者ID:vonwenm,项目名称:gosnowflake-1,代码行数:47,代码来源:thriftserver.go


示例20: runFakeRender

func runFakeRender(addr string) {
	var tTS fakeRender
	processor := gopnikrpc.NewRenderProcessor(&tTS)

	transport, err := thrift.NewTServerSocket(addr)
	if err != nil {
		panic(err)
	}
	transportFactory := thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory())
	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()

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

	if err = server.Serve(); err != nil {
		panic(err)
	}
}
开发者ID:mikhailborodin,项目名称:gopnik,代码行数:17,代码来源:renderselector_test.go



注:本文中的git/apache/org/thrift/git/lib/go/thrift.NewTServerSocket函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang thrift.NewTSimpleJSONProtocolFactory函数代码示例发布时间:2022-05-24
下一篇:
Golang thrift.NewTMemoryBufferLen函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap