summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuxuan 'fishy' Wang <yuxuan.wang@reddit.com>2022-10-12 14:13:15 -0700
committerYuxuan 'fishy' Wang <fishywang@gmail.com>2022-10-21 10:36:06 -0700
commit19c13b4cc697410b586b243123522c43e68e2f0c (patch)
tree12a77be60cdcc08cb6ec2d8714b4530e9306aff8
parentbaa0daa478c3b16876ccc0778f068fb72932dda6 (diff)
downloadthrift-19c13b4cc697410b586b243123522c43e68e2f0c.tar.gz
THRIFT-5650: Implement UUID in Go library
Client: go This is only the library part of THRIFT-5650. I still have some open questions for the compiler part so that will be done later. While I'm here, also made some changes to go CI process: * Update ubuntu-bionic to use go 1.18 for travis * Update ubuntu-jammy to use the latest go 1.19.x for travis * Run both go 1.18 and 1.19 for github actions * Also run test/go tests for github actions
-rw-r--r--.github/workflows/build.yml16
-rw-r--r--LANGUAGES.md2
-rw-r--r--build/docker/ubuntu-bionic/Dockerfile4
-rw-r--r--build/docker/ubuntu-jammy/Dockerfile4
-rw-r--r--go.mod9
-rw-r--r--go.sum24
-rw-r--r--lib/go/test/tests/protocol_mock.go602
-rw-r--r--lib/go/thrift/binary_protocol.go14
-rw-r--r--lib/go/thrift/compact_protocol.go20
-rw-r--r--lib/go/thrift/debug_protocol.go16
-rw-r--r--lib/go/thrift/duplicate_protocol.go12
-rw-r--r--lib/go/thrift/header_protocol.go8
-rw-r--r--lib/go/thrift/json_protocol.go1
-rw-r--r--lib/go/thrift/pointerize.go1
-rw-r--r--lib/go/thrift/protocol.go5
-rw-r--r--lib/go/thrift/protocol_test.go56
-rw-r--r--lib/go/thrift/simple_json_protocol.go15
-rw-r--r--lib/go/thrift/type.go7
-rw-r--r--lib/go/thrift/uuid.go130
-rw-r--r--lib/go/thrift/uuid_test.go290
20 files changed, 1009 insertions, 227 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0a4ecaf47..b3ecd1eca 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -54,12 +54,17 @@ jobs:
lib-go:
needs: compiler
runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ go:
+ - '1.18'
+ - '1.19'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
- go-version: '>=1.17.0'
+ go-version: ${{ matrix.go }}
- name: Install dependencies
run: |
@@ -110,13 +115,20 @@ jobs:
- name: Run make for go
run: make -C lib/go
- - name: Run make check for go
+ - name: Run make check for lib/go
run: make -C lib/go check
+ - name: Run make check for lib/go/test
+ run: make -C lib/go/test check
+
+ - name: Run make check for test/go
+ run: make -C test/go check
+
- name: Run make precross for go test
run: make -C test/go precross
- name: Upload go precross artifacts
+ if: matrix.go == '1.19'
uses: actions/upload-artifact@v3
with:
name: go-precross
diff --git a/LANGUAGES.md b/LANGUAGES.md
index 93c4648db..e366f98a8 100644
--- a/LANGUAGES.md
+++ b/LANGUAGES.md
@@ -163,7 +163,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr
<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/go/README.md">Go</a></td>
<!-- Since -----------------><td>0.7.0</td>
<!-- Build Systems ---------><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
-<!-- Language Levels -------><td>1.18.5</td><td>1.19.2</td>
+<!-- Language Levels -------><td>1.18.7</td><td>1.19.2</td>
<!-- Field types -----------><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Low-Level Transports --><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td>
diff --git a/build/docker/ubuntu-bionic/Dockerfile b/build/docker/ubuntu-bionic/Dockerfile
index 3d2793077..5d5f7ca72 100644
--- a/build/docker/ubuntu-bionic/Dockerfile
+++ b/build/docker/ubuntu-bionic/Dockerfile
@@ -144,9 +144,9 @@ RUN apt-get install -y --no-install-recommends \
libglib2.0-dev
# golang
-ENV GOLANG_VERSION 1.19.2
+ENV GOLANG_VERSION 1.18.7
ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 5e8c5a74fe6470dd7e055a461acda8bb4050ead8c2df70f227e3ff7d8eb7eeb6
+ENV GOLANG_DOWNLOAD_SHA256 6c967efc22152ce3124fc35cdf50fc686870120c5fd2107234d05d450a6105d8
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/build/docker/ubuntu-jammy/Dockerfile b/build/docker/ubuntu-jammy/Dockerfile
index 6ab65fb9a..9fd0db394 100644
--- a/build/docker/ubuntu-jammy/Dockerfile
+++ b/build/docker/ubuntu-jammy/Dockerfile
@@ -145,9 +145,9 @@ RUN apt-get install -y --no-install-recommends \
libglib2.0-dev
# golang
-ENV GOLANG_VERSION 1.19
+ENV GOLANG_VERSION 1.19.2
ENV GOLANG_DOWNLOAD_URL https://go.dev/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 464b6b66591f6cf055bc5df90a9750bf5fbc9d038722bb84a9d56a2bea974be6
+ENV GOLANG_DOWNLOAD_SHA256 5e8c5a74fe6470dd7e055a461acda8bb4050ead8c2df70f227e3ff7d8eb7eeb6
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/go.mod b/go.mod
index 2d3d1c662..dc1e4a207 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,11 @@ module github.com/apache/thrift
go 1.18
-require github.com/golang/mock v1.5.0
+require github.com/golang/mock v1.6.0
+
+require (
+ golang.org/x/mod v0.4.2 // indirect
+ golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
+ golang.org/x/tools v0.1.1 // indirect
+ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
+)
diff --git a/go.sum b/go.sum
index cfde58466..6904b3efe 100644
--- a/go.sum
+++ b/go.sum
@@ -1,17 +1,29 @@
-github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
-github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
+github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
+github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
-golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
+golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/lib/go/test/tests/protocol_mock.go b/lib/go/test/tests/protocol_mock.go
index 1cdd4c321..221705f61 100644
--- a/lib/go/test/tests/protocol_mock.go
+++ b/lib/go/test/tests/protocol_mock.go
@@ -1,111 +1,118 @@
-/*
- * 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.
- */
-
-// Automatically generated by MockGen. DO NOT EDIT!
-// Source: thrift (interfaces: TProtocol)
+// Code generated by MockGen. DO NOT EDIT.
+// Source: github.com/apache/thrift/lib/go/thrift (interfaces: TProtocol)
+// Package tests is a generated GoMock package.
package tests
import (
- "context"
- thrift "github.com/apache/thrift/lib/go/thrift"
+ context "context"
+ reflect "reflect"
+ thrift "github.com/apache/thrift/lib/go/thrift"
gomock "github.com/golang/mock/gomock"
)
-// Mock of TProtocol interface
+// MockTProtocol is a mock of TProtocol interface.
type MockTProtocol struct {
ctrl *gomock.Controller
- recorder *_MockTProtocolRecorder
+ recorder *MockTProtocolMockRecorder
}
-// Recorder for MockTProtocol (not exported)
-type _MockTProtocolRecorder struct {
+// MockTProtocolMockRecorder is the mock recorder for MockTProtocol.
+type MockTProtocolMockRecorder struct {
mock *MockTProtocol
}
+// NewMockTProtocol creates a new mock instance.
func NewMockTProtocol(ctrl *gomock.Controller) *MockTProtocol {
mock := &MockTProtocol{ctrl: ctrl}
- mock.recorder = &_MockTProtocolRecorder{mock}
+ mock.recorder = &MockTProtocolMockRecorder{mock}
return mock
}
-func (_m *MockTProtocol) EXPECT() *_MockTProtocolRecorder {
- return _m.recorder
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockTProtocol) EXPECT() *MockTProtocolMockRecorder {
+ return m.recorder
}
-func (_m *MockTProtocol) Flush(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "Flush")
+// Flush mocks base method.
+func (m *MockTProtocol) Flush(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Flush", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) Flush(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "Flush")
+// Flush indicates an expected call of Flush.
+func (mr *MockTProtocolMockRecorder) Flush(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Flush", reflect.TypeOf((*MockTProtocol)(nil).Flush), arg0)
}
-func (_m *MockTProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
- ret := _m.ctrl.Call(_m, "ReadBinary", ctx)
+// ReadBinary mocks base method.
+func (m *MockTProtocol) ReadBinary(arg0 context.Context) ([]byte, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadBinary", arg0)
ret0, _ := ret[0].([]byte)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadBinary(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadBinary", ctx)
+// ReadBinary indicates an expected call of ReadBinary.
+func (mr *MockTProtocolMockRecorder) ReadBinary(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadBinary", reflect.TypeOf((*MockTProtocol)(nil).ReadBinary), arg0)
}
-func (_m *MockTProtocol) ReadBool(ctx context.Context) (bool, error) {
- ret := _m.ctrl.Call(_m, "ReadBool", ctx)
+// ReadBool mocks base method.
+func (m *MockTProtocol) ReadBool(arg0 context.Context) (bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadBool", arg0)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadBool(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadBool", ctx)
+// ReadBool indicates an expected call of ReadBool.
+func (mr *MockTProtocolMockRecorder) ReadBool(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadBool", reflect.TypeOf((*MockTProtocol)(nil).ReadBool), arg0)
}
-func (_m *MockTProtocol) ReadByte(ctx context.Context) (int8, error) {
- ret := _m.ctrl.Call(_m, "ReadByte", ctx)
+// ReadByte mocks base method.
+func (m *MockTProtocol) ReadByte(arg0 context.Context) (int8, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadByte", arg0)
ret0, _ := ret[0].(int8)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadByte(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadByte", ctx)
+// ReadByte indicates an expected call of ReadByte.
+func (mr *MockTProtocolMockRecorder) ReadByte(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadByte", reflect.TypeOf((*MockTProtocol)(nil).ReadByte), arg0)
}
-func (_m *MockTProtocol) ReadDouble(ctx context.Context) (float64, error) {
- ret := _m.ctrl.Call(_m, "ReadDouble", ctx)
+// ReadDouble mocks base method.
+func (m *MockTProtocol) ReadDouble(arg0 context.Context) (float64, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadDouble", arg0)
ret0, _ := ret[0].(float64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadDouble(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadDouble", ctx)
+// ReadDouble indicates an expected call of ReadDouble.
+func (mr *MockTProtocolMockRecorder) ReadDouble(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadDouble", reflect.TypeOf((*MockTProtocol)(nil).ReadDouble), arg0)
}
-func (_m *MockTProtocol) ReadFieldBegin(ctx context.Context) (string, thrift.TType, int16, error) {
- ret := _m.ctrl.Call(_m, "ReadFieldBegin", ctx)
+// ReadFieldBegin mocks base method.
+func (m *MockTProtocol) ReadFieldBegin(arg0 context.Context) (string, thrift.TType, int16, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadFieldBegin", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(thrift.TType)
ret2, _ := ret[2].(int16)
@@ -113,77 +120,105 @@ func (_m *MockTProtocol) ReadFieldBegin(ctx context.Context) (string, thrift.TTy
return ret0, ret1, ret2, ret3
}
-func (_mr *_MockTProtocolRecorder) ReadFieldBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadFieldBegin", ctx)
+// ReadFieldBegin indicates an expected call of ReadFieldBegin.
+func (mr *MockTProtocolMockRecorder) ReadFieldBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFieldBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadFieldBegin), arg0)
}
-func (_m *MockTProtocol) ReadFieldEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadFieldEnd", ctx)
+// ReadFieldEnd mocks base method.
+func (m *MockTProtocol) ReadFieldEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadFieldEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadFieldEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadFieldEnd", ctx)
+// ReadFieldEnd indicates an expected call of ReadFieldEnd.
+func (mr *MockTProtocolMockRecorder) ReadFieldEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadFieldEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadFieldEnd), arg0)
}
-func (_m *MockTProtocol) ReadI16(ctx context.Context) (int16, error) {
- ret := _m.ctrl.Call(_m, "ReadI16", ctx)
+// ReadI16 mocks base method.
+func (m *MockTProtocol) ReadI16(arg0 context.Context) (int16, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadI16", arg0)
ret0, _ := ret[0].(int16)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadI16(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI16", ctx)
+// ReadI16 indicates an expected call of ReadI16.
+func (mr *MockTProtocolMockRecorder) ReadI16(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadI16", reflect.TypeOf((*MockTProtocol)(nil).ReadI16), arg0)
}
-func (_m *MockTProtocol) ReadI32(ctx context.Context) (int32, error) {
- ret := _m.ctrl.Call(_m, "ReadI32", ctx)
+// ReadI32 mocks base method.
+func (m *MockTProtocol) ReadI32(arg0 context.Context) (int32, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadI32", arg0)
ret0, _ := ret[0].(int32)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadI32(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI32", ctx)
+// ReadI32 indicates an expected call of ReadI32.
+func (mr *MockTProtocolMockRecorder) ReadI32(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadI32", reflect.TypeOf((*MockTProtocol)(nil).ReadI32), arg0)
}
-func (_m *MockTProtocol) ReadI64(ctx context.Context) (int64, error) {
- ret := _m.ctrl.Call(_m, "ReadI64", ctx)
+// ReadI64 mocks base method.
+func (m *MockTProtocol) ReadI64(arg0 context.Context) (int64, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadI64", arg0)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadI64(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadI64", ctx)
+// ReadI64 indicates an expected call of ReadI64.
+func (mr *MockTProtocolMockRecorder) ReadI64(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadI64", reflect.TypeOf((*MockTProtocol)(nil).ReadI64), arg0)
}
-func (_m *MockTProtocol) ReadListBegin(ctx context.Context) (thrift.TType, int, error) {
- ret := _m.ctrl.Call(_m, "ReadListBegin", ctx)
+// ReadListBegin mocks base method.
+func (m *MockTProtocol) ReadListBegin(arg0 context.Context) (thrift.TType, int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadListBegin", arg0)
ret0, _ := ret[0].(thrift.TType)
ret1, _ := ret[1].(int)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
-func (_mr *_MockTProtocolRecorder) ReadListBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadListBegin", ctx)
+// ReadListBegin indicates an expected call of ReadListBegin.
+func (mr *MockTProtocolMockRecorder) ReadListBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadListBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadListBegin), arg0)
}
-func (_m *MockTProtocol) ReadListEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadListEnd", ctx)
+// ReadListEnd mocks base method.
+func (m *MockTProtocol) ReadListEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadListEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadListEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadListEnd", ctx)
+// ReadListEnd indicates an expected call of ReadListEnd.
+func (mr *MockTProtocolMockRecorder) ReadListEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadListEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadListEnd), arg0)
}
-func (_m *MockTProtocol) ReadMapBegin(ctx context.Context) (thrift.TType, thrift.TType, int, error) {
- ret := _m.ctrl.Call(_m, "ReadMapBegin", ctx)
+// ReadMapBegin mocks base method.
+func (m *MockTProtocol) ReadMapBegin(arg0 context.Context) (thrift.TType, thrift.TType, int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadMapBegin", arg0)
ret0, _ := ret[0].(thrift.TType)
ret1, _ := ret[1].(thrift.TType)
ret2, _ := ret[2].(int)
@@ -191,22 +226,30 @@ func (_m *MockTProtocol) ReadMapBegin(ctx context.Context) (thrift.TType, thrift
return ret0, ret1, ret2, ret3
}
-func (_mr *_MockTProtocolRecorder) ReadMapBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMapBegin", ctx)
+// ReadMapBegin indicates an expected call of ReadMapBegin.
+func (mr *MockTProtocolMockRecorder) ReadMapBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadMapBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadMapBegin), arg0)
}
-func (_m *MockTProtocol) ReadMapEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadMapEnd", ctx)
+// ReadMapEnd mocks base method.
+func (m *MockTProtocol) ReadMapEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadMapEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadMapEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMapEnd", ctx)
+// ReadMapEnd indicates an expected call of ReadMapEnd.
+func (mr *MockTProtocolMockRecorder) ReadMapEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadMapEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadMapEnd), arg0)
}
-func (_m *MockTProtocol) ReadMessageBegin(ctx context.Context) (string, thrift.TMessageType, int32, error) {
- ret := _m.ctrl.Call(_m, "ReadMessageBegin", ctx)
+// ReadMessageBegin mocks base method.
+func (m *MockTProtocol) ReadMessageBegin(arg0 context.Context) (string, thrift.TMessageType, int32, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadMessageBegin", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(thrift.TMessageType)
ret2, _ := ret[2].(int32)
@@ -214,300 +257,447 @@ func (_m *MockTProtocol) ReadMessageBegin(ctx context.Context) (string, thrift.T
return ret0, ret1, ret2, ret3
}
-func (_mr *_MockTProtocolRecorder) ReadMessageBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMessageBegin", ctx)
+// ReadMessageBegin indicates an expected call of ReadMessageBegin.
+func (mr *MockTProtocolMockRecorder) ReadMessageBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadMessageBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadMessageBegin), arg0)
}
-func (_m *MockTProtocol) ReadMessageEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadMessageEnd", ctx)
+// ReadMessageEnd mocks base method.
+func (m *MockTProtocol) ReadMessageEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadMessageEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadMessageEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadMessageEnd", ctx)
+// ReadMessageEnd indicates an expected call of ReadMessageEnd.
+func (mr *MockTProtocolMockRecorder) ReadMessageEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadMessageEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadMessageEnd), arg0)
}
-func (_m *MockTProtocol) ReadSetBegin(ctx context.Context) (thrift.TType, int, error) {
- ret := _m.ctrl.Call(_m, "ReadSetBegin", ctx)
+// ReadSetBegin mocks base method.
+func (m *MockTProtocol) ReadSetBegin(arg0 context.Context) (thrift.TType, int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadSetBegin", arg0)
ret0, _ := ret[0].(thrift.TType)
ret1, _ := ret[1].(int)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
-func (_mr *_MockTProtocolRecorder) ReadSetBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadSetBegin", ctx)
+// ReadSetBegin indicates an expected call of ReadSetBegin.
+func (mr *MockTProtocolMockRecorder) ReadSetBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadSetBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadSetBegin), arg0)
}
-func (_m *MockTProtocol) ReadSetEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadSetEnd", ctx)
+// ReadSetEnd mocks base method.
+func (m *MockTProtocol) ReadSetEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadSetEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadSetEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadSetEnd", ctx)
+// ReadSetEnd indicates an expected call of ReadSetEnd.
+func (mr *MockTProtocolMockRecorder) ReadSetEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadSetEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadSetEnd), arg0)
}
-func (_m *MockTProtocol) ReadString(ctx context.Context) (string, error) {
- ret := _m.ctrl.Call(_m, "ReadString", ctx)
+// ReadString mocks base method.
+func (m *MockTProtocol) ReadString(arg0 context.Context) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadString", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadString(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadString", ctx)
+// ReadString indicates an expected call of ReadString.
+func (mr *MockTProtocolMockRecorder) ReadString(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadString", reflect.TypeOf((*MockTProtocol)(nil).ReadString), arg0)
}
-func (_m *MockTProtocol) ReadStructBegin(ctx context.Context) (string, error) {
- ret := _m.ctrl.Call(_m, "ReadStructBegin", ctx)
+// ReadStructBegin mocks base method.
+func (m *MockTProtocol) ReadStructBegin(arg0 context.Context) (string, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadStructBegin", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
-func (_mr *_MockTProtocolRecorder) ReadStructBegin(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadStructBegin", ctx)
+// ReadStructBegin indicates an expected call of ReadStructBegin.
+func (mr *MockTProtocolMockRecorder) ReadStructBegin(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadStructBegin", reflect.TypeOf((*MockTProtocol)(nil).ReadStructBegin), arg0)
}
-func (_m *MockTProtocol) ReadStructEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "ReadStructEnd", ctx)
+// ReadStructEnd mocks base method.
+func (m *MockTProtocol) ReadStructEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadStructEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) ReadStructEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "ReadStructEnd", ctx)
+// ReadStructEnd indicates an expected call of ReadStructEnd.
+func (mr *MockTProtocolMockRecorder) ReadStructEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadStructEnd", reflect.TypeOf((*MockTProtocol)(nil).ReadStructEnd), arg0)
+}
+
+// ReadUUID mocks base method.
+func (m *MockTProtocol) ReadUUID(arg0 context.Context) (thrift.Tuuid, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ReadUUID", arg0)
+ ret0, _ := ret[0].(thrift.Tuuid)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ReadUUID indicates an expected call of ReadUUID.
+func (mr *MockTProtocolMockRecorder) ReadUUID(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadUUID", reflect.TypeOf((*MockTProtocol)(nil).ReadUUID), arg0)
}
-func (_m *MockTProtocol) Skip(ctx context.Context, _param0 thrift.TType) error {
- ret := _m.ctrl.Call(_m, "Skip", ctx, _param0)
+// Skip mocks base method.
+func (m *MockTProtocol) Skip(arg0 context.Context, arg1 thrift.TType) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Skip", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) Skip(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "Skip", ctx, arg0)
+// Skip indicates an expected call of Skip.
+func (mr *MockTProtocolMockRecorder) Skip(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Skip", reflect.TypeOf((*MockTProtocol)(nil).Skip), arg0, arg1)
}
-func (_m *MockTProtocol) Transport() thrift.TTransport {
- ret := _m.ctrl.Call(_m, "Transport")
+// Transport mocks base method.
+func (m *MockTProtocol) Transport() thrift.TTransport {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Transport")
ret0, _ := ret[0].(thrift.TTransport)
return ret0
}
-func (_mr *_MockTProtocolRecorder) Transport() *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "Transport")
+// Transport indicates an expected call of Transport.
+func (mr *MockTProtocolMockRecorder) Transport() *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Transport", reflect.TypeOf((*MockTProtocol)(nil).Transport))
+}
+
+// WriteBinary mocks base method.
+func (m *MockTProtocol) WriteBinary(arg0 context.Context, arg1 []byte) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteBinary", arg0, arg1)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// WriteBinary indicates an expected call of WriteBinary.
+func (mr *MockTProtocolMockRecorder) WriteBinary(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteBinary", reflect.TypeOf((*MockTProtocol)(nil).WriteBinary), arg0, arg1)
}
-func (_m *MockTProtocol) WriteBinary(ctx context.Context, _param0 []byte) error {
- ret := _m.ctrl.Call(_m, "WriteBinary", ctx, _param0)
+// WriteBool mocks base method.
+func (m *MockTProtocol) WriteBool(arg0 context.Context, arg1 bool) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteBool", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteBinary(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteBinary", ctx, arg0)
+// WriteBool indicates an expected call of WriteBool.
+func (mr *MockTProtocolMockRecorder) WriteBool(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteBool", reflect.TypeOf((*MockTProtocol)(nil).WriteBool), arg0, arg1)
}
-func (_m *MockTProtocol) WriteBool(ctx context.Context, _param0 bool) error {
- ret := _m.ctrl.Call(_m, "WriteBool", ctx, _param0)
+// WriteByte mocks base method.
+func (m *MockTProtocol) WriteByte(arg0 context.Context, arg1 int8) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteByte", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteBool(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteBool", ctx, arg0)
+// WriteByte indicates an expected call of WriteByte.
+func (mr *MockTProtocolMockRecorder) WriteByte(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteByte", reflect.TypeOf((*MockTProtocol)(nil).WriteByte), arg0, arg1)
}
-func (_m *MockTProtocol) WriteByte(ctx context.Context, _param0 int8) error {
- ret := _m.ctrl.Call(_m, "WriteByte", ctx, _param0)
+// WriteDouble mocks base method.
+func (m *MockTProtocol) WriteDouble(arg0 context.Context, arg1 float64) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteDouble", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteByte(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteByte", ctx, arg0)
+// WriteDouble indicates an expected call of WriteDouble.
+func (mr *MockTProtocolMockRecorder) WriteDouble(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteDouble", reflect.TypeOf((*MockTProtocol)(nil).WriteDouble), arg0, arg1)
}
-func (_m *MockTProtocol) WriteDouble(ctx context.Context, _param0 float64) error {
- ret := _m.ctrl.Call(_m, "WriteDouble", ctx, _param0)
+// WriteFieldBegin mocks base method.
+func (m *MockTProtocol) WriteFieldBegin(arg0 context.Context, arg1 string, arg2 thrift.TType, arg3 int16) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteFieldBegin", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteDouble(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteDouble", ctx, arg0)
+// WriteFieldBegin indicates an expected call of WriteFieldBegin.
+func (mr *MockTProtocolMockRecorder) WriteFieldBegin(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteFieldBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteFieldBegin), arg0, arg1, arg2, arg3)
}
-func (_m *MockTProtocol) WriteFieldBegin(ctx context.Context, _param0 string, _param1 thrift.TType, _param2 int16) error {
- ret := _m.ctrl.Call(_m, "WriteFieldBegin", ctx, _param0, _param1, _param2)
+// WriteFieldEnd mocks base method.
+func (m *MockTProtocol) WriteFieldEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteFieldEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteFieldBegin(ctx context.Context, arg0, arg1, arg2 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldBegin", ctx, arg0, arg1, arg2)
+// WriteFieldEnd indicates an expected call of WriteFieldEnd.
+func (mr *MockTProtocolMockRecorder) WriteFieldEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteFieldEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteFieldEnd), arg0)
}
-func (_m *MockTProtocol) WriteFieldEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteFieldEnd", ctx)
+// WriteFieldStop mocks base method.
+func (m *MockTProtocol) WriteFieldStop(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteFieldStop", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteFieldEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldEnd", ctx)
+// WriteFieldStop indicates an expected call of WriteFieldStop.
+func (mr *MockTProtocolMockRecorder) WriteFieldStop(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteFieldStop", reflect.TypeOf((*MockTProtocol)(nil).WriteFieldStop), arg0)
}
-func (_m *MockTProtocol) WriteFieldStop(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteFieldStop", ctx)
+// WriteI16 mocks base method.
+func (m *MockTProtocol) WriteI16(arg0 context.Context, arg1 int16) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteI16", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteFieldStop(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteFieldStop", ctx)
+// WriteI16 indicates an expected call of WriteI16.
+func (mr *MockTProtocolMockRecorder) WriteI16(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteI16", reflect.TypeOf((*MockTProtocol)(nil).WriteI16), arg0, arg1)
}
-func (_m *MockTProtocol) WriteI16(ctx context.Context, _param0 int16) error {
- ret := _m.ctrl.Call(_m, "WriteI16", ctx, _param0)
+// WriteI32 mocks base method.
+func (m *MockTProtocol) WriteI32(arg0 context.Context, arg1 int32) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteI32", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteI16(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI16", ctx, arg0)
+// WriteI32 indicates an expected call of WriteI32.
+func (mr *MockTProtocolMockRecorder) WriteI32(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteI32", reflect.TypeOf((*MockTProtocol)(nil).WriteI32), arg0, arg1)
}
-func (_m *MockTProtocol) WriteI32(ctx context.Context, _param0 int32) error {
- ret := _m.ctrl.Call(_m, "WriteI32", ctx, _param0)
+// WriteI64 mocks base method.
+func (m *MockTProtocol) WriteI64(arg0 context.Context, arg1 int64) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteI64", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteI32(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI32", ctx, arg0)
+// WriteI64 indicates an expected call of WriteI64.
+func (mr *MockTProtocolMockRecorder) WriteI64(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteI64", reflect.TypeOf((*MockTProtocol)(nil).WriteI64), arg0, arg1)
}
-func (_m *MockTProtocol) WriteI64(ctx context.Context, _param0 int64) error {
- ret := _m.ctrl.Call(_m, "WriteI64", ctx, _param0)
+// WriteListBegin mocks base method.
+func (m *MockTProtocol) WriteListBegin(arg0 context.Context, arg1 thrift.TType, arg2 int) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteListBegin", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteI64(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteI64", ctx, arg0)
+// WriteListBegin indicates an expected call of WriteListBegin.
+func (mr *MockTProtocolMockRecorder) WriteListBegin(arg0, arg1, arg2 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteListBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteListBegin), arg0, arg1, arg2)
}
-func (_m *MockTProtocol) WriteListBegin(ctx context.Context, _param0 thrift.TType, _param1 int) error {
- ret := _m.ctrl.Call(_m, "WriteListBegin", ctx, _param0, _param1)
+// WriteListEnd mocks base method.
+func (m *MockTProtocol) WriteListEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteListEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteListBegin(ctx context.Context, arg0, arg1 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteListBegin", ctx, arg0, arg1)
+// WriteListEnd indicates an expected call of WriteListEnd.
+func (mr *MockTProtocolMockRecorder) WriteListEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteListEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteListEnd), arg0)
}
-func (_m *MockTProtocol) WriteListEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteListEnd", ctx)
+// WriteMapBegin mocks base method.
+func (m *MockTProtocol) WriteMapBegin(arg0 context.Context, arg1, arg2 thrift.TType, arg3 int) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteMapBegin", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteListEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteListEnd", ctx)
+// WriteMapBegin indicates an expected call of WriteMapBegin.
+func (mr *MockTProtocolMockRecorder) WriteMapBegin(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteMapBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteMapBegin), arg0, arg1, arg2, arg3)
}
-func (_m *MockTProtocol) WriteMapBegin(ctx context.Context, _param0 thrift.TType, _param1 thrift.TType, _param2 int) error {
- ret := _m.ctrl.Call(_m, "WriteMapBegin", ctx, _param0, _param1, _param2)
+// WriteMapEnd mocks base method.
+func (m *MockTProtocol) WriteMapEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteMapEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteMapBegin(ctx context.Context, arg0, arg1, arg2 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMapBegin", ctx, arg0, arg1, arg2)
+// WriteMapEnd indicates an expected call of WriteMapEnd.
+func (mr *MockTProtocolMockRecorder) WriteMapEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteMapEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteMapEnd), arg0)
}
-func (_m *MockTProtocol) WriteMapEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteMapEnd", ctx)
+// WriteMessageBegin mocks base method.
+func (m *MockTProtocol) WriteMessageBegin(arg0 context.Context, arg1 string, arg2 thrift.TMessageType, arg3 int32) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteMessageBegin", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteMapEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMapEnd", ctx)
+// WriteMessageBegin indicates an expected call of WriteMessageBegin.
+func (mr *MockTProtocolMockRecorder) WriteMessageBegin(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteMessageBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteMessageBegin), arg0, arg1, arg2, arg3)
}
-func (_m *MockTProtocol) WriteMessageBegin(ctx context.Context, _param0 string, _param1 thrift.TMessageType, _param2 int32) error {
- ret := _m.ctrl.Call(_m, "WriteMessageBegin", ctx, _param0, _param1, _param2)
+// WriteMessageEnd mocks base method.
+func (m *MockTProtocol) WriteMessageEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteMessageEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteMessageBegin(ctx context.Context, arg0, arg1, arg2 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMessageBegin", ctx, arg0, arg1, arg2)
+// WriteMessageEnd indicates an expected call of WriteMessageEnd.
+func (mr *MockTProtocolMockRecorder) WriteMessageEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteMessageEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteMessageEnd), arg0)
}
-func (_m *MockTProtocol) WriteMessageEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteMessageEnd", ctx)
+// WriteSetBegin mocks base method.
+func (m *MockTProtocol) WriteSetBegin(arg0 context.Context, arg1 thrift.TType, arg2 int) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteSetBegin", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteMessageEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteMessageEnd", ctx)
+// WriteSetBegin indicates an expected call of WriteSetBegin.
+func (mr *MockTProtocolMockRecorder) WriteSetBegin(arg0, arg1, arg2 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSetBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteSetBegin), arg0, arg1, arg2)
}
-func (_m *MockTProtocol) WriteSetBegin(ctx context.Context, _param0 thrift.TType, _param1 int) error {
- ret := _m.ctrl.Call(_m, "WriteSetBegin", ctx, _param0, _param1)
+// WriteSetEnd mocks base method.
+func (m *MockTProtocol) WriteSetEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteSetEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteSetBegin(ctx context.Context, arg0, arg1 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteSetBegin", ctx, arg0, arg1)
+// WriteSetEnd indicates an expected call of WriteSetEnd.
+func (mr *MockTProtocolMockRecorder) WriteSetEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSetEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteSetEnd), arg0)
}
-func (_m *MockTProtocol) WriteSetEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteSetEnd", ctx)
+// WriteString mocks base method.
+func (m *MockTProtocol) WriteString(arg0 context.Context, arg1 string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteString", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteSetEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteSetEnd", ctx)
+// WriteString indicates an expected call of WriteString.
+func (mr *MockTProtocolMockRecorder) WriteString(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteString", reflect.TypeOf((*MockTProtocol)(nil).WriteString), arg0, arg1)
}
-func (_m *MockTProtocol) WriteString(ctx context.Context, _param0 string) error {
- ret := _m.ctrl.Call(_m, "WriteString", ctx, _param0)
+// WriteStructBegin mocks base method.
+func (m *MockTProtocol) WriteStructBegin(arg0 context.Context, arg1 string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteStructBegin", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteString(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteString", ctx, arg0)
+// WriteStructBegin indicates an expected call of WriteStructBegin.
+func (mr *MockTProtocolMockRecorder) WriteStructBegin(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteStructBegin", reflect.TypeOf((*MockTProtocol)(nil).WriteStructBegin), arg0, arg1)
}
-func (_m *MockTProtocol) WriteStructBegin(ctx context.Context, _param0 string) error {
- ret := _m.ctrl.Call(_m, "WriteStructBegin", ctx, _param0)
+// WriteStructEnd mocks base method.
+func (m *MockTProtocol) WriteStructEnd(arg0 context.Context) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteStructEnd", arg0)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteStructBegin(ctx context.Context, arg0 interface{}) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteStructBegin", ctx, arg0)
+// WriteStructEnd indicates an expected call of WriteStructEnd.
+func (mr *MockTProtocolMockRecorder) WriteStructEnd(arg0 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteStructEnd", reflect.TypeOf((*MockTProtocol)(nil).WriteStructEnd), arg0)
}
-func (_m *MockTProtocol) WriteStructEnd(ctx context.Context) error {
- ret := _m.ctrl.Call(_m, "WriteStructEnd", ctx)
+// WriteUUID mocks base method.
+func (m *MockTProtocol) WriteUUID(arg0 context.Context, arg1 thrift.Tuuid) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "WriteUUID", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
-func (_mr *_MockTProtocolRecorder) WriteStructEnd(ctx context.Context) *gomock.Call {
- return _mr.mock.ctrl.RecordCall(_mr.mock, "WriteStructEnd", ctx)
+// WriteUUID indicates an expected call of WriteUUID.
+func (mr *MockTProtocolMockRecorder) WriteUUID(arg0, arg1 interface{}) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteUUID", reflect.TypeOf((*MockTProtocol)(nil).WriteUUID), arg0, arg1)
}
diff --git a/lib/go/thrift/binary_protocol.go b/lib/go/thrift/binary_protocol.go
index c6fae0f59..eded93134 100644
--- a/lib/go/thrift/binary_protocol.go
+++ b/lib/go/thrift/binary_protocol.go
@@ -260,6 +260,11 @@ func (p *TBinaryProtocol) WriteBinary(ctx context.Context, value []byte) error {
return NewTProtocolException(err)
}
+func (p *TBinaryProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ _, err := p.trans.Write(value[:])
+ return NewTProtocolException(err)
+}
+
/**
* Reading methods
*/
@@ -488,6 +493,15 @@ func (p *TBinaryProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
return buf, NewTProtocolException(err)
}
+func (p *TBinaryProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ buf := p.buffer[0:16]
+ err = p.readAll(ctx, buf)
+ if err == nil {
+ copy(value[:], buf)
+ }
+ return value, err
+}
+
func (p *TBinaryProtocol) Flush(ctx context.Context) (err error) {
return NewTProtocolException(p.trans.Flush(ctx))
}
diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
index dc86fe605..18915fee8 100644
--- a/lib/go/thrift/compact_protocol.go
+++ b/lib/go/thrift/compact_protocol.go
@@ -52,6 +52,7 @@ const (
COMPACT_SET = 0x0A
COMPACT_MAP = 0x0B
COMPACT_STRUCT = 0x0C
+ COMPACT_UUID = 0x0D
)
var (
@@ -72,6 +73,7 @@ func init() {
SET: COMPACT_SET,
MAP: COMPACT_MAP,
STRUCT: COMPACT_STRUCT,
+ UUID: COMPACT_UUID,
}
}
@@ -354,6 +356,12 @@ func (p *TCompactProtocol) WriteBinary(ctx context.Context, bin []byte) error {
return nil
}
+// Write a Tuuid to the wire as 16 bytes.
+func (p *TCompactProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ _, err := p.trans.Write(value[:])
+ return NewTProtocolException(err)
+}
+
//
// Reading methods.
//
@@ -639,6 +647,16 @@ func (p *TCompactProtocol) ReadBinary(ctx context.Context) (value []byte, err er
return buf, NewTProtocolException(e)
}
+// Read fixed 16 bytes as UUID.
+func (p *TCompactProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ buf := p.buffer[0:16]
+ _, e := io.ReadFull(p.trans, buf)
+ if e == nil {
+ copy(value[:], buf)
+ }
+ return value, NewTProtocolException(e)
+}
+
func (p *TCompactProtocol) Flush(ctx context.Context) (err error) {
return NewTProtocolException(p.trans.Flush(ctx))
}
@@ -825,6 +843,8 @@ func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) {
return MAP, nil
case COMPACT_STRUCT:
return STRUCT, nil
+ case COMPACT_UUID:
+ return UUID, nil
}
return STOP, NewTProtocolException(fmt.Errorf("don't know what type: %v", t&0x0f))
}
diff --git a/lib/go/thrift/debug_protocol.go b/lib/go/thrift/debug_protocol.go
index c1f4fab4c..83ccad94b 100644
--- a/lib/go/thrift/debug_protocol.go
+++ b/lib/go/thrift/debug_protocol.go
@@ -258,6 +258,14 @@ func (tdp *TDebugProtocol) WriteBinary(ctx context.Context, value []byte) error
}
return err
}
+func (tdp *TDebugProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ err := tdp.Delegate.WriteUUID(ctx, value)
+ tdp.logf("%sWriteUUID(value=%#v) => %#v", tdp.LogPrefix, value, err)
+ if tdp.DuplicateTo != nil {
+ tdp.DuplicateTo.WriteUUID(ctx, value)
+ }
+ return err
+}
func (tdp *TDebugProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error) {
name, typeId, seqid, err = tdp.Delegate.ReadMessageBegin(ctx)
@@ -419,6 +427,14 @@ func (tdp *TDebugProtocol) ReadBinary(ctx context.Context) (value []byte, err er
}
return
}
+func (tdp *TDebugProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ value, err = tdp.Delegate.ReadUUID(ctx)
+ tdp.logf("%sReadUUID() (value=%#v, err=%#v)", tdp.LogPrefix, value, err)
+ if tdp.DuplicateTo != nil {
+ tdp.DuplicateTo.WriteUUID(ctx, value)
+ }
+ return
+}
func (tdp *TDebugProtocol) Skip(ctx context.Context, fieldType TType) (err error) {
err = tdp.Delegate.Skip(ctx, fieldType)
tdp.logf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err)
diff --git a/lib/go/thrift/duplicate_protocol.go b/lib/go/thrift/duplicate_protocol.go
index c23d548c3..6413909d4 100644
--- a/lib/go/thrift/duplicate_protocol.go
+++ b/lib/go/thrift/duplicate_protocol.go
@@ -166,6 +166,12 @@ func (tdtp *TDuplicateToProtocol) WriteBinary(ctx context.Context, value []byte)
return err
}
+func (tdtp *TDuplicateToProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ err := tdtp.Delegate.WriteUUID(ctx, value)
+ tdtp.DuplicateTo.WriteUUID(ctx, value)
+ return err
+}
+
func (tdtp *TDuplicateToProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error) {
name, typeId, seqid, err = tdtp.Delegate.ReadMessageBegin(ctx)
tdtp.DuplicateTo.WriteMessageBegin(ctx, name, typeId, seqid)
@@ -286,6 +292,12 @@ func (tdtp *TDuplicateToProtocol) ReadBinary(ctx context.Context) (value []byte,
return
}
+func (tdtp *TDuplicateToProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ value, err = tdtp.Delegate.ReadUUID(ctx)
+ tdtp.DuplicateTo.WriteUUID(ctx, value)
+ return
+}
+
func (tdtp *TDuplicateToProtocol) Skip(ctx context.Context, fieldType TType) (err error) {
err = tdtp.Delegate.Skip(ctx, fieldType)
tdtp.DuplicateTo.Skip(ctx, fieldType)
diff --git a/lib/go/thrift/header_protocol.go b/lib/go/thrift/header_protocol.go
index 878041f8d..36777b4ca 100644
--- a/lib/go/thrift/header_protocol.go
+++ b/lib/go/thrift/header_protocol.go
@@ -221,6 +221,10 @@ func (p *THeaderProtocol) WriteBinary(ctx context.Context, value []byte) error {
return p.protocol.WriteBinary(ctx, value)
}
+func (p *THeaderProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ return p.protocol.WriteUUID(ctx, value)
+}
+
// ReadFrame calls underlying THeaderTransport's ReadFrame function.
func (p *THeaderProtocol) ReadFrame(ctx context.Context) error {
return p.transport.ReadFrame(ctx)
@@ -334,6 +338,10 @@ func (p *THeaderProtocol) ReadBinary(ctx context.Context) (value []byte, err err
return p.protocol.ReadBinary(ctx)
}
+func (p *THeaderProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ return p.protocol.ReadUUID(ctx)
+}
+
func (p *THeaderProtocol) Skip(ctx context.Context, fieldType TType) error {
return p.protocol.Skip(ctx, fieldType)
}
diff --git a/lib/go/thrift/json_protocol.go b/lib/go/thrift/json_protocol.go
index d248ecfee..8b1bb52f4 100644
--- a/lib/go/thrift/json_protocol.go
+++ b/lib/go/thrift/json_protocol.go
@@ -33,7 +33,6 @@ const (
// JSON protocol implementation for thrift.
// Utilizes Simple JSON protocol
-//
type TJSONProtocol struct {
*TSimpleJSONProtocol
}
diff --git a/lib/go/thrift/pointerize.go b/lib/go/thrift/pointerize.go
index e200c68b6..1eddfa70c 100644
--- a/lib/go/thrift/pointerize.go
+++ b/lib/go/thrift/pointerize.go
@@ -56,3 +56,4 @@ func Uint32Ptr(v uint32) *uint32 { return &v }
func Uint64Ptr(v uint64) *uint64 { return &v }
func BoolPtr(v bool) *bool { return &v }
func ByteSlicePtr(v []byte) *[]byte { return &v }
+func TuuidPtr(v Tuuid) *Tuuid { return &v }
diff --git a/lib/go/thrift/protocol.go b/lib/go/thrift/protocol.go
index 647c0bdd6..2ee14caaa 100644
--- a/lib/go/thrift/protocol.go
+++ b/lib/go/thrift/protocol.go
@@ -52,6 +52,7 @@ type TProtocol interface {
WriteDouble(ctx context.Context, value float64) error
WriteString(ctx context.Context, value string) error
WriteBinary(ctx context.Context, value []byte) error
+ WriteUUID(ctx context.Context, value Tuuid) error
ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqid int32, err error)
ReadMessageEnd(ctx context.Context) error
@@ -73,6 +74,7 @@ type TProtocol interface {
ReadDouble(ctx context.Context) (value float64, err error)
ReadString(ctx context.Context) (value string, err error)
ReadBinary(ctx context.Context) (value []byte, err error)
+ ReadUUID(ctx context.Context) (value Tuuid, err error)
Skip(ctx context.Context, fieldType TType) (err error)
Flush(ctx context.Context) (err error)
@@ -117,6 +119,9 @@ func Skip(ctx context.Context, self TProtocol, fieldType TType, maxDepth int) (e
case STRING:
_, err = self.ReadString(ctx)
return
+ case UUID:
+ _, err = self.ReadUUID(ctx)
+ return
case STRUCT:
if _, err = self.ReadStructBegin(ctx); err != nil {
return err
diff --git a/lib/go/thrift/protocol_test.go b/lib/go/thrift/protocol_test.go
index d66dc65c2..1093c94a9 100644
--- a/lib/go/thrift/protocol_test.go
+++ b/lib/go/thrift/protocol_test.go
@@ -40,6 +40,7 @@ var (
INT64_VALUES []int64
DOUBLE_VALUES []float64
STRING_VALUES []string
+ UUID_VALUES []Tuuid
)
func init() {
@@ -54,6 +55,13 @@ func init() {
INT64_VALUES = []int64{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535, 34359738481, -35184372088719, -9223372036854775808, 9223372036854775807}
DOUBLE_VALUES = []float64{459.3, 0.0, -1.0, 1.0, 0.5, 0.3333, 3.14159, 1.537e-38, 1.673e25, 6.02214179e23, -6.02214179e23, INFINITY.Float64(), NEGATIVE_INFINITY.Float64(), NAN.Float64()}
STRING_VALUES = []string{"", "a", "st[uf]f", "st,u:ff with spaces", "stuff\twith\nescape\\characters'...\"lots{of}fun</xml>"}
+ UUID_VALUES = []Tuuid{
+ {},
+ Must(ParseTuuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b811-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b812-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b814-9dad-11d1-80b4-00c04fd430c8")),
+ }
}
type HTTPEchoServer struct{}
@@ -211,10 +219,21 @@ func ReadWriteProtocolTest(t *testing.T, protocolFactory TProtocolFactory) {
continue
}
p := protocolFactory.GetProtocol(trans)
+ ReadWriteUUID(t, p, trans)
+ trans.Close()
+ }
+ for _, tf := range transports {
+ trans, err := tf.GetTransport(nil)
+ if err != nil {
+ t.Error(err)
+ continue
+ }
+ p := protocolFactory.GetProtocol(trans)
ReadWriteI64(t, p, trans)
ReadWriteDouble(t, p, trans)
ReadWriteBinary(t, p, trans)
ReadWriteByte(t, p, trans)
+ ReadWriteUUID(t, p, trans)
trans.Close()
}
@@ -520,6 +539,43 @@ func ReadWriteBinary(t testing.TB, p TProtocol, trans TTransport) {
}
}
+func ReadWriteUUID(t testing.TB, p TProtocol, trans TTransport) {
+ ctx := context.Background()
+ thetype := TType(UUID)
+ thelen := len(UUID_VALUES)
+ p.WriteListBegin(ctx, thetype, thelen)
+ for _, v := range UUID_VALUES {
+ p.WriteUUID(ctx, v)
+ }
+ p.WriteListEnd(ctx)
+ p.Flush(ctx)
+ thetype2, thelen2, err := p.ReadListBegin(ctx)
+ if err != nil {
+ t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteUUID", p, trans, err, STRING_VALUES)
+ }
+ _, ok := p.(*TSimpleJSONProtocol)
+ if !ok {
+ if thetype != thetype2 {
+ t.Errorf("%s: %T %T type %s != type %s", "ReadWriteUUID", p, trans, thetype, thetype2)
+ }
+ if thelen != thelen2 {
+ t.Errorf("%s: %T %T len %v != len %v", "ReadWriteUUID", p, trans, thelen, thelen2)
+ }
+ }
+ for k, v := range UUID_VALUES {
+ value, err := p.ReadUUID(ctx)
+ if err != nil {
+ t.Errorf("%s: %T %T %q Error reading UUID at index %d: %q", "ReadWriteUUID", p, trans, err, k, v)
+ }
+ if v != value {
+ t.Errorf("%s: %T %T %v != %v", "ReadWriteUUID", p, trans, v, value)
+ }
+ }
+ if err != nil {
+ t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteUUID", p, trans, err)
+ }
+}
+
func UnmatchedBeginEndProtocolTest(t *testing.T, protocolFactory TProtocolFactory) {
// NOTE: not all protocol implementations do strict state check to
// return an error on unmatched Begin/End calls.
diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go
index 5cefb600a..8b1284fd1 100644
--- a/lib/go/thrift/simple_json_protocol.go
+++ b/lib/go/thrift/simple_json_protocol.go
@@ -93,7 +93,6 @@ var errEmptyJSONContextStack = NewTProtocolExceptionWithType(INVALID_DATA, error
// This protocol produces/consumes a simple output format
// suitable for parsing by scripting languages. It should not be
// confused with the full-featured TJSONProtocol.
-//
type TSimpleJSONProtocol struct {
trans TTransport
@@ -341,6 +340,10 @@ func (p *TSimpleJSONProtocol) WriteBinary(ctx context.Context, v []byte) error {
return p.OutputPostValue()
}
+func (p *TSimpleJSONProtocol) WriteUUID(ctx context.Context, v Tuuid) error {
+ return p.OutputString(v.String())
+}
+
// Reading methods.
func (p *TSimpleJSONProtocol) ReadMessageBegin(ctx context.Context) (name string, typeId TMessageType, seqId int32, err error) {
p.resetContextStack() // THRIFT-3735
@@ -595,6 +598,16 @@ func (p *TSimpleJSONProtocol) ReadBinary(ctx context.Context) ([]byte, error) {
return v, p.ParsePostValue()
}
+func (p *TSimpleJSONProtocol) ReadUUID(ctx context.Context) (v Tuuid, err error) {
+ var s string
+ s, err = p.ReadString(ctx)
+ if err != nil {
+ return v, err
+ }
+ v, err = ParseTuuid(s)
+ return v, NewTProtocolExceptionWithType(INVALID_DATA, err)
+}
+
func (p *TSimpleJSONProtocol) Flush(ctx context.Context) (err error) {
return NewTProtocolException(p.writer.Flush())
}
diff --git a/lib/go/thrift/type.go b/lib/go/thrift/type.go
index 4292ffcad..687557eab 100644
--- a/lib/go/thrift/type.go
+++ b/lib/go/thrift/type.go
@@ -38,9 +38,7 @@ const (
MAP = 13
SET = 14
LIST = 15
- UTF8 = 16
- UTF16 = 17
- //BINARY = 18 wrong and unusued
+ UUID = 16
)
var typeNames = map[int]string{
@@ -57,8 +55,7 @@ var typeNames = map[int]string{
MAP: "MAP",
SET: "SET",
LIST: "LIST",
- UTF8: "UTF8",
- UTF16: "UTF16",
+ UUID: "UUID",
}
func (p TType) String() string {
diff --git a/lib/go/thrift/uuid.go b/lib/go/thrift/uuid.go
new file mode 100644
index 000000000..ab47331c1
--- /dev/null
+++ b/lib/go/thrift/uuid.go
@@ -0,0 +1,130 @@
+/*
+ * 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 (
+ "encoding/hex"
+ "fmt"
+)
+
+// Tuuid is a minimal implementation of UUID for thrift's read/write operations.
+//
+// This implementation only covers read/write in various thrift protocols.
+// If you need to generate/manipulate/etc. an UUID,
+// you likely would need a third party UUID library instead.
+//
+// This type should be directly cast-able with most popular third party UUID
+// libraries.
+// For example, assuming you are using
+// https://pkg.go.dev/github.com/google/uuid to generate a v4 UUID for an
+// optional thrift field:
+//
+// id, err := uuid.NewRandom()
+// if err != nil {
+// // TODO: handle errors
+// }
+// myRequest.Uuid = thrift.Pointer(thrift.Tuuid(id))
+type Tuuid [16]byte
+
+// String generates the canonical form string for an Tuuid.
+//
+// This string is suitable for writing with TJSONProtocol.
+func (u Tuuid) String() string {
+ var buf [36]byte
+ hex.Encode(buf[0:], u[:4])
+ buf[8] = '-'
+ hex.Encode(buf[9:], u[4:6])
+ buf[13] = '-'
+ hex.Encode(buf[14:], u[6:8])
+ buf[18] = '-'
+ hex.Encode(buf[19:], u[8:10])
+ buf[23] = '-'
+ hex.Encode(buf[24:], u[10:])
+ return string(buf[:])
+}
+
+func hexToDec(b byte) (byte, bool) {
+ switch {
+ case b >= '0' && b <= '9':
+ return b - '0', true
+ case b >= 'a' && b <= 'f':
+ return b - 'a' + 10, true
+ case b >= 'A' && b <= 'F':
+ return b - 'A' + 10, true
+ default:
+ return 0, false
+ }
+}
+
+func hexToByte(b1, b2 byte) (b byte, ok bool) {
+ b1, ok = hexToDec(b1)
+ if !ok {
+ return 0, ok
+ }
+ b2, ok = hexToDec(b2)
+ if !ok {
+ return 0, ok
+ }
+ return b1<<4 + b2, true
+}
+
+// ParseTuuid parses a canonical form UUID string into Tuuid.
+//
+// Note that this function only supports case insensitive canonical form
+// (8-4-4-4-12/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),
+// and rejects any other forms.
+// For a more flexible UUID string parser,
+// please use third party UUID libraries.
+//
+// This function is suitable for reading with TJSONProtocol.
+func ParseTuuid(s string) (u Tuuid, err error) {
+ if len(s) != 36 || s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
+ return u, fmt.Errorf("malformed Tuuid string: %q", s)
+ }
+ var ok bool
+ for i, j := range []int{
+ 0, 2, 4, 6,
+ 9, 11,
+ 14, 16,
+ 19, 21,
+ 24, 26, 28, 30, 32, 34,
+ } {
+ u[i], ok = hexToByte(s[j], s[j+1])
+ if !ok {
+ return u, fmt.Errorf("malformed Tuuid string: %q", s)
+ }
+ }
+ return u, nil
+}
+
+// Must is a sugar to be used in places that error handling is impossible (for
+// example, global variable declarations) and also errors are not in general
+// expected.
+//
+// This is an example to use Must with ParseTuuid to declare a global special
+// uuid:
+//
+// var NameSpaceDNSUUID = thrift.Must(thrift.ParseTuuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
+func Must[T any](v T, err error) T {
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
diff --git a/lib/go/thrift/uuid_test.go b/lib/go/thrift/uuid_test.go
new file mode 100644
index 000000000..450400c9b
--- /dev/null
+++ b/lib/go/thrift/uuid_test.go
@@ -0,0 +1,290 @@
+/*
+ * 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 (
+ "fmt"
+ "testing"
+ "testing/quick"
+)
+
+func TestHexToByte(t *testing.T) {
+ for _, c := range []struct {
+ s string
+ b byte
+ fail bool
+ }{
+ {
+ s: "ff",
+ b: 0xff,
+ },
+ {
+ s: "FF",
+ b: 0xff,
+ },
+ {
+ s: "00",
+ b: 0,
+ },
+ {
+ s: "77",
+ b: 0x77,
+ },
+ {
+ s: "aC",
+ b: 0xac,
+ },
+ {
+ s: "xx",
+ fail: true,
+ },
+ {
+ s: "x0",
+ fail: true,
+ },
+ {
+ s: "fx",
+ fail: true,
+ },
+ } {
+ t.Run(c.s, func(t *testing.T) {
+ b, ok := hexToByte(c.s[0], c.s[1])
+ if ok != !c.fail {
+ t.Errorf("Want failure, got %x, %v", b, ok)
+ }
+ if !c.fail && b != c.b {
+ t.Errorf("Want %x, got %x", c.b, b)
+ }
+ })
+ }
+}
+
+func TestUUIDString(t *testing.T) {
+ for _, c := range []struct {
+ uuid Tuuid
+ want string
+ }{
+ {
+ uuid: Tuuid{},
+ want: "00000000-0000-0000-0000-000000000000",
+ },
+ {
+ uuid: Tuuid{
+ 0x6b, 0xa7, 0xb8, 0x10,
+ 0x9d, 0xad,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ want: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
+ },
+ {
+ uuid: Tuuid{
+ 0x6b, 0xa7, 0xB8, 0x11,
+ 0x9d, 0xAd,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ want: "6ba7b811-9dad-11d1-80b4-00c04fd430c8",
+ },
+ {
+ uuid: Tuuid{
+ 0x6b, 0xa7, 0xb8, 0x12,
+ 0x9d, 0xad,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ want: "6ba7b812-9dad-11d1-80b4-00c04fd430c8",
+ },
+ {
+ uuid: Tuuid{
+ 0x6b, 0xa7, 0xb8, 0x14,
+ 0x9d, 0xad,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ want: "6ba7b814-9dad-11d1-80b4-00c04fd430c8",
+ },
+ } {
+ t.Run(fmt.Sprintf("% 02x", c.uuid[:]), func(t *testing.T) {
+ got := c.uuid.String()
+ if got != c.want {
+ t.Errorf("got %q, want %q", got, c.want)
+ }
+ })
+ }
+}
+
+func TestUUIDParse(t *testing.T) {
+ for _, c := range []struct {
+ uuid string
+ want Tuuid
+ err bool
+ }{
+ {
+ uuid: "00000000-0000-0000-0000-000000000000",
+ want: Tuuid{
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ },
+ },
+ {
+ uuid: "6BA7B810-9DAD-11D1-80B4-00C04FD430C8",
+ want: Tuuid{
+ 0x6B, 0xA7, 0xB8, 0x10,
+ 0x9D, 0xAD,
+ 0x11, 0xD1,
+ 0x80, 0xB4,
+ 0x00, 0xC0, 0x4F, 0xD4, 0x30, 0xC8,
+ },
+ },
+ {
+ uuid: "6ba7B811-9dAd-11d1-80b4-00c04fd430c8",
+ want: Tuuid{
+ 0x6b, 0xa7, 0xB8, 0x11,
+ 0x9d, 0xAd,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ },
+ {
+ uuid: "6ba7b812-9dad-11d1-80b4-00c04fd430c8",
+ want: Tuuid{
+ 0x6b, 0xa7, 0xb8, 0x12,
+ 0x9d, 0xad,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ },
+ {
+ uuid: "6ba7b814-9dad-11d1-80b4-00c04fd430c8",
+ want: Tuuid{
+ 0x6b, 0xa7, 0xb8, 0x14,
+ 0x9d, 0xad,
+ 0x11, 0xd1,
+ 0x80, 0xb4,
+ 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8,
+ },
+ },
+ {
+ uuid: "00000000000000000000000000000000",
+ err: true, // not in canonical form
+ },
+ {
+ uuid: "6ba7b810-9d-ad11d1-80b4-00c04fd430c8",
+ err: true, // wrong position of hyphens
+ },
+ {
+ uuid: "urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8",
+ err: true, // urn form is not supported
+ },
+ {
+ uuid: "{6ba7b812-9dad-11d1-80b4-00c04fd430c8}",
+ err: true, // guid with braces form is not supported
+ },
+ {
+ uuid: "6xa7b814-9dad-11d1-80b4-00c04fd430c8",
+ err: true, // non-hex numbers
+ },
+ } {
+ t.Run(c.uuid, func(t *testing.T) {
+ uuid, err := ParseTuuid(c.uuid)
+ if c.err {
+ if err == nil {
+ t.Errorf("Got %v, want error", uuid)
+ }
+ } else {
+ if err != nil {
+ t.Errorf("Failed to parse: %v", err)
+ }
+ if uuid != c.want {
+ t.Errorf("Got %v, want %v", uuid, c.want)
+ }
+ }
+ })
+ }
+}
+
+func TestUUIDQuick(t *testing.T) {
+ f := func(u Tuuid) bool {
+ s := u.String()
+ parsed, err := ParseTuuid(s)
+ if err != nil {
+ t.Error(err)
+ }
+ if parsed != u {
+ t.Errorf("Parsed %v want %v", parsed, u)
+ }
+ return !t.Failed()
+ }
+ if err := quick.Check(f, nil); err != nil {
+ t.Error(err)
+ }
+}
+
+func BenchmarkUUIDParse(b *testing.B) {
+ for _, s := range []string{
+ "00000000-0000-0000-0000-000000000000",
+ "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
+ "6ba7b811-9dad-11d1-80b4-00c04fd430c8",
+ "6ba7b812-9dad-11d1-80b4-00c04fd430c8",
+ "6ba7b814-9dad-11d1-80b4-00c04fd430c8",
+ } {
+ b.Run(s, func(b *testing.B) {
+ b.ReportAllocs()
+ if _, err := ParseTuuid(s); err != nil {
+ b.Fatalf("Unable to parse %q: %v", s, err)
+ }
+ b.ResetTimer()
+ b.RunParallel(func(pb *testing.PB) {
+ for pb.Next() {
+ ParseTuuid(s)
+ }
+ })
+ })
+ }
+}
+
+func BenchmarkUUIDString(b *testing.B) {
+ for _, u := range []Tuuid{
+ {},
+ Must(ParseTuuid("6ba7b810-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b811-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b812-9dad-11d1-80b4-00c04fd430c8")),
+ Must(ParseTuuid("6ba7b814-9dad-11d1-80b4-00c04fd430c8")),
+ } {
+ b.Run(u.String(), func(b *testing.B) {
+ b.ReportAllocs()
+ b.RunParallel(func(pb *testing.PB) {
+ for pb.Next() {
+ _ = u.String()
+ }
+ })
+ })
+ }
+}