本文整理汇总了Golang中git/apache/org/thrift/git/lib/go/thrift.NewTBufferedTransportFactory函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTBufferedTransportFactory函数的具体用法?Golang NewTBufferedTransportFactory怎么用?Golang NewTBufferedTransportFactory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTBufferedTransportFactory函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
示例2: SendSms
func SendSms(msgSend string, phones_slice []int64) {
// random choice host
hosts := []string{"10.231.144.136", "10.231.144.137"}
rk := GenRandn(len(hosts))
host := hosts[rk]
port := "9090"
transport, err := thrift.NewTSocket(net.JoinHostPort(host, port))
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
transportFactory := thrift.NewTBufferedTransportFactory(10240)
protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
useTransport := transportFactory.GetTransport(transport)
client := sms.NewMessageServiceClientFactory(useTransport, protocolFactory)
if err := transport.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
defer transport.Close()
msg := sms.NewMessage()
msg.Phones = phones_slice
msg.BusinessId = 200100000
msg.Message = msgSend
client.SendMessage(msg)
}
开发者ID:dogeerf,项目名称:tool,代码行数:29,代码来源:xmail.go
示例3: main
func main() {
flag.Usage = Usage
protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)")
transport := flag.String("transport", "binary", "Specify transport (framed, buffered, file, memory, zlib)")
buffered := flag.String("buffered", "off", "Use buffered transport")
framed := flag.String("framed", "off", "Use framed transport")
addr := flag.String("addr", "localhost:9090", "Address to listen to")
secure := flag.Bool("secure", false, "Use tls secure transport")
conf_path := flag.String("conf", "nil", "配置文件路径")
flag.Parse()
if *conf_path == "nil" {
Usage()
os.Exit(1)
}
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 == "on" {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
} else {
transportFactory = thrift.NewTTransportFactory()
}
if *framed == "on" {
transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
}
//获取配置文件的路径
complete_path(conf_path)
//初始化控制层
handler.Init(*conf_path)
if err := runServer(transportFactory, *transport, protocolFactory, *addr, *secure); err != nil {
fmt.Println("error running server:", err)
}
}
开发者ID:proudlily,项目名称:Auth_ser,代码行数:58,代码来源:main.go
示例4: 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
示例5: 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
示例6: main
func main() {
flag.Usage = Usage
server := flag.Bool("server", false, "Run server")
protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)")
framed := flag.Bool("framed", false, "Use framed transport")
buffered := flag.Bool("buffered", false, "Use buffered transport")
addr := flag.String("addr", nats.DefaultURL, "NATS address to connect to")
secure := flag.Bool("secure", false, "Use tls secure transport")
flag.Parse()
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)
}
if *server {
if err := runServer(transportFactory, protocolFactory, *addr, *secure); err != nil {
fmt.Println("error running server:", err)
}
} else {
if err := runClient(transportFactory, protocolFactory, *addr, *secure); err != nil {
fmt.Println("error running client:", err)
}
}
}
开发者ID:Workiva,项目名称:thrift-nats,代码行数:48,代码来源:main.go
示例7: 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
示例8: ToFront
func ToFront(m *calendar.Message) {
flag.Usage = Usage
client := flag.Bool("client", true, "Run client")
protocol := flag.String("P1", "binary", "Specify the protocol (binary, compact, json, simplejson)")
framed := flag.Bool("framed1", false, "Use framed transport")
buffered := flag.Bool("buffered1", true, "Use buffered transport")
addr := flag.String("addr1", "localhost:9090", "Address to listen to")
secure := flag.Bool("secure1", false, "Use tls secure transport")
flag.Parse()
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)
}
if *client {
if err := runClient(transportFactory, protocolFactory, *addr, *secure, *m); err != nil {
fmt.Println("error running client:", err)
}
} else {
fmt.Println("error running client:")
}
}
开发者ID:wallacexinyu,项目名称:Distributed-Productivity-Calendar,代码行数:46,代码来源:client.go
示例9: main
func main() {
flag.Usage = Usage
// always be a client in this copy
//server := flag.Bool("server", false, "Run server")
protocol := flag.String("P", "binary", "Specify the protocol (binary, compact, json, simplejson)")
framed := flag.Bool("framed", false, "Use framed transport")
buffered := flag.Bool("buffered", false, "Use buffered transport")
addr := flag.String("addr", "localhost:9090", "Address to listen to")
secure := flag.Bool("secure", false, "Use tls secure transport")
flag.Parse()
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)
}
// always be client
fmt.Printf("*secure = '%v'\n", *secure)
fmt.Printf("*addr = '%v'\n", *addr)
if err := runClient(transportFactory, protocolFactory, *addr, *secure); err != nil {
fmt.Println("error running client:", err)
}
}
开发者ID:glycerine,项目名称:golang-thrift-minimal-example,代码行数:46,代码来源:main.go
示例10: startThriftServer
func startThriftServer() {
protocol := "binary" // "Specify the protocol (binary, compact, json, simplejson)"
framed := false // "Use framed transport"
buffered := false // "Use buffered transport"
addr := ":" + g.ThriftPort // "Address to listen to"
secure := false // "Use tls secure transport"
cpuNum := runtime.NumCPU()
if cpuNum > 1 {
runtime.GOMAXPROCS(cpuNum - 1)
}
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")
os.Exit(1)
}
var transportFactory thrift.TTransportFactory
if buffered {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
} else {
transportFactory = thrift.NewTTransportFactory()
}
if framed {
transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
}
if err := runServer(transportFactory, protocolFactory, addr, secure); err != nil {
fmt.Println("error running server:", err)
g.Log.Error("error running server, error:%s", err.Error())
}
}
开发者ID:rocflyhi,项目名称:glow,代码行数:43,代码来源:main.go
示例11: TestMain
func TestMain(m *testing.M) {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
serverTransport, err := thrift.NewTServerSocket("127.0.0.1:0")
if err != nil {
panic(err)
}
// call listen here to avoid synchronizing server.serve with test cases
if err = serverTransport.Listen(); err != nil {
panic(err)
}
serverAddr = serverTransport.Addr()
handler := &ExampleHandler{}
processor := example.NewExampleProcessor(handler)
server := thrift.NewTSimpleServer6(processor, serverTransport, transportFactory, transportFactory, protocolFactory, protocolFactory)
go server.Serve()
os.Exit(m.Run())
}
开发者ID:collinmsn,项目名称:thrift-client-pool,代码行数:20,代码来源:clientpool_test.go
示例12: main
func main() {
flag.Usage = Usage
protocol := flag.String("P", "binary", "Specify the protocol (binary,compact,simplejson)")
framed := flag.Bool("framed", true, "Use framed transport")
bufferd := flag.Bool("bufferd", true, "Use bufferd transport")
addr := flag.String("addr", "localhost:9090", "Address to listen to")
flag.Parse()
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 *bufferd {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
} else {
transportFactory = thrift.NewTTranspotFactory()
}
if *framed {
transportFactory = thrift.NewTFramedTranspotFactory(transportFactory)
}
if err := runServer(transportFactory, protocolFactory, addr); err != nil {
fmt.Println("error running server:", err)
}
}
开发者ID:tuhao,项目名称:Thrift4AsyncMsg,代码行数:37,代码来源:server.go
示例13: main
func main() {
transportFactory := thrift.NewTBufferedTransportFactory(8192)
protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
var client [20]*greeter.GreeterClient
//warm up
for i := 0; i < 20; i++ {
transport, err := thrift.NewTSocket(address)
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
useTransport := transportFactory.GetTransport(transport)
defer transport.Close()
if err := transport.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to localhost:9090", " ", err)
os.Exit(1)
}
client[i] = greeter.NewGreeterClientFactory(useTransport, protocolFactory)
client[i].SayHello(defaultName)
}
sync := true
if len(os.Args) > 1 {
sync, _ = strconv.ParseBool(os.Args[1])
}
if sync {
syncTest(client[0], defaultName)
} else {
asyncTest(client, defaultName)
}
}
开发者ID:smallnest,项目名称:RPC-TEST,代码行数:36,代码来源:main.go
示例14: testHappyPath
func testHappyPath(t *testing.T, proto thrift.TProtocolFactory, buffered, framed bool) {
options := nats.DefaultOptions
options.Servers = []string{fmt.Sprintf("nats://localhost:%d", port)}
serverConn, err := options.Connect()
if err != nil {
t.Fatal("Failed to connect to gnatsd", err)
}
defer serverConn.Close()
clientConn, err := options.Connect()
if err != nil {
t.Fatal("Failed to connect to gnatsd", err)
}
defer clientConn.Close()
var transportFactory thrift.TTransportFactory
if buffered {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
} else {
transportFactory = thrift.NewTTransportFactory()
}
if framed {
transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
}
processor := tutorial.NewCalculatorProcessor(NewCalculatorHandler())
server := thrift_nats.NewNATSServer(serverConn, subject, -1, -1, processor,
transportFactory, proto)
wait := make(chan bool)
go func() {
wait <- true
if err := server.Serve(); err != nil {
t.Fatal("Failed to start thrift server", err)
}
}()
<-wait
defer server.Stop()
// Give the server a chance to start.
time.Sleep(500 * time.Millisecond)
transport, err := thrift_nats.NATSTransportFactory(clientConn, subject, time.Second, -1)
if err != nil {
t.Fatal("Failed to create NATS transport", err)
}
transport = transportFactory.GetTransport(transport)
if err := transport.Open(); err != nil {
t.Fatal("Failed to open transport", err)
}
defer transport.Close()
client := tutorial.NewCalculatorClientFactory(transport, proto)
if err := client.Ping(); err != nil {
t.Fatal("Ping failed", err)
}
if err := client.Zip(); err != nil {
t.Fatal("Zip failed", err)
}
sum, err := client.Add(1, 1)
if err != nil {
t.Fatal("Sum failed", err)
}
if sum != 2 {
t.Fatalf("Expected Sum result 2, got %d", sum)
}
work := tutorial.NewWork()
work.Op = tutorial.Operation_DIVIDE
work.Num1 = 8
work.Num2 = 4
quotient, err := client.Calculate(1, work)
if err != nil {
t.Fatal("Calculate failed", err)
}
if sum != 2 {
t.Fatalf("Expected Calculate result 4, got %d", quotient)
}
work.Op = tutorial.Operation_DIVIDE
work.Num1 = 1
work.Num2 = 0
_, err = client.Calculate(2, work)
switch v := err.(type) {
case *tutorial.InvalidOperation:
break
default:
t.Fatalf("Expected Calculate to return InvalidOperation, got %s", v)
}
log, err := client.GetStruct(1)
if err != nil {
t.Fatal("GetStruct failed", err)
}
if log.Value != "2" {
t.Fatalf("Expected struct value `2`, got `%s`", log.Value)
}
log, err = client.GetStruct(2)
if err != nil {
//.........这里部分代码省略.........
开发者ID:Workiva,项目名称:thrift-nats,代码行数:101,代码来源:thrift_nats_test.go
注:本文中的git/apache/org/thrift/git/lib/go/thrift.NewTBufferedTransportFactory函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论