mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-12 04:07:24 +00:00
``` $ gvt delete github.com/weaveworks/common $ gvt fetch --revision 4d96fd8dcf2c7b417912c6219b310112cb4a4626 github.com/weaveworks/common 2018/07/23 15:31:11 Fetching: github.com/weaveworks/common 2018/07/23 15:31:14 · Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:14 · Fetching recursive dependency: github.com/pkg/errors 2018/07/23 15:31:16 · Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:31:16 · Fetching recursive dependency: github.com/sirupsen/logrus 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/sys/unix 2018/07/23 15:31:18 ·· Skipping (existing): golang.org/x/crypto/ssh/terminal 2018/07/23 15:31:18 · Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:18 · Skipping (existing): github.com/gorilla/mux 2018/07/23 15:31:18 · Fetching recursive dependency: github.com/opentracing-contrib/go-stdlib/nethttp 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:20 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:20 · Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:31:20 · Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:20 · Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:20 · Fetching recursive dependency: github.com/go-kit/kit/log 2018/07/23 15:31:23 ·· Fetching recursive dependency: github.com/go-logfmt/logfmt 2018/07/23 15:31:25 ··· Fetching recursive dependency: github.com/kr/logfmt 2018/07/23 15:31:27 ·· Fetching recursive dependency: github.com/go-stack/stack 2018/07/23 15:31:29 · Fetching recursive dependency: google.golang.org/genproto/googleapis/rpc/status 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:37 ·· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:31:37 · Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:37 · Fetching recursive dependency: github.com/sercand/kuberesolver 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:31:39 ·· Skipping (existing): google.golang.org/grpc/resolver 2018/07/23 15:31:39 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:39 · Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:39 · Skipping (existing): github.com/armon/go-socks5 2018/07/23 15:31:39 · Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:39 · Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/ptypes 2018/07/23 15:31:39 · Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:39 · Fetching recursive dependency: github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:41 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:31:41 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:41 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:31:41 ·· Skipping (existing): google.golang.org/grpc/status 2018/07/23 15:31:41 · Fetching recursive dependency: github.com/uber/jaeger-client-go/config 2018/07/23 15:31:44 ·· Fetching recursive dependency: github.com/uber/jaeger-client-go/internal/throttler/remote 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go/utils 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/agent 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/jaeger 2018/07/23 15:31:44 ····· Fetching recursive dependency: github.com/uber/jaeger-client-go/thrift-gen/zipkincore 2018/07/23 15:31:44 ··· Fetching recursive dependency: github.com/uber/jaeger-client-go 2018/07/23 15:31:44 ···· Fetching recursive dependency: github.com/crossdock/crossdock-go 2018/07/23 15:31:46 ····· Skipping (existing): github.com/davecgh/go-spew/spew 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:31:46 ····· Skipping (existing): golang.org/x/net/context 2018/07/23 15:31:46 ····· Skipping (existing): github.com/pmezard/go-difflib/difflib 2018/07/23 15:31:46 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:31:46 ···· Fetching recursive dependency: go.uber.org/zap/zapcore 2018/07/23 15:31:49 ····· Fetching recursive dependency: go.uber.org/atomic 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/zap/internal/bufferpool 2018/07/23 15:31:51 ······ Fetching recursive dependency: go.uber.org/zap/buffer 2018/07/23 15:31:51 ····· Fetching recursive dependency: go.uber.org/multierr 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/exit 2018/07/23 15:31:54 ····· Fetching recursive dependency: go.uber.org/zap/internal/color 2018/07/23 15:31:54 ···· Fetching recursive dependency: go.uber.org/zap 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:31:54 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:31:54 ···· Fetching recursive dependency: github.com/uber/jaeger-lib/metrics 2018/07/23 15:31:56 ····· Fetching recursive dependency: github.com/uber-go/tally 2018/07/23 15:31:58 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus/promhttp 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:00 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:00 ······ Fetching recursive dependency: gopkg.in/validator.v2 2018/07/23 15:32:06 ······ Fetching recursive dependency: github.com/cactus/go-statsd-client/statsd 2018/07/23 15:32:08 ······ Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/m3db/prometheus_client_golang/prometheus 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/procfs 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_model/go 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/expfmt 2018/07/23 15:32:08 ······· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:08 ······· Skipping (existing): github.com/beorn7/perks/quantile 2018/07/23 15:32:08 ······· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/common/model 2018/07/23 15:32:08 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:08 ······ Fetching recursive dependency: github.com/apache/thrift/lib/go/thrift 2018/07/23 15:32:13 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:13 ····· Fetching recursive dependency: github.com/go-kit/kit/metrics/influx 2018/07/23 15:32:13 ······ Fetching recursive dependency: github.com/influxdata/influxdb/client/v2 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/influxdata/influxdb/models 2018/07/23 15:32:17 ········ Fetching recursive dependency: github.com/influxdata/influxdb/pkg/escape 2018/07/23 15:32:17 ······ Fetching recursive dependency: github.com/go-kit/kit/metrics 2018/07/23 15:32:17 ······· Fetching recursive dependency: github.com/performancecopilot/speed 2018/07/23 15:32:19 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/aws 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/sdk 2018/07/23 15:32:28 ········ Skipping (existing): github.com/go-ini/ini 2018/07/23 15:32:28 ········ Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/sts 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol/query 2018/07/23 15:32:28 ·········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/private/protocol 2018/07/23 15:32:28 ········· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/internal/awsutil 2018/07/23 15:32:28 ·········· Skipping (existing): github.com/jmespath/go-jmespath 2018/07/23 15:32:28 ······· Fetching recursive dependency: github.com/aws/aws-sdk-go-v2/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/aws 2018/07/23 15:32:29 ······· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch 2018/07/23 15:32:29 ······· Skipping (existing): github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface 2018/07/23 15:32:29 ······· Fetching recursive dependency: golang.org/x/sync/errgroup 2018/07/23 15:32:31 ········ Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/go-kit/kit/util/conn 2018/07/23 15:32:31 ······· Fetching recursive dependency: github.com/VividCortex/gohistogram 2018/07/23 15:32:33 ····· Skipping (existing): github.com/prometheus/client_golang/prometheus 2018/07/23 15:32:33 ····· Fetching recursive dependency: github.com/codahale/hdrhistogram 2018/07/23 15:32:35 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:35 · Fetching recursive dependency: github.com/mwitkow/go-grpc-middleware 2018/07/23 15:32:37 ·· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware/logging 2018/07/23 15:32:39 ··· Fetching recursive dependency: github.com/grpc-ecosystem/go-grpc-middleware 2018/07/23 15:32:39 ···· Fetching recursive dependency: github.com/golang/protobuf/jsonpb 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/timestamp 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/duration 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/any 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/struct 2018/07/23 15:32:42 ····· Skipping (existing): github.com/golang/protobuf/ptypes/wrappers 2018/07/23 15:32:42 ···· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:42 ···· Fetching recursive dependency: github.com/stretchr/testify/suite 2018/07/23 15:32:45 ····· Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ····· Fetching recursive dependency: github.com/stretchr/testify/require 2018/07/23 15:32:45 ······ Skipping (existing): github.com/stretchr/testify/assert 2018/07/23 15:32:45 ···· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:45 ···· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:45 ···· Fetching recursive dependency: github.com/gogo/protobuf/gogoproto 2018/07/23 15:32:48 ····· Fetching recursive dependency: github.com/gogo/protobuf/protoc-gen-gogo/descriptor 2018/07/23 15:32:48 ······ Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ····· Skipping (existing): github.com/gogo/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ···· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ···· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 ···· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ··· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ··· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ··· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/codes 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/grpclog 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/log 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/metadata 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/peer 2018/07/23 15:32:48 ·· Skipping (existing): google.golang.org/grpc/credentials 2018/07/23 15:32:48 ·· Skipping (existing): github.com/golang/protobuf/proto 2018/07/23 15:32:48 ·· Skipping (existing): golang.org/x/net/trace 2018/07/23 15:32:48 ·· Skipping (existing): github.com/opentracing/opentracing-go/ext 2018/07/23 15:32:48 · Fetching recursive dependency: github.com/weaveworks/promrus 2018/07/23 15:32:53 ·· Skipping (existing): gopkg.in/yaml.v2 2018/07/23 15:32:53 ·· Skipping (existing): golang.org/x/net/context/ctxhttp 2018/07/23 15:32:53 ·· Fetching recursive dependency: github.com/stretchr/objx 2018/07/23 15:32:55 ·· Fetching recursive dependency: gopkg.in/alecthomas/kingpin.v2 2018/07/23 15:32:58 ··· Fetching recursive dependency: github.com/alecthomas/units 2018/07/23 15:33:00 ··· Fetching recursive dependency: github.com/alecthomas/template 2018/07/23 15:33:02 ·· Fetching recursive dependency: github.com/julienschmidt/httprouter 2018/07/23 15:33:05 ·· Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): github.com/aws/aws-sdk-go/aws/credentials 2018/07/23 15:33:05 · Skipping (existing): github.com/golang/protobuf/ptypes/empty 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/net/context 2018/07/23 15:33:05 · Skipping (existing): golang.org/x/tools/cover 2018/07/23 15:33:05 · Skipping (existing): github.com/mgutz/ansi ```
515 lines
11 KiB
Go
515 lines
11 KiB
Go
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
package thrift
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/binary"
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
"math"
|
|
)
|
|
|
|
type TBinaryProtocol struct {
|
|
trans TRichTransport
|
|
origTransport TTransport
|
|
reader io.Reader
|
|
writer io.Writer
|
|
strictRead bool
|
|
strictWrite bool
|
|
buffer [64]byte
|
|
}
|
|
|
|
type TBinaryProtocolFactory struct {
|
|
strictRead bool
|
|
strictWrite bool
|
|
}
|
|
|
|
func NewTBinaryProtocolTransport(t TTransport) *TBinaryProtocol {
|
|
return NewTBinaryProtocol(t, false, true)
|
|
}
|
|
|
|
func NewTBinaryProtocol(t TTransport, strictRead, strictWrite bool) *TBinaryProtocol {
|
|
p := &TBinaryProtocol{origTransport: t, strictRead: strictRead, strictWrite: strictWrite}
|
|
if et, ok := t.(TRichTransport); ok {
|
|
p.trans = et
|
|
} else {
|
|
p.trans = NewTRichTransport(t)
|
|
}
|
|
p.reader = p.trans
|
|
p.writer = p.trans
|
|
return p
|
|
}
|
|
|
|
func NewTBinaryProtocolFactoryDefault() *TBinaryProtocolFactory {
|
|
return NewTBinaryProtocolFactory(false, true)
|
|
}
|
|
|
|
func NewTBinaryProtocolFactory(strictRead, strictWrite bool) *TBinaryProtocolFactory {
|
|
return &TBinaryProtocolFactory{strictRead: strictRead, strictWrite: strictWrite}
|
|
}
|
|
|
|
func (p *TBinaryProtocolFactory) GetProtocol(t TTransport) TProtocol {
|
|
return NewTBinaryProtocol(t, p.strictRead, p.strictWrite)
|
|
}
|
|
|
|
/**
|
|
* Writing Methods
|
|
*/
|
|
|
|
func (p *TBinaryProtocol) WriteMessageBegin(name string, typeId TMessageType, seqId int32) error {
|
|
if p.strictWrite {
|
|
version := uint32(VERSION_1) | uint32(typeId)
|
|
e := p.WriteI32(int32(version))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteString(name)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI32(seqId)
|
|
return e
|
|
} else {
|
|
e := p.WriteString(name)
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteByte(int8(typeId))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI32(seqId)
|
|
return e
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteMessageEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteStructBegin(name string) error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteStructEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteFieldBegin(name string, typeId TType, id int16) error {
|
|
e := p.WriteByte(int8(typeId))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI16(id)
|
|
return e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteFieldEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteFieldStop() error {
|
|
e := p.WriteByte(STOP)
|
|
return e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error {
|
|
e := p.WriteByte(int8(keyType))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteByte(int8(valueType))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI32(int32(size))
|
|
return e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteMapEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteListBegin(elemType TType, size int) error {
|
|
e := p.WriteByte(int8(elemType))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI32(int32(size))
|
|
return e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteListEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteSetBegin(elemType TType, size int) error {
|
|
e := p.WriteByte(int8(elemType))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
e = p.WriteI32(int32(size))
|
|
return e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteSetEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteBool(value bool) error {
|
|
if value {
|
|
return p.WriteByte(1)
|
|
}
|
|
return p.WriteByte(0)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteByte(value int8) error {
|
|
e := p.trans.WriteByte(byte(value))
|
|
return NewTProtocolException(e)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteI16(value int16) error {
|
|
v := p.buffer[0:2]
|
|
binary.BigEndian.PutUint16(v, uint16(value))
|
|
_, e := p.writer.Write(v)
|
|
return NewTProtocolException(e)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteI32(value int32) error {
|
|
v := p.buffer[0:4]
|
|
binary.BigEndian.PutUint32(v, uint32(value))
|
|
_, e := p.writer.Write(v)
|
|
return NewTProtocolException(e)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteI64(value int64) error {
|
|
v := p.buffer[0:8]
|
|
binary.BigEndian.PutUint64(v, uint64(value))
|
|
_, err := p.writer.Write(v)
|
|
return NewTProtocolException(err)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteDouble(value float64) error {
|
|
return p.WriteI64(int64(math.Float64bits(value)))
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteString(value string) error {
|
|
e := p.WriteI32(int32(len(value)))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
_, err := p.trans.WriteString(value)
|
|
return NewTProtocolException(err)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) WriteBinary(value []byte) error {
|
|
e := p.WriteI32(int32(len(value)))
|
|
if e != nil {
|
|
return e
|
|
}
|
|
_, err := p.writer.Write(value)
|
|
return NewTProtocolException(err)
|
|
}
|
|
|
|
/**
|
|
* Reading methods
|
|
*/
|
|
|
|
func (p *TBinaryProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) {
|
|
size, e := p.ReadI32()
|
|
if e != nil {
|
|
return "", typeId, 0, NewTProtocolException(e)
|
|
}
|
|
if size < 0 {
|
|
typeId = TMessageType(size & 0x0ff)
|
|
version := int64(int64(size) & VERSION_MASK)
|
|
if version != VERSION_1 {
|
|
return name, typeId, seqId, NewTProtocolExceptionWithType(BAD_VERSION, fmt.Errorf("Bad version in ReadMessageBegin"))
|
|
}
|
|
name, e = p.ReadString()
|
|
if e != nil {
|
|
return name, typeId, seqId, NewTProtocolException(e)
|
|
}
|
|
seqId, e = p.ReadI32()
|
|
if e != nil {
|
|
return name, typeId, seqId, NewTProtocolException(e)
|
|
}
|
|
return name, typeId, seqId, nil
|
|
}
|
|
if p.strictRead {
|
|
return name, typeId, seqId, NewTProtocolExceptionWithType(BAD_VERSION, fmt.Errorf("Missing version in ReadMessageBegin"))
|
|
}
|
|
name, e2 := p.readStringBody(size)
|
|
if e2 != nil {
|
|
return name, typeId, seqId, e2
|
|
}
|
|
b, e3 := p.ReadByte()
|
|
if e3 != nil {
|
|
return name, typeId, seqId, e3
|
|
}
|
|
typeId = TMessageType(b)
|
|
seqId, e4 := p.ReadI32()
|
|
if e4 != nil {
|
|
return name, typeId, seqId, e4
|
|
}
|
|
return name, typeId, seqId, nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadMessageEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadStructBegin() (name string, err error) {
|
|
return
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadStructEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadFieldBegin() (name string, typeId TType, seqId int16, err error) {
|
|
t, err := p.ReadByte()
|
|
typeId = TType(t)
|
|
if err != nil {
|
|
return name, typeId, seqId, err
|
|
}
|
|
if t != STOP {
|
|
seqId, err = p.ReadI16()
|
|
}
|
|
return name, typeId, seqId, err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadFieldEnd() error {
|
|
return nil
|
|
}
|
|
|
|
var invalidDataLength = NewTProtocolExceptionWithType(INVALID_DATA, errors.New("Invalid data length"))
|
|
|
|
func (p *TBinaryProtocol) ReadMapBegin() (kType, vType TType, size int, err error) {
|
|
k, e := p.ReadByte()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
kType = TType(k)
|
|
v, e := p.ReadByte()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
vType = TType(v)
|
|
size32, e := p.ReadI32()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
if size32 < 0 {
|
|
err = invalidDataLength
|
|
return
|
|
}
|
|
size = int(size32)
|
|
return kType, vType, size, nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadMapEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadListBegin() (elemType TType, size int, err error) {
|
|
b, e := p.ReadByte()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
elemType = TType(b)
|
|
size32, e := p.ReadI32()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
if size32 < 0 {
|
|
err = invalidDataLength
|
|
return
|
|
}
|
|
size = int(size32)
|
|
|
|
return
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadListEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadSetBegin() (elemType TType, size int, err error) {
|
|
b, e := p.ReadByte()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
elemType = TType(b)
|
|
size32, e := p.ReadI32()
|
|
if e != nil {
|
|
err = NewTProtocolException(e)
|
|
return
|
|
}
|
|
if size32 < 0 {
|
|
err = invalidDataLength
|
|
return
|
|
}
|
|
size = int(size32)
|
|
return elemType, size, nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadSetEnd() error {
|
|
return nil
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadBool() (bool, error) {
|
|
b, e := p.ReadByte()
|
|
v := true
|
|
if b != 1 {
|
|
v = false
|
|
}
|
|
return v, e
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadByte() (int8, error) {
|
|
v, err := p.trans.ReadByte()
|
|
return int8(v), err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadI16() (value int16, err error) {
|
|
buf := p.buffer[0:2]
|
|
err = p.readAll(buf)
|
|
value = int16(binary.BigEndian.Uint16(buf))
|
|
return value, err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadI32() (value int32, err error) {
|
|
buf := p.buffer[0:4]
|
|
err = p.readAll(buf)
|
|
value = int32(binary.BigEndian.Uint32(buf))
|
|
return value, err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadI64() (value int64, err error) {
|
|
buf := p.buffer[0:8]
|
|
err = p.readAll(buf)
|
|
value = int64(binary.BigEndian.Uint64(buf))
|
|
return value, err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadDouble() (value float64, err error) {
|
|
buf := p.buffer[0:8]
|
|
err = p.readAll(buf)
|
|
value = math.Float64frombits(binary.BigEndian.Uint64(buf))
|
|
return value, err
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadString() (value string, err error) {
|
|
size, e := p.ReadI32()
|
|
if e != nil {
|
|
return "", e
|
|
}
|
|
if size < 0 {
|
|
err = invalidDataLength
|
|
return
|
|
}
|
|
|
|
return p.readStringBody(size)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) ReadBinary() ([]byte, error) {
|
|
size, e := p.ReadI32()
|
|
if e != nil {
|
|
return nil, e
|
|
}
|
|
if size < 0 {
|
|
return nil, invalidDataLength
|
|
}
|
|
if uint64(size) > p.trans.RemainingBytes() {
|
|
return nil, invalidDataLength
|
|
}
|
|
|
|
isize := int(size)
|
|
buf := make([]byte, isize)
|
|
_, err := io.ReadFull(p.trans, buf)
|
|
return buf, NewTProtocolException(err)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) Flush() (err error) {
|
|
return NewTProtocolException(p.trans.Flush())
|
|
}
|
|
|
|
func (p *TBinaryProtocol) Skip(fieldType TType) (err error) {
|
|
return SkipDefaultDepth(p, fieldType)
|
|
}
|
|
|
|
func (p *TBinaryProtocol) Transport() TTransport {
|
|
return p.origTransport
|
|
}
|
|
|
|
func (p *TBinaryProtocol) readAll(buf []byte) error {
|
|
_, err := io.ReadFull(p.reader, buf)
|
|
return NewTProtocolException(err)
|
|
}
|
|
|
|
const readLimit = 32768
|
|
|
|
func (p *TBinaryProtocol) readStringBody(size int32) (value string, err error) {
|
|
if size < 0 {
|
|
return "", nil
|
|
}
|
|
if uint64(size) > p.trans.RemainingBytes() {
|
|
return "", invalidDataLength
|
|
}
|
|
|
|
var (
|
|
buf bytes.Buffer
|
|
e error
|
|
b []byte
|
|
)
|
|
|
|
switch {
|
|
case int(size) <= len(p.buffer):
|
|
b = p.buffer[:size] // avoids allocation for small reads
|
|
case int(size) < readLimit:
|
|
b = make([]byte, size)
|
|
default:
|
|
b = make([]byte, readLimit)
|
|
}
|
|
|
|
for size > 0 {
|
|
_, e = io.ReadFull(p.trans, b)
|
|
buf.Write(b)
|
|
if e != nil {
|
|
break
|
|
}
|
|
size -= readLimit
|
|
if size < readLimit && size > 0 {
|
|
b = b[:size]
|
|
}
|
|
}
|
|
return buf.String(), NewTProtocolException(e)
|
|
}
|