本文整理汇总了Golang中git/apache/org/thrift/git/lib/go/thrift.NewTMemoryBufferLen函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTMemoryBufferLen函数的具体用法?Golang NewTMemoryBufferLen怎么用?Golang NewTMemoryBufferLen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTMemoryBufferLen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: binary
func binary() {
fmt.Printf("\n ==== demo Thrift Binary serialization ====\n")
t := thrift.NewTMemoryBufferLen(1024)
p := thrift.NewTBinaryProtocolFactoryDefault().GetProtocol(t)
tser := &thrift.TSerializer{
Transport: t,
Protocol: p,
}
str := "hi there"
a := &tutorial.Work{
Num1: 12,
Num2: 24,
Comment: &str,
}
by, err := tser.Write(a)
panicOn(err)
fmt.Printf("by = '%v', length %v\n", string(by), len(by))
t2 := thrift.NewTMemoryBufferLen(1024)
p2 := thrift.NewTBinaryProtocolFactoryDefault().GetProtocol(t2)
deser := &thrift.TDeserializer{
Transport: t2,
Protocol: p2,
}
b := tutorial.NewWork()
deser.Transport.Close() // resets underlying bytes.Buffer
err = deser.Read(b, by)
panicOn(err)
fmt.Printf("b = '%#v'\n", b)
}
开发者ID:glycerine,项目名称:golang-thrift-minimal-example,代码行数:35,代码来源:serialize.go
示例2: ParseThriftMsgBegin
//
// 解析Thrift数据的Message Header
//
func ParseThriftMsgBegin(msg []byte) (name string, typeId thrift.TMessageType, seqId int32, err error) {
transport := thrift.NewTMemoryBufferLen(256)
transport.Write(msg)
protocol := thrift.NewTBinaryProtocolTransport(transport)
name, typeId, seqId, err = protocol.ReadMessageBegin()
return
}
开发者ID:jinhy,项目名称:rpc_proxy,代码行数:10,代码来源:thrift_exception.go
示例3: GetWorkerNotFoundData
func GetWorkerNotFoundData(service string, seqId int32) []byte {
// 构建thrift的Transport
transport := thrift.NewTMemoryBufferLen(1024)
protocol := thrift.NewTBinaryProtocolTransport(transport)
// 构建一个Message, 写入Exception
msg := fmt.Sprintf("Worker: %s Not Found", service)
exc := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, msg)
protocol.WriteMessageBegin(service, thrift.EXCEPTION, seqId)
exc.Write(protocol)
protocol.WriteMessageEnd()
bytes := transport.Bytes()
return bytes
}
开发者ID:vinsia,项目名称:rpc_proxy,代码行数:16,代码来源:thrift_expection.go
示例4: Process
// Process function
func (s *Server) Process(str *string) (string, error) {
buffer := new(bytes.Buffer)
_, err := buffer.WriteString(*str)
if err != nil {
s.Err(err)
return "", err
}
t1 := &thrift.TMemoryBuffer{Buffer: buffer}
in := thrift.NewTJSONProtocol(t1)
t2 := thrift.NewTMemoryBufferLen(1024)
//defer t2.Close()
out := thrift.NewTJSONProtocol(t2)
s.processor.Process(in, out)
return t2.String(), nil
}
开发者ID:dictav,项目名称:thrift_learning,代码行数:18,代码来源:server.go
示例5: GetWorkerNotFoundData
func GetWorkerNotFoundData(req *Request, module string) []byte {
req.Response.TypeId = thrift.EXCEPTION
// 构建thrift的Transport
transport := thrift.NewTMemoryBufferLen(100)
protocol := thrift.NewTBinaryProtocolTransport(transport)
// 构建一个Message, 写入Exception
msg := fmt.Sprintf("Worker FOR %s#%s.%s Not Found", module, req.Service, req.Request.Name)
exc := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, msg)
protocol.WriteMessageBegin(req.Request.Name, thrift.EXCEPTION, req.Request.SeqId)
exc.Write(protocol)
protocol.WriteMessageEnd()
bytes := transport.Bytes()
return bytes
}
开发者ID:jinhy,项目名称:rpc_proxy,代码行数:18,代码来源:thrift_exception.go
示例6: GetThriftException
func GetThriftException(req *Request, module string) []byte {
req.Response.TypeId = thrift.EXCEPTION
// 构建thrift的Transport
transport := thrift.NewTMemoryBufferLen(256)
protocol := thrift.NewTBinaryProtocolTransport(transport)
msg := fmt.Sprintf("Module: %s, Service: %s, Method: %s, Error: %v", module, req.Service, req.Request.Name, req.Response.Err)
// 构建一个Message, 写入Exception
exc := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, msg)
protocol.WriteMessageBegin(req.Service, thrift.EXCEPTION, req.Request.SeqId)
exc.Write(protocol)
protocol.WriteMessageEnd()
bytes := transport.Bytes()
return bytes
}
开发者ID:jinhy,项目名称:rpc_proxy,代码行数:19,代码来源:thrift_exception.go
示例7: GetServiceNotFoundData
//
// 生成Thrift格式的Exception Message
//
func GetServiceNotFoundData(req *Request) []byte {
req.Response.TypeId = thrift.EXCEPTION
// 构建thrift的Transport
transport := thrift.NewTMemoryBufferLen(100)
protocol := thrift.NewTBinaryProtocolTransport(transport)
// 构建一个Message, 写入Exception
msg := fmt.Sprintf("Service: %s Not Found", req.Service)
exc := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, msg)
protocol.WriteMessageBegin(req.Request.Name, thrift.EXCEPTION, req.Request.SeqId)
exc.Write(protocol)
protocol.WriteMessageEnd()
protocol.Flush()
bytes := transport.Bytes()
return bytes
}
开发者ID:jinhy,项目名称:rpc_proxy,代码行数:22,代码来源:thrift_exception.go
示例8: NewThriftHandler
// NewThriftHandler retuns http.Handler
func NewThriftHandler(processor thrift.TProcessor) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != `POST` {
http.Error(w, "Thrift Handler requires POST access", http.StatusInternalServerError)
return
}
buffer := new(bytes.Buffer)
_, err := buffer.ReadFrom(r.Body)
if err != nil {
http.Error(w, "Could not read body", http.StatusInternalServerError)
return
}
inTransport := &thrift.TMemoryBuffer{Buffer: buffer}
inProtocol := thrift.NewTJSONProtocol(inTransport)
outTransport := thrift.NewTMemoryBufferLen(1024)
outProtocol := thrift.NewTJSONProtocol(outTransport)
processor.Process(inProtocol, outProtocol)
fmt.Fprint(w, outTransport)
}
}
开发者ID:dictav,项目名称:thrift_learning,代码行数:25,代码来源:thrift_handler.go
示例9: main
//.........这里部分代码省略.........
tmp0, err28 := (strconv.Atoi(flag.Arg(1)))
if err28 != nil {
Usage()
return
}
argvalue0 := int32(tmp0)
value0 := argvalue0
argvalue1 := flag.Arg(2) == "true"
value1 := argvalue1
fmt.Print(client.ActiveFontUser(value0, value1))
fmt.Print("\n")
break
case "FindApplyFormByUnit":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "FindApplyFormByUnit requires 1 args")
flag.Usage()
}
tmp0, err30 := (strconv.Atoi(flag.Arg(1)))
if err30 != nil {
Usage()
return
}
argvalue0 := int32(tmp0)
value0 := argvalue0
fmt.Print(client.FindApplyFormByUnit(value0))
fmt.Print("\n")
break
case "PushBoxStatus":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "PushBoxStatus requires 1 args")
flag.Usage()
}
arg31 := flag.Arg(1)
mbTrans32 := thrift.NewTMemoryBufferLen(len(arg31))
defer mbTrans32.Close()
_, err33 := mbTrans32.WriteString(arg31)
if err33 != nil {
Usage()
return
}
factory34 := thrift.NewTSimpleJSONProtocolFactory()
jsProt35 := factory34.GetProtocol(mbTrans32)
argvalue0 := service.NewBoxStatus()
err36 := argvalue0.Read(jsProt35)
if err36 != nil {
Usage()
return
}
value0 := argvalue0
fmt.Print(client.PushBoxStatus(value0))
fmt.Print("\n")
break
case "DeleteApplyForm":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "DeleteApplyForm requires 1 args")
flag.Usage()
}
tmp0, err37 := (strconv.Atoi(flag.Arg(1)))
if err37 != nil {
Usage()
return
}
argvalue0 := int32(tmp0)
value0 := argvalue0
fmt.Print(client.DeleteApplyForm(value0))
fmt.Print("\n")
开发者ID:huodon,项目名称:tyful,代码行数:67,代码来源:system_service-remote.go
示例10: main
//.........这里部分代码省略.........
protocolFactory = thrift.NewTCompactProtocolFactory()
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := services.NewCitySvcClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "createCity":
if flag.NArg()-1 != 3 {
fmt.Fprintln(os.Stderr, "CreateCity requires 3 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
arg191 := flag.Arg(3)
mbTrans192 := thrift.NewTMemoryBufferLen(len(arg191))
defer mbTrans192.Close()
_, err193 := mbTrans192.WriteString(arg191)
if err193 != nil {
Usage()
return
}
factory194 := thrift.NewTSimpleJSONProtocolFactory()
jsProt195 := factory194.GetProtocol(mbTrans192)
containerStruct2 := services.NewCitySvcCreateCityArgs()
err196 := containerStruct2.ReadField3(jsProt195)
if err196 != nil {
Usage()
return
}
argvalue2 := containerStruct2.Coords
value2 := argvalue2
fmt.Print(client.CreateCity(value0, value1, value2))
fmt.Print("\n")
break
case "getNearBy":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "GetNearBy requires 2 args")
flag.Usage()
}
arg197 := flag.Arg(1)
mbTrans198 := thrift.NewTMemoryBufferLen(len(arg197))
defer mbTrans198.Close()
_, err199 := mbTrans198.WriteString(arg197)
if err199 != nil {
Usage()
return
}
开发者ID:sebsofen,项目名称:sportapp-server,代码行数:67,代码来源:city_svc-remote.go
示例11: main
func main() {
flag.Usage = Usage
var host string
var port int
var protocol string
var urlString string
var framed bool
var useHttp bool
var parsedUrl url.URL
var trans thrift.TTransport
_ = strconv.Atoi
_ = math.Abs
flag.Usage = Usage
flag.StringVar(&host, "h", "localhost", "Specify host and port")
flag.IntVar(&port, "p", 9090, "Specify port")
flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
flag.StringVar(&urlString, "u", "", "Specify the url")
flag.BoolVar(&framed, "framed", false, "Use framed transport")
flag.BoolVar(&useHttp, "http", false, "Use http")
flag.Parse()
if len(urlString) > 0 {
parsedUrl, err := url.Parse(urlString)
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
host = parsedUrl.Host
useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
} else if useHttp {
_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
}
cmd := flag.Arg(0)
var err error
if useHttp {
trans, err = thrift.NewTHttpClient(parsedUrl.String())
} else {
portStr := fmt.Sprint(port)
if strings.Contains(host, ":") {
host, portStr, err = net.SplitHostPort(host)
if err != nil {
fmt.Fprintln(os.Stderr, "error with host:", err)
os.Exit(1)
}
}
trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
if framed {
trans = thrift.NewTFramedTransport(trans)
}
}
if err != nil {
fmt.Fprintln(os.Stderr, "Error creating transport", err)
os.Exit(1)
}
defer trans.Close()
var protocolFactory thrift.TProtocolFactory
switch protocol {
case "compact":
protocolFactory = thrift.NewTCompactProtocolFactory()
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := services.NewAreaSvcClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "createArea":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "CreateArea requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
arg144 := flag.Arg(2)
mbTrans145 := thrift.NewTMemoryBufferLen(len(arg144))
defer mbTrans145.Close()
//.........这里部分代码省略.........
开发者ID:sebsofen,项目名称:sportapp-server,代码行数:101,代码来源:area_svc-remote.go
示例12: main
//.........这里部分代码省略.........
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := notestore.NewNoteStoreClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "getSyncState":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "GetSyncState requires 1 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
fmt.Print(client.GetSyncState(value0))
fmt.Print("\n")
break
case "getSyncStateWithMetrics":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "GetSyncStateWithMetrics requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
arg194 := flag.Arg(2)
mbTrans195 := thrift.NewTMemoryBufferLen(len(arg194))
defer mbTrans195.Close()
_, err196 := mbTrans195.WriteString(arg194)
if err196 != nil {
Usage()
return
}
factory197 := thrift.NewTSimpleJSONProtocolFactory()
jsProt198 := factory197.GetProtocol(mbTrans195)
argvalue1 := notestore.NewClientUsageMetrics()
err199 := argvalue1.Read(jsProt198)
if err199 != nil {
Usage()
return
}
value1 := argvalue1
fmt.Print(client.GetSyncStateWithMetrics(value0, value1))
fmt.Print("\n")
break
case "getSyncChunk":
if flag.NArg()-1 != 4 {
fmt.Fprintln(os.Stderr, "GetSyncChunk requires 4 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
tmp1, err201 := (strconv.Atoi(flag.Arg(2)))
if err201 != nil {
Usage()
return
}
argvalue1 := int32(tmp1)
value1 := argvalue1
开发者ID:rastech,项目名称:goevernote,代码行数:67,代码来源:note_store-remote.go
示例13: main
func main() {
flag.Usage = Usage
var host string
var port int
var protocol string
var urlString string
var framed bool
var useHttp bool
var parsedUrl url.URL
var trans thrift.TTransport
_ = strconv.Atoi
_ = math.Abs
flag.Usage = Usage
flag.StringVar(&host, "h", "localhost", "Specify host and port")
flag.IntVar(&port, "p", 9090, "Specify port")
flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
flag.StringVar(&urlString, "u", "", "Specify the url")
flag.BoolVar(&framed, "framed", false, "Use framed transport")
flag.BoolVar(&useHttp, "http", false, "Use http")
flag.Parse()
if len(urlString) > 0 {
parsedUrl, err := url.Parse(urlString)
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
host = parsedUrl.Host
useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
} else if useHttp {
_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
}
cmd := flag.Arg(0)
var err error
if useHttp {
trans, err = thrift.NewTHttpClient(parsedUrl.String())
} else {
portStr := fmt.Sprint(port)
if strings.Contains(host, ":") {
host, portStr, err = net.SplitHostPort(host)
if err != nil {
fmt.Fprintln(os.Stderr, "error with host:", err)
os.Exit(1)
}
}
trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
if framed {
trans = thrift.NewTFramedTransport(trans)
}
}
if err != nil {
fmt.Fprintln(os.Stderr, "Error creating transport", err)
os.Exit(1)
}
defer trans.Close()
var protocolFactory thrift.TProtocolFactory
switch protocol {
case "compact":
protocolFactory = thrift.NewTCompactProtocolFactory()
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := bolt.NewBoltSchedulerServiceClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "deployComputation":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "DeployComputation requires 1 args")
flag.Usage()
}
arg102 := flag.Arg(1)
mbTrans103 := thrift.NewTMemoryBufferLen(len(arg102))
defer mbTrans103.Close()
_, err104 := mbTrans103.WriteString(arg102)
if err104 != nil {
//.........这里部分代码省略.........
开发者ID:concord,项目名称:concord-go,代码行数:101,代码来源:bolt_scheduler_service-remote.go
示例14: main
func main() {
flag.Usage = Usage
var host string
var port int
var protocol string
var urlString string
var framed bool
var useHttp bool
var parsedUrl url.URL
var trans thrift.TTransport
_ = math.MinInt32 // will become unneeded eventually
_ = strconv.Atoi
flag.Usage = Usage
flag.StringVar(&host, "h", "localhost", "Specify host and port")
flag.IntVar(&port, "p", 9090, "Specify port")
flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
flag.StringVar(&urlString, "u", "", "Specify the url")
flag.BoolVar(&framed, "framed", false, "Use framed transport")
flag.BoolVar(&useHttp, "http", false, "Use http")
flag.Parse()
if len(urlString) > 0 {
parsedUrl, err := url.Parse(urlString)
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
host = parsedUrl.Host
useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
} else if useHttp {
_, err := url.Parse(fmt.Sprint("http://", host, ":", port))
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
flag.Usage()
}
}
cmd := flag.Arg(0)
var err error
if useHttp {
trans, err = thrift.NewTHttpClient(parsedUrl.String())
} else {
portStr := fmt.Sprint(port)
if strings.Contains(host, ":") {
host, portStr, err = net.SplitHostPort(host)
if err != nil {
fmt.Fprintln(os.Stderr, "error with host:", err)
os.Exit(1)
}
}
trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
if err != nil {
fmt.Fprintln(os.Stderr, "error resolving address:", err)
os.Exit(1)
}
if framed {
trans = thrift.NewTFramedTransport(trans)
}
}
if err != nil {
fmt.Fprintln(os.Stderr, "Error creating transport", err)
os.Exit(1)
}
defer trans.Close()
var protocolFactory thrift.TProtocolFactory
switch protocol {
case "compact":
protocolFactory = thrift.NewTCompactProtocolFactory()
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := service.NewAdServletClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "Sender":
if flag.NArg()-1 != 1 {
fmt.Fprintln(os.Stderr, "Sender requires 1 args")
flag.Usage()
}
arg10 := flag.Arg(1)
mbTrans11 := thrift.NewTMemoryBufferLen(len(arg10))
defer mbTrans11.Close()
_, err12 := mbTrans11.WriteString(arg10)
if err12 != nil {
//.........这里部分代码省略.........
开发者ID:SteveYe1024,项目名称:CSTest,代码行数:101,代码来源:ad_servlet-remote.go
示例15: init
"git.apache.org/thrift.git/lib/go/thrift"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/huodon/wpc/thrift/impl"
"github.com/huodon/wpc/thrift/service"
)
var upgrade = websocket.Upgrader{
HandshakeTimeout: 15 * time.Second,
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {
log.Printf("some error happend: %v, state: %d, reason: %s", r.Host, status, reason)
},
}
var (
trans = thrift.NewTMemoryBufferLen(bytes.MinRead << 4)
proto = thrift.NewTJSONProtocol(trans)
process = thrift.NewTMultiplexedProcessor()
boxProc = service.NewBoxServiceProcessor(impl.GetServiceImpl())
inChan = make(chan []byte)
)
func init() {
process.RegisterDefault(boxProc)
}
func wsHandle(w http.ResponseWriter, r *http.Request) {
log.Println(`incomeing websocket request`)
c, err := upgrade.Upgrade(w, r, nil)
defer c.Close()
开发者ID:huodon,项目名称:tyful,代码行数:30,代码来源:server.go
示例16: main
//.........这里部分代码省略.........
}
client := services.NewTagManagerClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "addTag":
if flag.NArg()-1 != 5 {
fmt.Fprintln(os.Stderr, "AddTag requires 5 args")
flag.Usage()
}
argvalue0, err1486 := (strconv.ParseInt(flag.Arg(1), 10, 64))
if err1486 != nil {
Usage()
return
}
value0 := argvalue0
argvalue1, err1487 := (strconv.ParseInt(flag.Arg(2), 10, 64))
if err1487 != nil {
Usage()
return
}
value1 := argvalue1
tmp2, err := (strconv.Atoi(flag.Arg(3)))
if err != nil {
Usage()
return
}
argvalue2 := services.ResourceType(tmp2)
value2 := argvalue2
arg1488 := flag.Arg(4)
mbTrans1489 := thrift.NewTMemoryBufferLen(len(arg1488))
defer mbTrans1489.Close()
_, err1490 := mbTrans1489.WriteString(arg1488)
if err1490 != nil {
Usage()
return
}
factory1491 := thrift.NewTSimpleJSONProtocolFactory()
jsProt1492 := factory1491.GetProtocol(mbTrans1489)
containerStruct3 := services.NewAddTagArgs()
err1493 := containerStruct3.ReadField4(jsProt1492)
if err1493 != nil {
Usage()
return
}
argvalue3 := containerStruct3.Tags
value3 := argvalue3
arg1494 := flag.Arg(5)
mbTrans1495 := thrift.NewTMemoryBufferLen(len(arg1494))
defer mbTrans1495.Close()
_, err1496 := mbTrans1495.WriteString(arg1494)
if err1496 != nil {
Usage()
return
}
factory1497 := thrift.NewTSimpleJSONProtocolFactory()
jsProt1498 := factory1497.GetProtocol(mbTrans1495)
argvalue4 := services.NewFromInfo()
err1499 := argvalue4.Read(jsProt1498)
if err1499 != nil {
Usage()
return
}
开发者ID:lei-yu,项目名称:GOPATH,代码行数:67,代码来源:tag_manager-remote.go
示例17: main
//.........这里部分代码省略.........
value0 := argvalue0
fmt.Print(client.GetFriendRequests(value0))
fmt.Print("\n")
break
case "acceptFriendRequest":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "AcceptFriendRequest requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
fmt.Print(client.AcceptFriendRequest(value0, value1))
fmt.Print("\n")
break
case "declineFriendRequest":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "DeclineFriendRequest requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
fmt.Print(client.DeclineFriendRequest(value0, value1))
fmt.Print("\n")
break
case "sendFriendRequest":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "SendFriendRequest requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
fmt.Print(client.SendFriendRequest(value0, value1))
fmt.Print("\n")
break
case "setProfile":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "SetProfile requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
arg114 := flag.Arg(2)
mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114))
defer mbTrans115.Close()
_, err116 := mbTrans115.WriteString(arg114)
if err116 != nil {
Usage()
return
}
factory117 := thrift.NewTSimpleJSONProtocolFactory()
jsProt118 := factory117.GetProtocol(mbTrans115)
argvalue1 := services.NewProfile()
err119 := argvalue1.Read(jsProt118)
if err119 != nil {
Usage()
return
}
value1 := argvalue1
fmt.Print(client.SetProfile(value0, value1))
fmt.Print("\n")
break
case "requestToken":
if flag.NArg()-1 != 2 {
fmt.Fprintln(os.Stderr, "RequestToken requires 2 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
fmt.Print(client.RequestToken(value0, value1))
fmt.Print("\n")
break
case "setAdmin":
if flag.NArg()-1 != 3 {
fmt.Fprintln(os.Stderr, "SetAdmin requires 3 args")
flag.Usage()
}
argvalue0 := flag.Arg(1)
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
argvalue2 := flag.Arg(3) == "true"
value2 := argvalue2
fmt.Print(client.SetAdmin(value0, value1, value2))
fmt.Print("\n")
break
case "":
Usage()
break
default:
fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
}
}
开发者ID:sebsofen,项目名称:sportapp-server,代码行数:101,代码来源:user_svc-remote.go
示例18: main
//.........这里部分代码省略.........
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := servicessync.NewAccessManagerSyncClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "grantUserAccessToGroupRegion":
if flag.NArg()-1 != 6 {
fmt.Fprintln(os.Stderr, "GrantUserAccessToGroupRegion requires 6 args")
flag.Usage()
}
argvalue0, err182 := (strconv.ParseInt(flag.Arg(1), 10, 64))
if err182 != nil {
Usage()
return
}
value0 := argvalue0
argvalue1, err183 := (strconv.ParseInt(flag.Arg(2), 10, 64))
if err183 != nil {
Usage()
return
}
value1 := argvalue1
arg184 := flag.Arg(3)
mbTrans185 := thrift.NewTMemoryBufferLen(len(arg184))
defer mbTrans185.Close()
_, err186 := mbTrans185.WriteString(arg184)
if err186 != nil {
Usage()
return
}
factory187 := thrift.NewTSimpleJSONProtocolFactory()
jsProt188 := factory187.GetProtocol(mbTrans185)
containerStruct2 := servicessync.NewGrantUserAccessToGroupRegionArgs()
err189 := containerStruct2.ReadField3(jsProt188)
if err189 != nil {
Usage()
return
}
argvalue2 := containerStruct2.Zones
value2 := argvalue2
tmp3, err190 := (strconv.Atoi(flag.Arg(4)))
if err190 != nil {
Usage()
return
}
argvalue3 := int32(tmp3)
value3 := argvalue3
tmp4, err191 := (strconv.Atoi(flag.Arg(5)))
if err191 != nil {
Usage()
return
}
argvalue4 := int32(tmp4)
value4 := argvalue4
argvalue5, err192 := (strconv.ParseInt(flag.Arg(6), 10, 64))
if err192 != nil {
开发者ID:lei-yu,项目名称:GOPATH,代码行数:67,代码来源:access_manager_sync-remote.go
示例19: main
//.........这里部分代码省略.........
return
}
argvalue1 := servicessync.SearchCategory(tmp1)
value1 := argvalue1
tmp2, err := (strconv.Atoi(flag.Arg(3)))
if err != nil {
Usage()
return
}
argvalue2 := servicessync.ResourceType(tmp2)
value2 := argvalue2
tmp3, err := (strconv.Atoi(flag.Arg(4)))
if err != nil {
Usage()
return
}
argvalue3 := servicessync.Zone(tmp3)
value3 := argvalue3
tmp4, err463 := (strconv.Atoi(flag.Arg(5)))
if err463 != nil {
Usage()
return
}
argvalue4 := int32(tmp4)
value4 := argvalue4
tmp5, err464 := (strconv.Atoi(flag.Arg(6)))
if err464 != nil {
Usage()
return
}
argvalue5 := int32(tmp5)
value5 := argvalue5
arg465 := flag.Arg(7)
mbTrans466 := thrift.NewTMemoryBufferLen(len(arg465))
defer mbTrans466.Close()
_, err467 := mbTrans466.WriteString(arg465)
if err467 != nil {
Usage()
return
}
factory468 := thrift.NewTSimpleJSONProtocolFactory()
jsProt469 := factory468.GetProtocol(mbTrans466)
containerStruct6 := servicessync.NewSearchPublicResourcesArgs()
err470 := containerStruct6.ReadField7(jsProt469)
if err470 != nil {
Usage()
return
}
argvalue6 := containerStruct6.Sortlist
value6 := argvalue6
arg471 := flag.Arg(8)
mbTrans472 := thrift.NewTMemoryBufferLen(len(arg471))
defer mbTrans472.Close()
_, err473 := mbTrans472.WriteString(arg471)
if err473 != nil {
Usage()
return
}
factory474 := thrift.NewTSimpleJSONProtocolFactory()
jsProt475 := factory474.GetProtocol(mbTrans472)
containerStruct7 := servicessync.NewSearchPublicResourcesArgs()
err476 := containerStruct7.ReadField8(jsProt475)
if err476 != nil {
Usage()
return
}
开发者ID:lei-yu,项目名称:GOPATH,代码行数:67,代码来源:search_manager_sync-remote.go
示例20: main
//.........这里部分代码省略.........
break
case "simplejson":
protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
break
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
break
case "binary", "":
protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
break
default:
fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
Usage()
os.Exit(1)
}
client := services.NewUserRelationManagerClientFactory(trans, protocolFactory)
if err := trans.Open(); err != nil {
fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
os.Exit(1)
}
switch cmd {
case "setRemark":
if flag.NArg()-1 != 3 {
fmt.Fprintln(os.Stderr, "SetRemark requires 3 args")
flag.Usage()
}
argvalue0, err595 := (strconv.ParseInt(flag.Arg(1), 10, 64))
if err595 != nil {
Usage()
return
}
value0 := argvalue0
argvalue1 := flag.Arg(2)
value1 := argvalue1
arg597 := flag.Arg(3)
mbTrans598 := thrift.NewTMemoryBufferLen(len(arg597))
defer mbTrans598.Close()
_, err599 := mbTrans598.WriteString(arg597)
if err599 != nil {
Usage()
return
}
factory600 := thrift.NewTSimpleJSONProtocolFactory()
jsProt601 := factory600.GetProtocol(mbTrans598)
argvalue2 := services.NewFromInfo()
err602 := argvalue2.Read(jsProt601)
if err602 != nil {
Usage()
return
}
value2 := argvalue2
fmt.Print(client.SetRemark(value0, value1, value2))
fmt.Print("\n")
break
case "getRemarks":
if flag.NArg()-1 != 3 {
fmt.Fprintln(os.Stderr, "GetRemarks requires 3 args")
flag.Usage()
}
argvalue0, err603 := (strconv.ParseInt(flag.Arg(1), 10, 64))
if err603 != nil {
Usage()
return
}
value0 := argvalue0
tmp1, err604 := (strconv.Atoi(flag.Arg(2)))
if err604 != nil {
Usage()
return
}
argvalue1 := int32(tmp1)
value1 := argvalue1
arg605 := flag.Arg(3)
mbTrans606 := thrift.NewTMemoryBufferLen(len(arg605))
defer mbTrans606.Close()
_, err607 := mbTrans606.WriteString(arg605)
if err607 != nil {
Usage()
return
}
factory608 := thrift.NewTSimpleJSONProtocolFactory()
jsProt609 := factory608.GetProtocol(mbTrans606)
argvalue2 := services.NewFromInfo()
err610 := argvalue2.Read(jsProt609)
if err610 != nil {
Usage()
return
}
value2 := argvalue2
fmt.Print(client.GetRemarks(value0, value1, value2))
fmt.Print("\n")
break
case "":
Usage()
break
default:
fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
}
}
开发者ID:lei-yu,项目名称:GOPATH,代码行数:101,代码来源:user_relation_manager-remote.go
注:本文中的git/apache/org/thrift/git/lib/go/thrift.NewTMemoryBufferLen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论