From 96384e6fdc5eb876f4cde79d1f3f81f3656bc102 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 7 May 2020 11:31:31 -0700 Subject: [PATCH 01/23] Renaming function in job update to reduce ambiguity about which underlying object it is modifiying. Adding support for specifying ranges in updates as well as SLA Awareness. --- jobUpdate.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jobUpdate.go b/jobUpdate.go index 6b285df..cc2cd7f 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -131,8 +131,20 @@ func (j *JobUpdate) VariableBatchStrategy(autoPause bool, batchSizes ...int32) * return j } -func newUpdateSettings() *aurora.JobUpdateSettings { +// SlaAware makes the scheduler enforce the SLA Aware policy if the job meets the SLA awareness criteria. +// By default, the scheduler will only apply SLA Awareness to jobs in the production tier with 20 or more instances. +func (j *JobUpdate) SlaAware(slaAware bool) *JobUpdate { + j.request.Settings.SlaAware = &slaAware + return j +} +// AddInstanceRange allows updates to only touch a certain specific range of instances +func (j *JobUpdate) AddInstanceRange(first, last int32) *JobUpdate { + j.request.Settings.UpdateOnlyTheseInstances = append(j.request.Settings.UpdateOnlyTheseInstances, + &aurora.Range{First: first, Last: last}) + return j +} +func newUpdateSettings() *aurora.JobUpdateSettings { us := aurora.JobUpdateSettings{} // Mirrors defaults set by Pystachio us.UpdateOnlyTheseInstances = []*aurora.Range{} @@ -198,7 +210,7 @@ func (j *JobUpdate) Tier(tier string) *JobUpdate { return j } -func (j *JobUpdate) MaxFailure(maxFail int32) *JobUpdate { +func (j *JobUpdate) TaskMaxFailure(maxFail int32) *JobUpdate { j.task.MaxFailure(maxFail) return j } From 72c04220fe981744e4e589afc64a71756a6df20c Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 7 May 2020 11:33:47 -0700 Subject: [PATCH 02/23] Removing vendoring folder now that packages are cached in goproxy. --- .../lib/go/thrift/application_exception.go | 164 -- .../go/thrift/application_exception_test.go | 41 - .../thrift/lib/go/thrift/binary_protocol.go | 509 ----- .../lib/go/thrift/binary_protocol_test.go | 28 - .../lib/go/thrift/buffered_transport.go | 92 - .../lib/go/thrift/buffered_transport_test.go | 29 - .../apache/thrift/lib/go/thrift/client.go | 85 - .../thrift/lib/go/thrift/common_test.go | 30 - .../thrift/lib/go/thrift/compact_protocol.go | 810 -------- .../lib/go/thrift/compact_protocol_test.go | 60 - .../apache/thrift/lib/go/thrift/context.go | 24 - .../thrift/lib/go/thrift/debug_protocol.go | 270 --- .../thrift/lib/go/thrift/deserializer.go | 58 - .../apache/thrift/lib/go/thrift/exception.go | 44 - .../thrift/lib/go/thrift/exception_test.go | 69 - .../apache/thrift/lib/go/thrift/field.go | 79 - .../thrift/lib/go/thrift/framed_transport.go | 173 -- .../lib/go/thrift/framed_transport_test.go | 29 - .../thrift/lib/go/thrift/http_client.go | 242 --- .../thrift/lib/go/thrift/http_client_test.go | 106 - .../thrift/lib/go/thrift/http_transport.go | 63 - .../lib/go/thrift/iostream_transport.go | 214 -- .../lib/go/thrift/iostream_transport_test.go | 52 - .../thrift/lib/go/thrift/json_protocol.go | 584 ------ .../lib/go/thrift/json_protocol_test.go | 650 ------ .../lib/go/thrift/lowlevel_benchmarks_test.go | 540 ----- .../thrift/lib/go/thrift/memory_buffer.go | 80 - .../lib/go/thrift/memory_buffer_test.go | 29 - .../thrift/lib/go/thrift/messagetype.go | 31 - .../lib/go/thrift/multiplexed_protocol.go | 170 -- .../apache/thrift/lib/go/thrift/numeric.go | 164 -- .../apache/thrift/lib/go/thrift/pointerize.go | 50 - .../thrift/lib/go/thrift/processor_factory.go | 70 - .../apache/thrift/lib/go/thrift/protocol.go | 179 -- .../lib/go/thrift/protocol_exception.go | 77 - .../thrift/lib/go/thrift/protocol_factory.go | 25 - .../thrift/lib/go/thrift/protocol_test.go | 517 ----- .../thrift/lib/go/thrift/rich_transport.go | 68 - .../lib/go/thrift/rich_transport_test.go | 89 - .../apache/thrift/lib/go/thrift/serializer.go | 79 - .../thrift/lib/go/thrift/serializer_test.go | 170 -- .../lib/go/thrift/serializer_types_test.go | 633 ------ .../apache/thrift/lib/go/thrift/server.go | 35 - .../thrift/lib/go/thrift/server_socket.go | 137 -- .../lib/go/thrift/server_socket_test.go | 60 - .../thrift/lib/go/thrift/server_test.go | 28 - .../thrift/lib/go/thrift/server_transport.go | 34 - .../lib/go/thrift/simple_json_protocol.go | 1338 ------------ .../go/thrift/simple_json_protocol_test.go | 716 ------- .../thrift/lib/go/thrift/simple_server.go | 227 --- .../lib/go/thrift/simple_server_test.go | 156 -- .../apache/thrift/lib/go/thrift/socket.go | 166 -- .../thrift/lib/go/thrift/ssl_server_socket.go | 112 - .../apache/thrift/lib/go/thrift/ssl_socket.go | 176 -- .../apache/thrift/lib/go/thrift/transport.go | 70 - .../lib/go/thrift/transport_exception.go | 90 - .../lib/go/thrift/transport_exception_test.go | 60 - .../thrift/lib/go/thrift/transport_factory.go | 39 - .../thrift/lib/go/thrift/transport_test.go | 177 -- .../apache/thrift/lib/go/thrift/type.go | 69 - .../thrift/lib/go/thrift/zlib_transport.go | 132 -- .../lib/go/thrift/zlib_transport_test.go | 62 - vendor/github.com/davecgh/go-spew/.gitignore | 22 - vendor/github.com/davecgh/go-spew/.travis.yml | 28 - vendor/github.com/davecgh/go-spew/LICENSE | 15 - vendor/github.com/davecgh/go-spew/README.md | 201 -- .../github.com/davecgh/go-spew/cov_report.sh | 22 - .../github.com/davecgh/go-spew/spew/bypass.go | 145 -- .../davecgh/go-spew/spew/bypasssafe.go | 38 - .../github.com/davecgh/go-spew/spew/common.go | 341 ---- .../davecgh/go-spew/spew/common_test.go | 298 --- .../github.com/davecgh/go-spew/spew/config.go | 306 --- vendor/github.com/davecgh/go-spew/spew/doc.go | 211 -- .../github.com/davecgh/go-spew/spew/dump.go | 509 ----- .../davecgh/go-spew/spew/dump_test.go | 1042 ---------- .../davecgh/go-spew/spew/dumpcgo_test.go | 101 - .../davecgh/go-spew/spew/dumpnocgo_test.go | 26 - .../davecgh/go-spew/spew/example_test.go | 226 --- .../github.com/davecgh/go-spew/spew/format.go | 419 ---- .../davecgh/go-spew/spew/format_test.go | 1558 -------------- .../davecgh/go-spew/spew/internal_test.go | 84 - .../go-spew/spew/internalunsafe_test.go | 101 - .../github.com/davecgh/go-spew/spew/spew.go | 148 -- .../davecgh/go-spew/spew/spew_test.go | 320 --- .../davecgh/go-spew/spew/testdata/dumpcgo.go | 82 - .../davecgh/go-spew/test_coverage.txt | 61 - vendor/github.com/pkg/errors/.gitignore | 24 - vendor/github.com/pkg/errors/.travis.yml | 13 - vendor/github.com/pkg/errors/LICENSE | 23 - vendor/github.com/pkg/errors/README.md | 52 - vendor/github.com/pkg/errors/appveyor.yml | 32 - vendor/github.com/pkg/errors/bench_test.go | 63 - vendor/github.com/pkg/errors/errors.go | 269 --- vendor/github.com/pkg/errors/errors_test.go | 225 --- vendor/github.com/pkg/errors/example_test.go | 205 -- vendor/github.com/pkg/errors/format_test.go | 535 ----- vendor/github.com/pkg/errors/stack.go | 187 -- vendor/github.com/pkg/errors/stack_test.go | 292 --- .../github.com/pmezard/go-difflib/.travis.yml | 5 - vendor/github.com/pmezard/go-difflib/LICENSE | 27 - .../github.com/pmezard/go-difflib/README.md | 50 - .../pmezard/go-difflib/difflib/difflib.go | 772 ------- .../go-difflib/difflib/difflib_test.go | 426 ---- .../github.com/samuel/go-zookeeper/.gitignore | 1 - .../samuel/go-zookeeper/.travis.yml | 31 - vendor/github.com/samuel/go-zookeeper/LICENSE | 25 - .../github.com/samuel/go-zookeeper/README.md | 11 - .../samuel/go-zookeeper/examples/basic.go | 22 - .../samuel/go-zookeeper/zk/cluster_test.go | 314 --- .../github.com/samuel/go-zookeeper/zk/conn.go | 1193 ----------- .../samuel/go-zookeeper/zk/constants.go | 240 --- .../samuel/go-zookeeper/zk/constants_test.go | 24 - .../samuel/go-zookeeper/zk/dnshostprovider.go | 88 - .../go-zookeeper/zk/dnshostprovider_test.go | 224 -- .../github.com/samuel/go-zookeeper/zk/flw.go | 266 --- .../samuel/go-zookeeper/zk/flw_test.go | 330 --- .../github.com/samuel/go-zookeeper/zk/lock.go | 150 -- .../samuel/go-zookeeper/zk/lock_test.go | 94 - .../samuel/go-zookeeper/zk/server_help.go | 216 -- .../samuel/go-zookeeper/zk/server_java.go | 136 -- .../samuel/go-zookeeper/zk/structs.go | 609 ------ .../samuel/go-zookeeper/zk/structs_test.go | 83 - .../samuel/go-zookeeper/zk/throttle_test.go | 136 -- .../github.com/samuel/go-zookeeper/zk/util.go | 116 -- .../samuel/go-zookeeper/zk/util_test.go | 53 - .../samuel/go-zookeeper/zk/zk_test.go | 939 --------- vendor/github.com/stretchr/testify/.gitignore | 24 - .../stretchr/testify/.travis.gofmt.sh | 7 - .../stretchr/testify/.travis.gogenerate.sh | 13 - .../stretchr/testify/.travis.govet.sh | 10 - .../github.com/stretchr/testify/.travis.yml | 15 - vendor/github.com/stretchr/testify/Gopkg.lock | 27 - vendor/github.com/stretchr/testify/Gopkg.toml | 16 - vendor/github.com/stretchr/testify/LICENSE | 22 - vendor/github.com/stretchr/testify/README.md | 331 --- .../stretchr/testify/_codegen/main.go | 316 --- .../testify/assert/assertion_format.go | 484 ----- .../testify/assert/assertion_format.go.tmpl | 5 - .../testify/assert/assertion_forward.go | 956 --------- .../testify/assert/assertion_forward.go.tmpl | 5 - .../stretchr/testify/assert/assertions.go | 1394 ------------- .../testify/assert/assertions_test.go | 1793 ----------------- .../github.com/stretchr/testify/assert/doc.go | 45 - .../stretchr/testify/assert/errors.go | 10 - .../testify/assert/forward_assertions.go | 16 - .../testify/assert/forward_assertions_test.go | 611 ------ .../testify/assert/http_assertions.go | 143 -- .../testify/assert/http_assertions_test.go | 146 -- vendor/github.com/stretchr/testify/doc.go | 22 - .../github.com/stretchr/testify/http/doc.go | 2 - .../testify/http/test_response_writer.go | 49 - .../testify/http/test_round_tripper.go | 17 - .../github.com/stretchr/testify/mock/doc.go | 44 - .../github.com/stretchr/testify/mock/mock.go | 885 -------- .../stretchr/testify/mock/mock_test.go | 1497 -------------- .../stretchr/testify/package_test.go | 12 - .../stretchr/testify/require/doc.go | 28 - .../testify/require/forward_requirements.go | 16 - .../require/forward_requirements_test.go | 385 ---- .../stretchr/testify/require/require.go | 1227 ----------- .../stretchr/testify/require/require.go.tmpl | 6 - .../testify/require/require_forward.go | 957 --------- .../testify/require/require_forward.go.tmpl | 5 - .../stretchr/testify/require/requirements.go | 29 - .../testify/require/requirements_test.go | 566 ------ .../github.com/stretchr/testify/suite/doc.go | 65 - .../stretchr/testify/suite/interfaces.go | 46 - .../stretchr/testify/suite/suite.go | 136 -- .../stretchr/testify/suite/suite_test.go | 294 --- 169 files changed, 38842 deletions(-) delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/client.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/common_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/context.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/exception.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/field.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/http_client.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/numeric.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/serializer.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/server.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/server_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/socket.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/type.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go delete mode 100644 vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/.gitignore delete mode 100644 vendor/github.com/davecgh/go-spew/.travis.yml delete mode 100644 vendor/github.com/davecgh/go-spew/LICENSE delete mode 100644 vendor/github.com/davecgh/go-spew/README.md delete mode 100644 vendor/github.com/davecgh/go-spew/cov_report.sh delete mode 100644 vendor/github.com/davecgh/go-spew/spew/bypass.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/bypasssafe.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/common.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/common_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/config.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/doc.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dump.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dump_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/example_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/format.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/format_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/internal_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/spew.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/spew_test.go delete mode 100644 vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go delete mode 100644 vendor/github.com/davecgh/go-spew/test_coverage.txt delete mode 100644 vendor/github.com/pkg/errors/.gitignore delete mode 100644 vendor/github.com/pkg/errors/.travis.yml delete mode 100644 vendor/github.com/pkg/errors/LICENSE delete mode 100644 vendor/github.com/pkg/errors/README.md delete mode 100644 vendor/github.com/pkg/errors/appveyor.yml delete mode 100644 vendor/github.com/pkg/errors/bench_test.go delete mode 100644 vendor/github.com/pkg/errors/errors.go delete mode 100644 vendor/github.com/pkg/errors/errors_test.go delete mode 100644 vendor/github.com/pkg/errors/example_test.go delete mode 100644 vendor/github.com/pkg/errors/format_test.go delete mode 100644 vendor/github.com/pkg/errors/stack.go delete mode 100644 vendor/github.com/pkg/errors/stack_test.go delete mode 100644 vendor/github.com/pmezard/go-difflib/.travis.yml delete mode 100644 vendor/github.com/pmezard/go-difflib/LICENSE delete mode 100644 vendor/github.com/pmezard/go-difflib/README.md delete mode 100644 vendor/github.com/pmezard/go-difflib/difflib/difflib.go delete mode 100644 vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/.gitignore delete mode 100644 vendor/github.com/samuel/go-zookeeper/.travis.yml delete mode 100644 vendor/github.com/samuel/go-zookeeper/LICENSE delete mode 100644 vendor/github.com/samuel/go-zookeeper/README.md delete mode 100644 vendor/github.com/samuel/go-zookeeper/examples/basic.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/conn.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/constants.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/constants_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/flw.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/flw_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/lock.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/lock_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/server_help.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/server_java.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/structs.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/structs_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/util.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/util_test.go delete mode 100644 vendor/github.com/samuel/go-zookeeper/zk/zk_test.go delete mode 100644 vendor/github.com/stretchr/testify/.gitignore delete mode 100755 vendor/github.com/stretchr/testify/.travis.gofmt.sh delete mode 100755 vendor/github.com/stretchr/testify/.travis.gogenerate.sh delete mode 100755 vendor/github.com/stretchr/testify/.travis.govet.sh delete mode 100644 vendor/github.com/stretchr/testify/.travis.yml delete mode 100644 vendor/github.com/stretchr/testify/Gopkg.lock delete mode 100644 vendor/github.com/stretchr/testify/Gopkg.toml delete mode 100644 vendor/github.com/stretchr/testify/LICENSE delete mode 100644 vendor/github.com/stretchr/testify/README.md delete mode 100644 vendor/github.com/stretchr/testify/_codegen/main.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_format.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_forward.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/assert/assertions.go delete mode 100644 vendor/github.com/stretchr/testify/assert/assertions_test.go delete mode 100644 vendor/github.com/stretchr/testify/assert/doc.go delete mode 100644 vendor/github.com/stretchr/testify/assert/errors.go delete mode 100644 vendor/github.com/stretchr/testify/assert/forward_assertions.go delete mode 100644 vendor/github.com/stretchr/testify/assert/forward_assertions_test.go delete mode 100644 vendor/github.com/stretchr/testify/assert/http_assertions.go delete mode 100644 vendor/github.com/stretchr/testify/assert/http_assertions_test.go delete mode 100644 vendor/github.com/stretchr/testify/doc.go delete mode 100644 vendor/github.com/stretchr/testify/http/doc.go delete mode 100644 vendor/github.com/stretchr/testify/http/test_response_writer.go delete mode 100644 vendor/github.com/stretchr/testify/http/test_round_tripper.go delete mode 100644 vendor/github.com/stretchr/testify/mock/doc.go delete mode 100644 vendor/github.com/stretchr/testify/mock/mock.go delete mode 100644 vendor/github.com/stretchr/testify/mock/mock_test.go delete mode 100644 vendor/github.com/stretchr/testify/package_test.go delete mode 100644 vendor/github.com/stretchr/testify/require/doc.go delete mode 100644 vendor/github.com/stretchr/testify/require/forward_requirements.go delete mode 100644 vendor/github.com/stretchr/testify/require/forward_requirements_test.go delete mode 100644 vendor/github.com/stretchr/testify/require/require.go delete mode 100644 vendor/github.com/stretchr/testify/require/require.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/require/require_forward.go delete mode 100644 vendor/github.com/stretchr/testify/require/require_forward.go.tmpl delete mode 100644 vendor/github.com/stretchr/testify/require/requirements.go delete mode 100644 vendor/github.com/stretchr/testify/require/requirements_test.go delete mode 100644 vendor/github.com/stretchr/testify/suite/doc.go delete mode 100644 vendor/github.com/stretchr/testify/suite/interfaces.go delete mode 100644 vendor/github.com/stretchr/testify/suite/suite.go delete mode 100644 vendor/github.com/stretchr/testify/suite/suite_test.go diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go deleted file mode 100644 index b9d7eed..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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 - -const ( - UNKNOWN_APPLICATION_EXCEPTION = 0 - UNKNOWN_METHOD = 1 - INVALID_MESSAGE_TYPE_EXCEPTION = 2 - WRONG_METHOD_NAME = 3 - BAD_SEQUENCE_ID = 4 - MISSING_RESULT = 5 - INTERNAL_ERROR = 6 - PROTOCOL_ERROR = 7 -) - -var defaultApplicationExceptionMessage = map[int32]string{ - UNKNOWN_APPLICATION_EXCEPTION: "unknown application exception", - UNKNOWN_METHOD: "unknown method", - INVALID_MESSAGE_TYPE_EXCEPTION: "invalid message type", - WRONG_METHOD_NAME: "wrong method name", - BAD_SEQUENCE_ID: "bad sequence ID", - MISSING_RESULT: "missing result", - INTERNAL_ERROR: "unknown internal error", - PROTOCOL_ERROR: "unknown protocol error", -} - -// Application level Thrift exception -type TApplicationException interface { - TException - TypeId() int32 - Read(iprot TProtocol) error - Write(oprot TProtocol) error -} - -type tApplicationException struct { - message string - type_ int32 -} - -func (e tApplicationException) Error() string { - if e.message != "" { - return e.message - } - return defaultApplicationExceptionMessage[e.type_] -} - -func NewTApplicationException(type_ int32, message string) TApplicationException { - return &tApplicationException{message, type_} -} - -func (p *tApplicationException) TypeId() int32 { - return p.type_ -} - -func (p *tApplicationException) Read(iprot TProtocol) error { - // TODO: this should really be generated by the compiler - _, err := iprot.ReadStructBegin() - if err != nil { - return err - } - - message := "" - type_ := int32(UNKNOWN_APPLICATION_EXCEPTION) - - for { - _, ttype, id, err := iprot.ReadFieldBegin() - if err != nil { - return err - } - if ttype == STOP { - break - } - switch id { - case 1: - if ttype == STRING { - if message, err = iprot.ReadString(); err != nil { - return err - } - } else { - if err = SkipDefaultDepth(iprot, ttype); err != nil { - return err - } - } - case 2: - if ttype == I32 { - if type_, err = iprot.ReadI32(); err != nil { - return err - } - } else { - if err = SkipDefaultDepth(iprot, ttype); err != nil { - return err - } - } - default: - if err = SkipDefaultDepth(iprot, ttype); err != nil { - return err - } - } - if err = iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return err - } - - p.message = message - p.type_ = type_ - - return nil -} - -func (p *tApplicationException) Write(oprot TProtocol) (err error) { - err = oprot.WriteStructBegin("TApplicationException") - if len(p.Error()) > 0 { - err = oprot.WriteFieldBegin("message", STRING, 1) - if err != nil { - return - } - err = oprot.WriteString(p.Error()) - if err != nil { - return - } - err = oprot.WriteFieldEnd() - if err != nil { - return - } - } - err = oprot.WriteFieldBegin("type", I32, 2) - if err != nil { - return - } - err = oprot.WriteI32(p.type_) - if err != nil { - return - } - err = oprot.WriteFieldEnd() - if err != nil { - return - } - err = oprot.WriteFieldStop() - if err != nil { - return - } - err = oprot.WriteStructEnd() - return -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go deleted file mode 100644 index 7743357..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestTApplicationException(t *testing.T) { - exc := NewTApplicationException(UNKNOWN_APPLICATION_EXCEPTION, "") - if exc.Error() != defaultApplicationExceptionMessage[UNKNOWN_APPLICATION_EXCEPTION] { - t.Fatalf("Expected empty string for exception but found '%s'", exc.Error()) - } - if exc.TypeId() != UNKNOWN_APPLICATION_EXCEPTION { - t.Fatalf("Expected type UNKNOWN for exception but found '%v'", exc.TypeId()) - } - exc = NewTApplicationException(WRONG_METHOD_NAME, "junk_method") - if exc.Error() != "junk_method" { - t.Fatalf("Expected 'junk_method' for exception but found '%s'", exc.Error()) - } - if exc.TypeId() != WRONG_METHOD_NAME { - t.Fatalf("Expected type WRONG_METHOD_NAME for exception but found '%v'", exc.TypeId()) - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go deleted file mode 100644 index 1f90bf4..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go +++ /dev/null @@ -1,509 +0,0 @@ -/* - * 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" - "context" - "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 - } - - isize := int(size) - buf := make([]byte, isize) - _, err := io.ReadFull(p.trans, buf) - return buf, NewTProtocolException(err) -} - -func (p *TBinaryProtocol) Flush(ctx context.Context) (err error) { - return NewTProtocolException(p.trans.Flush(ctx)) -} - -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 - } - - 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) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go deleted file mode 100644 index 0462cc7..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestReadWriteBinaryProtocol(t *testing.T) { - ReadWriteProtocolTest(t, NewTBinaryProtocolFactoryDefault()) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go deleted file mode 100644 index 9670206..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 ( - "bufio" - "context" -) - -type TBufferedTransportFactory struct { - size int -} - -type TBufferedTransport struct { - bufio.ReadWriter - tp TTransport -} - -func (p *TBufferedTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - return NewTBufferedTransport(trans, p.size), nil -} - -func NewTBufferedTransportFactory(bufferSize int) *TBufferedTransportFactory { - return &TBufferedTransportFactory{size: bufferSize} -} - -func NewTBufferedTransport(trans TTransport, bufferSize int) *TBufferedTransport { - return &TBufferedTransport{ - ReadWriter: bufio.ReadWriter{ - Reader: bufio.NewReaderSize(trans, bufferSize), - Writer: bufio.NewWriterSize(trans, bufferSize), - }, - tp: trans, - } -} - -func (p *TBufferedTransport) IsOpen() bool { - return p.tp.IsOpen() -} - -func (p *TBufferedTransport) Open() (err error) { - return p.tp.Open() -} - -func (p *TBufferedTransport) Close() (err error) { - return p.tp.Close() -} - -func (p *TBufferedTransport) Read(b []byte) (int, error) { - n, err := p.ReadWriter.Read(b) - if err != nil { - p.ReadWriter.Reader.Reset(p.tp) - } - return n, err -} - -func (p *TBufferedTransport) Write(b []byte) (int, error) { - n, err := p.ReadWriter.Write(b) - if err != nil { - p.ReadWriter.Writer.Reset(p.tp) - } - return n, err -} - -func (p *TBufferedTransport) Flush(ctx context.Context) error { - if err := p.ReadWriter.Flush(); err != nil { - p.ReadWriter.Writer.Reset(p.tp) - return err - } - return p.tp.Flush(ctx) -} - -func (p *TBufferedTransport) RemainingBytes() (num_bytes uint64) { - return p.tp.RemainingBytes() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go deleted file mode 100644 index 95ec0cb..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestBufferedTransport(t *testing.T) { - trans := NewTBufferedTransport(NewTMemoryBuffer(), 10240) - TransportTest(t, trans, trans) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/client.go b/vendor/github.com/apache/thrift/lib/go/thrift/client.go deleted file mode 100644 index 28791cc..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/client.go +++ /dev/null @@ -1,85 +0,0 @@ -package thrift - -import ( - "context" - "fmt" -) - -type TClient interface { - Call(ctx context.Context, method string, args, result TStruct) error -} - -type TStandardClient struct { - seqId int32 - iprot, oprot TProtocol -} - -// TStandardClient implements TClient, and uses the standard message format for Thrift. -// It is not safe for concurrent use. -func NewTStandardClient(inputProtocol, outputProtocol TProtocol) *TStandardClient { - return &TStandardClient{ - iprot: inputProtocol, - oprot: outputProtocol, - } -} - -func (p *TStandardClient) Send(ctx context.Context, oprot TProtocol, seqId int32, method string, args TStruct) error { - if err := oprot.WriteMessageBegin(method, CALL, seqId); err != nil { - return err - } - if err := args.Write(oprot); err != nil { - return err - } - if err := oprot.WriteMessageEnd(); err != nil { - return err - } - return oprot.Flush(ctx) -} - -func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string, result TStruct) error { - rMethod, rTypeId, rSeqId, err := iprot.ReadMessageBegin() - if err != nil { - return err - } - - if method != rMethod { - return NewTApplicationException(WRONG_METHOD_NAME, fmt.Sprintf("%s: wrong method name", method)) - } else if seqId != rSeqId { - return NewTApplicationException(BAD_SEQUENCE_ID, fmt.Sprintf("%s: out of order sequence response", method)) - } else if rTypeId == EXCEPTION { - var exception tApplicationException - if err := exception.Read(iprot); err != nil { - return err - } - - if err := iprot.ReadMessageEnd(); err != nil { - return err - } - - return &exception - } else if rTypeId != REPLY { - return NewTApplicationException(INVALID_MESSAGE_TYPE_EXCEPTION, fmt.Sprintf("%s: invalid message type", method)) - } - - if err := result.Read(iprot); err != nil { - return err - } - - return iprot.ReadMessageEnd() -} - -func (p *TStandardClient) Call(ctx context.Context, method string, args, result TStruct) error { - p.seqId++ - seqId := p.seqId - - if err := p.Send(ctx, p.oprot, seqId, method, args); err != nil { - return err - } - - // method is oneway - if result == nil { - return nil - } - - return p.Recv(p.iprot, seqId, method, result) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/common_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/common_test.go deleted file mode 100644 index 93597ff..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/common_test.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 "context" - -type mockProcessor struct { - ProcessFunc func(in, out TProtocol) (bool, TException) -} - -func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) { - return m.ProcessFunc(in, out) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go deleted file mode 100644 index 1900d50..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go +++ /dev/null @@ -1,810 +0,0 @@ -/* - * 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 ( - "context" - "encoding/binary" - "fmt" - "io" - "math" -) - -const ( - COMPACT_PROTOCOL_ID = 0x082 - COMPACT_VERSION = 1 - COMPACT_VERSION_MASK = 0x1f - COMPACT_TYPE_MASK = 0x0E0 - COMPACT_TYPE_BITS = 0x07 - COMPACT_TYPE_SHIFT_AMOUNT = 5 -) - -type tCompactType byte - -const ( - COMPACT_BOOLEAN_TRUE = 0x01 - COMPACT_BOOLEAN_FALSE = 0x02 - COMPACT_BYTE = 0x03 - COMPACT_I16 = 0x04 - COMPACT_I32 = 0x05 - COMPACT_I64 = 0x06 - COMPACT_DOUBLE = 0x07 - COMPACT_BINARY = 0x08 - COMPACT_LIST = 0x09 - COMPACT_SET = 0x0A - COMPACT_MAP = 0x0B - COMPACT_STRUCT = 0x0C -) - -var ( - ttypeToCompactType map[TType]tCompactType -) - -func init() { - ttypeToCompactType = map[TType]tCompactType{ - STOP: STOP, - BOOL: COMPACT_BOOLEAN_TRUE, - BYTE: COMPACT_BYTE, - I16: COMPACT_I16, - I32: COMPACT_I32, - I64: COMPACT_I64, - DOUBLE: COMPACT_DOUBLE, - STRING: COMPACT_BINARY, - LIST: COMPACT_LIST, - SET: COMPACT_SET, - MAP: COMPACT_MAP, - STRUCT: COMPACT_STRUCT, - } -} - -type TCompactProtocolFactory struct{} - -func NewTCompactProtocolFactory() *TCompactProtocolFactory { - return &TCompactProtocolFactory{} -} - -func (p *TCompactProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return NewTCompactProtocol(trans) -} - -type TCompactProtocol struct { - trans TRichTransport - origTransport TTransport - - // Used to keep track of the last field for the current and previous structs, - // so we can do the delta stuff. - lastField []int - lastFieldId int - - // If we encounter a boolean field begin, save the TField here so it can - // have the value incorporated. - booleanFieldName string - booleanFieldId int16 - booleanFieldPending bool - - // If we read a field header, and it's a boolean field, save the boolean - // value here so that readBool can use it. - boolValue bool - boolValueIsNotNull bool - buffer [64]byte -} - -// Create a TCompactProtocol given a TTransport -func NewTCompactProtocol(trans TTransport) *TCompactProtocol { - p := &TCompactProtocol{origTransport: trans, lastField: []int{}} - if et, ok := trans.(TRichTransport); ok { - p.trans = et - } else { - p.trans = NewTRichTransport(trans) - } - - return p - -} - -// -// Public Writing methods. -// - -// Write a message header to the wire. Compact Protocol messages contain the -// protocol version so we can migrate forwards in the future if need be. -func (p *TCompactProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error { - err := p.writeByteDirect(COMPACT_PROTOCOL_ID) - if err != nil { - return NewTProtocolException(err) - } - err = p.writeByteDirect((COMPACT_VERSION & COMPACT_VERSION_MASK) | ((byte(typeId) << COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_MASK)) - if err != nil { - return NewTProtocolException(err) - } - _, err = p.writeVarint32(seqid) - if err != nil { - return NewTProtocolException(err) - } - e := p.WriteString(name) - return e - -} - -func (p *TCompactProtocol) WriteMessageEnd() error { return nil } - -// Write a struct begin. This doesn't actually put anything on the wire. We -// use it as an opportunity to put special placeholder markers on the field -// stack so we can get the field id deltas correct. -func (p *TCompactProtocol) WriteStructBegin(name string) error { - p.lastField = append(p.lastField, p.lastFieldId) - p.lastFieldId = 0 - return nil -} - -// Write a struct end. This doesn't actually put anything on the wire. We use -// this as an opportunity to pop the last field from the current struct off -// of the field stack. -func (p *TCompactProtocol) WriteStructEnd() error { - p.lastFieldId = p.lastField[len(p.lastField)-1] - p.lastField = p.lastField[:len(p.lastField)-1] - return nil -} - -func (p *TCompactProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - if typeId == BOOL { - // we want to possibly include the value, so we'll wait. - p.booleanFieldName, p.booleanFieldId, p.booleanFieldPending = name, id, true - return nil - } - _, err := p.writeFieldBeginInternal(name, typeId, id, 0xFF) - return NewTProtocolException(err) -} - -// The workhorse of writeFieldBegin. It has the option of doing a -// 'type override' of the type header. This is used specifically in the -// boolean field case. -func (p *TCompactProtocol) writeFieldBeginInternal(name string, typeId TType, id int16, typeOverride byte) (int, error) { - // short lastField = lastField_.pop(); - - // if there's a type override, use that. - var typeToWrite byte - if typeOverride == 0xFF { - typeToWrite = byte(p.getCompactType(typeId)) - } else { - typeToWrite = typeOverride - } - // check if we can use delta encoding for the field id - fieldId := int(id) - written := 0 - if fieldId > p.lastFieldId && fieldId-p.lastFieldId <= 15 { - // write them together - err := p.writeByteDirect(byte((fieldId-p.lastFieldId)<<4) | typeToWrite) - if err != nil { - return 0, err - } - } else { - // write them separate - err := p.writeByteDirect(typeToWrite) - if err != nil { - return 0, err - } - err = p.WriteI16(id) - written = 1 + 2 - if err != nil { - return 0, err - } - } - - p.lastFieldId = fieldId - // p.lastField.Push(field.id); - return written, nil -} - -func (p *TCompactProtocol) WriteFieldEnd() error { return nil } - -func (p *TCompactProtocol) WriteFieldStop() error { - err := p.writeByteDirect(STOP) - return NewTProtocolException(err) -} - -func (p *TCompactProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - if size == 0 { - err := p.writeByteDirect(0) - return NewTProtocolException(err) - } - _, err := p.writeVarint32(int32(size)) - if err != nil { - return NewTProtocolException(err) - } - err = p.writeByteDirect(byte(p.getCompactType(keyType))<<4 | byte(p.getCompactType(valueType))) - return NewTProtocolException(err) -} - -func (p *TCompactProtocol) WriteMapEnd() error { return nil } - -// Write a list header. -func (p *TCompactProtocol) WriteListBegin(elemType TType, size int) error { - _, err := p.writeCollectionBegin(elemType, size) - return NewTProtocolException(err) -} - -func (p *TCompactProtocol) WriteListEnd() error { return nil } - -// Write a set header. -func (p *TCompactProtocol) WriteSetBegin(elemType TType, size int) error { - _, err := p.writeCollectionBegin(elemType, size) - return NewTProtocolException(err) -} - -func (p *TCompactProtocol) WriteSetEnd() error { return nil } - -func (p *TCompactProtocol) WriteBool(value bool) error { - v := byte(COMPACT_BOOLEAN_FALSE) - if value { - v = byte(COMPACT_BOOLEAN_TRUE) - } - if p.booleanFieldPending { - // we haven't written the field header yet - _, err := p.writeFieldBeginInternal(p.booleanFieldName, BOOL, p.booleanFieldId, v) - p.booleanFieldPending = false - return NewTProtocolException(err) - } - // we're not part of a field, so just write the value. - err := p.writeByteDirect(v) - return NewTProtocolException(err) -} - -// Write a byte. Nothing to see here! -func (p *TCompactProtocol) WriteByte(value int8) error { - err := p.writeByteDirect(byte(value)) - return NewTProtocolException(err) -} - -// Write an I16 as a zigzag varint. -func (p *TCompactProtocol) WriteI16(value int16) error { - _, err := p.writeVarint32(p.int32ToZigzag(int32(value))) - return NewTProtocolException(err) -} - -// Write an i32 as a zigzag varint. -func (p *TCompactProtocol) WriteI32(value int32) error { - _, err := p.writeVarint32(p.int32ToZigzag(value)) - return NewTProtocolException(err) -} - -// Write an i64 as a zigzag varint. -func (p *TCompactProtocol) WriteI64(value int64) error { - _, err := p.writeVarint64(p.int64ToZigzag(value)) - return NewTProtocolException(err) -} - -// Write a double to the wire as 8 bytes. -func (p *TCompactProtocol) WriteDouble(value float64) error { - buf := p.buffer[0:8] - binary.LittleEndian.PutUint64(buf, math.Float64bits(value)) - _, err := p.trans.Write(buf) - return NewTProtocolException(err) -} - -// Write a string to the wire with a varint size preceding. -func (p *TCompactProtocol) WriteString(value string) error { - _, e := p.writeVarint32(int32(len(value))) - if e != nil { - return NewTProtocolException(e) - } - if len(value) > 0 { - } - _, e = p.trans.WriteString(value) - return e -} - -// Write a byte array, using a varint for the size. -func (p *TCompactProtocol) WriteBinary(bin []byte) error { - _, e := p.writeVarint32(int32(len(bin))) - if e != nil { - return NewTProtocolException(e) - } - if len(bin) > 0 { - _, e = p.trans.Write(bin) - return NewTProtocolException(e) - } - return nil -} - -// -// Reading methods. -// - -// Read a message header. -func (p *TCompactProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) { - - protocolId, err := p.readByteDirect() - if err != nil { - return - } - - if protocolId != COMPACT_PROTOCOL_ID { - e := fmt.Errorf("Expected protocol id %02x but got %02x", COMPACT_PROTOCOL_ID, protocolId) - return "", typeId, seqId, NewTProtocolExceptionWithType(BAD_VERSION, e) - } - - versionAndType, err := p.readByteDirect() - if err != nil { - return - } - - version := versionAndType & COMPACT_VERSION_MASK - typeId = TMessageType((versionAndType >> COMPACT_TYPE_SHIFT_AMOUNT) & COMPACT_TYPE_BITS) - if version != COMPACT_VERSION { - e := fmt.Errorf("Expected version %02x but got %02x", COMPACT_VERSION, version) - err = NewTProtocolExceptionWithType(BAD_VERSION, e) - return - } - seqId, e := p.readVarint32() - if e != nil { - err = NewTProtocolException(e) - return - } - name, err = p.ReadString() - return -} - -func (p *TCompactProtocol) ReadMessageEnd() error { return nil } - -// Read a struct begin. There's nothing on the wire for this, but it is our -// opportunity to push a new struct begin marker onto the field stack. -func (p *TCompactProtocol) ReadStructBegin() (name string, err error) { - p.lastField = append(p.lastField, p.lastFieldId) - p.lastFieldId = 0 - return -} - -// Doesn't actually consume any wire data, just removes the last field for -// this struct from the field stack. -func (p *TCompactProtocol) ReadStructEnd() error { - // consume the last field we read off the wire. - p.lastFieldId = p.lastField[len(p.lastField)-1] - p.lastField = p.lastField[:len(p.lastField)-1] - return nil -} - -// Read a field header off the wire. -func (p *TCompactProtocol) ReadFieldBegin() (name string, typeId TType, id int16, err error) { - t, err := p.readByteDirect() - if err != nil { - return - } - - // if it's a stop, then we can return immediately, as the struct is over. - if (t & 0x0f) == STOP { - return "", STOP, 0, nil - } - - // mask off the 4 MSB of the type header. it could contain a field id delta. - modifier := int16((t & 0xf0) >> 4) - if modifier == 0 { - // not a delta. look ahead for the zigzag varint field id. - id, err = p.ReadI16() - if err != nil { - return - } - } else { - // has a delta. add the delta to the last read field id. - id = int16(p.lastFieldId) + modifier - } - typeId, e := p.getTType(tCompactType(t & 0x0f)) - if e != nil { - err = NewTProtocolException(e) - return - } - - // if this happens to be a boolean field, the value is encoded in the type - if p.isBoolType(t) { - // save the boolean value in a special instance variable. - p.boolValue = (byte(t)&0x0f == COMPACT_BOOLEAN_TRUE) - p.boolValueIsNotNull = true - } - - // push the new field onto the field stack so we can keep the deltas going. - p.lastFieldId = int(id) - return -} - -func (p *TCompactProtocol) ReadFieldEnd() error { return nil } - -// Read a map header off the wire. If the size is zero, skip reading the key -// and value type. This means that 0-length maps will yield TMaps without the -// "correct" types. -func (p *TCompactProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, err error) { - size32, e := p.readVarint32() - if e != nil { - err = NewTProtocolException(e) - return - } - if size32 < 0 { - err = invalidDataLength - return - } - size = int(size32) - - keyAndValueType := byte(STOP) - if size != 0 { - keyAndValueType, err = p.readByteDirect() - if err != nil { - return - } - } - keyType, _ = p.getTType(tCompactType(keyAndValueType >> 4)) - valueType, _ = p.getTType(tCompactType(keyAndValueType & 0xf)) - return -} - -func (p *TCompactProtocol) ReadMapEnd() error { return nil } - -// Read a list header off the wire. If the list size is 0-14, the size will -// be packed into the element type header. If it's a longer list, the 4 MSB -// of the element type header will be 0xF, and a varint will follow with the -// true size. -func (p *TCompactProtocol) ReadListBegin() (elemType TType, size int, err error) { - size_and_type, err := p.readByteDirect() - if err != nil { - return - } - size = int((size_and_type >> 4) & 0x0f) - if size == 15 { - size2, e := p.readVarint32() - if e != nil { - err = NewTProtocolException(e) - return - } - if size2 < 0 { - err = invalidDataLength - return - } - size = int(size2) - } - elemType, e := p.getTType(tCompactType(size_and_type)) - if e != nil { - err = NewTProtocolException(e) - return - } - return -} - -func (p *TCompactProtocol) ReadListEnd() error { return nil } - -// Read a set header off the wire. If the set size is 0-14, the size will -// be packed into the element type header. If it's a longer set, the 4 MSB -// of the element type header will be 0xF, and a varint will follow with the -// true size. -func (p *TCompactProtocol) ReadSetBegin() (elemType TType, size int, err error) { - return p.ReadListBegin() -} - -func (p *TCompactProtocol) ReadSetEnd() error { return nil } - -// Read a boolean off the wire. If this is a boolean field, the value should -// already have been read during readFieldBegin, so we'll just consume the -// pre-stored value. Otherwise, read a byte. -func (p *TCompactProtocol) ReadBool() (value bool, err error) { - if p.boolValueIsNotNull { - p.boolValueIsNotNull = false - return p.boolValue, nil - } - v, err := p.readByteDirect() - return v == COMPACT_BOOLEAN_TRUE, err -} - -// Read a single byte off the wire. Nothing interesting here. -func (p *TCompactProtocol) ReadByte() (int8, error) { - v, err := p.readByteDirect() - if err != nil { - return 0, NewTProtocolException(err) - } - return int8(v), err -} - -// Read an i16 from the wire as a zigzag varint. -func (p *TCompactProtocol) ReadI16() (value int16, err error) { - v, err := p.ReadI32() - return int16(v), err -} - -// Read an i32 from the wire as a zigzag varint. -func (p *TCompactProtocol) ReadI32() (value int32, err error) { - v, e := p.readVarint32() - if e != nil { - return 0, NewTProtocolException(e) - } - value = p.zigzagToInt32(v) - return value, nil -} - -// Read an i64 from the wire as a zigzag varint. -func (p *TCompactProtocol) ReadI64() (value int64, err error) { - v, e := p.readVarint64() - if e != nil { - return 0, NewTProtocolException(e) - } - value = p.zigzagToInt64(v) - return value, nil -} - -// No magic here - just read a double off the wire. -func (p *TCompactProtocol) ReadDouble() (value float64, err error) { - longBits := p.buffer[0:8] - _, e := io.ReadFull(p.trans, longBits) - if e != nil { - return 0.0, NewTProtocolException(e) - } - return math.Float64frombits(p.bytesToUint64(longBits)), nil -} - -// Reads a []byte (via readBinary), and then UTF-8 decodes it. -func (p *TCompactProtocol) ReadString() (value string, err error) { - length, e := p.readVarint32() - if e != nil { - return "", NewTProtocolException(e) - } - if length < 0 { - return "", invalidDataLength - } - - if length == 0 { - return "", nil - } - var buf []byte - if length <= int32(len(p.buffer)) { - buf = p.buffer[0:length] - } else { - buf = make([]byte, length) - } - _, e = io.ReadFull(p.trans, buf) - return string(buf), NewTProtocolException(e) -} - -// Read a []byte from the wire. -func (p *TCompactProtocol) ReadBinary() (value []byte, err error) { - length, e := p.readVarint32() - if e != nil { - return nil, NewTProtocolException(e) - } - if length == 0 { - return []byte{}, nil - } - if length < 0 { - return nil, invalidDataLength - } - - buf := make([]byte, length) - _, e = io.ReadFull(p.trans, buf) - return buf, NewTProtocolException(e) -} - -func (p *TCompactProtocol) Flush(ctx context.Context) (err error) { - return NewTProtocolException(p.trans.Flush(ctx)) -} - -func (p *TCompactProtocol) Skip(fieldType TType) (err error) { - return SkipDefaultDepth(p, fieldType) -} - -func (p *TCompactProtocol) Transport() TTransport { - return p.origTransport -} - -// -// Internal writing methods -// - -// Abstract method for writing the start of lists and sets. List and sets on -// the wire differ only by the type indicator. -func (p *TCompactProtocol) writeCollectionBegin(elemType TType, size int) (int, error) { - if size <= 14 { - return 1, p.writeByteDirect(byte(int32(size<<4) | int32(p.getCompactType(elemType)))) - } - err := p.writeByteDirect(0xf0 | byte(p.getCompactType(elemType))) - if err != nil { - return 0, err - } - m, err := p.writeVarint32(int32(size)) - return 1 + m, err -} - -// Write an i32 as a varint. Results in 1-5 bytes on the wire. -// TODO(pomack): make a permanent buffer like writeVarint64? -func (p *TCompactProtocol) writeVarint32(n int32) (int, error) { - i32buf := p.buffer[0:5] - idx := 0 - for { - if (n & ^0x7F) == 0 { - i32buf[idx] = byte(n) - idx++ - // p.writeByteDirect(byte(n)); - break - // return; - } else { - i32buf[idx] = byte((n & 0x7F) | 0x80) - idx++ - // p.writeByteDirect(byte(((n & 0x7F) | 0x80))); - u := uint32(n) - n = int32(u >> 7) - } - } - return p.trans.Write(i32buf[0:idx]) -} - -// Write an i64 as a varint. Results in 1-10 bytes on the wire. -func (p *TCompactProtocol) writeVarint64(n int64) (int, error) { - varint64out := p.buffer[0:10] - idx := 0 - for { - if (n & ^0x7F) == 0 { - varint64out[idx] = byte(n) - idx++ - break - } else { - varint64out[idx] = byte((n & 0x7F) | 0x80) - idx++ - u := uint64(n) - n = int64(u >> 7) - } - } - return p.trans.Write(varint64out[0:idx]) -} - -// Convert l into a zigzag long. This allows negative numbers to be -// represented compactly as a varint. -func (p *TCompactProtocol) int64ToZigzag(l int64) int64 { - return (l << 1) ^ (l >> 63) -} - -// Convert l into a zigzag long. This allows negative numbers to be -// represented compactly as a varint. -func (p *TCompactProtocol) int32ToZigzag(n int32) int32 { - return (n << 1) ^ (n >> 31) -} - -func (p *TCompactProtocol) fixedUint64ToBytes(n uint64, buf []byte) { - binary.LittleEndian.PutUint64(buf, n) -} - -func (p *TCompactProtocol) fixedInt64ToBytes(n int64, buf []byte) { - binary.LittleEndian.PutUint64(buf, uint64(n)) -} - -// Writes a byte without any possibility of all that field header nonsense. -// Used internally by other writing methods that know they need to write a byte. -func (p *TCompactProtocol) writeByteDirect(b byte) error { - return p.trans.WriteByte(b) -} - -// Writes a byte without any possibility of all that field header nonsense. -func (p *TCompactProtocol) writeIntAsByteDirect(n int) (int, error) { - return 1, p.writeByteDirect(byte(n)) -} - -// -// Internal reading methods -// - -// Read an i32 from the wire as a varint. The MSB of each byte is set -// if there is another byte to follow. This can read up to 5 bytes. -func (p *TCompactProtocol) readVarint32() (int32, error) { - // if the wire contains the right stuff, this will just truncate the i64 we - // read and get us the right sign. - v, err := p.readVarint64() - return int32(v), err -} - -// Read an i64 from the wire as a proper varint. The MSB of each byte is set -// if there is another byte to follow. This can read up to 10 bytes. -func (p *TCompactProtocol) readVarint64() (int64, error) { - shift := uint(0) - result := int64(0) - for { - b, err := p.readByteDirect() - if err != nil { - return 0, err - } - result |= int64(b&0x7f) << shift - if (b & 0x80) != 0x80 { - break - } - shift += 7 - } - return result, nil -} - -// Read a byte, unlike ReadByte that reads Thrift-byte that is i8. -func (p *TCompactProtocol) readByteDirect() (byte, error) { - return p.trans.ReadByte() -} - -// -// encoding helpers -// - -// Convert from zigzag int to int. -func (p *TCompactProtocol) zigzagToInt32(n int32) int32 { - u := uint32(n) - return int32(u>>1) ^ -(n & 1) -} - -// Convert from zigzag long to long. -func (p *TCompactProtocol) zigzagToInt64(n int64) int64 { - u := uint64(n) - return int64(u>>1) ^ -(n & 1) -} - -// Note that it's important that the mask bytes are long literals, -// otherwise they'll default to ints, and when you shift an int left 56 bits, -// you just get a messed up int. -func (p *TCompactProtocol) bytesToInt64(b []byte) int64 { - return int64(binary.LittleEndian.Uint64(b)) -} - -// Note that it's important that the mask bytes are long literals, -// otherwise they'll default to ints, and when you shift an int left 56 bits, -// you just get a messed up int. -func (p *TCompactProtocol) bytesToUint64(b []byte) uint64 { - return binary.LittleEndian.Uint64(b) -} - -// -// type testing and converting -// - -func (p *TCompactProtocol) isBoolType(b byte) bool { - return (b&0x0f) == COMPACT_BOOLEAN_TRUE || (b&0x0f) == COMPACT_BOOLEAN_FALSE -} - -// Given a tCompactType constant, convert it to its corresponding -// TType value. -func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) { - switch byte(t) & 0x0f { - case STOP: - return STOP, nil - case COMPACT_BOOLEAN_FALSE, COMPACT_BOOLEAN_TRUE: - return BOOL, nil - case COMPACT_BYTE: - return BYTE, nil - case COMPACT_I16: - return I16, nil - case COMPACT_I32: - return I32, nil - case COMPACT_I64: - return I64, nil - case COMPACT_DOUBLE: - return DOUBLE, nil - case COMPACT_BINARY: - return STRING, nil - case COMPACT_LIST: - return LIST, nil - case COMPACT_SET: - return SET, nil - case COMPACT_MAP: - return MAP, nil - case COMPACT_STRUCT: - return STRUCT, nil - } - return STOP, TException(fmt.Errorf("don't know what type: %v", t&0x0f)) -} - -// Given a TType value, find the appropriate TCompactProtocol.Types constant. -func (p *TCompactProtocol) getCompactType(t TType) tCompactType { - return ttypeToCompactType[t] -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go deleted file mode 100644 index 65f77f2..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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" - "testing" -) - -func TestReadWriteCompactProtocol(t *testing.T) { - ReadWriteProtocolTest(t, NewTCompactProtocolFactory()) - - transports := []TTransport{ - NewTMemoryBuffer(), - NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))), - NewTFramedTransport(NewTMemoryBuffer()), - } - - zlib0, _ := NewTZlibTransport(NewTMemoryBuffer(), 0) - zlib6, _ := NewTZlibTransport(NewTMemoryBuffer(), 6) - zlib9, _ := NewTZlibTransport(NewTFramedTransport(NewTMemoryBuffer()), 9) - transports = append(transports, zlib0, zlib6, zlib9) - - for _, trans := range transports { - p := NewTCompactProtocol(trans) - ReadWriteBool(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteByte(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI16(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI32(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteI64(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteDouble(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteString(t, p, trans) - p = NewTCompactProtocol(trans) - ReadWriteBinary(t, p, trans) - trans.Close() - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/context.go b/vendor/github.com/apache/thrift/lib/go/thrift/context.go deleted file mode 100644 index d15c1bc..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/context.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 "context" - -var defaultCtx = context.Background() diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go deleted file mode 100644 index 57943e0..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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 ( - "context" - "log" -) - -type TDebugProtocol struct { - Delegate TProtocol - LogPrefix string -} - -type TDebugProtocolFactory struct { - Underlying TProtocolFactory - LogPrefix string -} - -func NewTDebugProtocolFactory(underlying TProtocolFactory, logPrefix string) *TDebugProtocolFactory { - return &TDebugProtocolFactory{ - Underlying: underlying, - LogPrefix: logPrefix, - } -} - -func (t *TDebugProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return &TDebugProtocol{ - Delegate: t.Underlying.GetProtocol(trans), - LogPrefix: t.LogPrefix, - } -} - -func (tdp *TDebugProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error { - err := tdp.Delegate.WriteMessageBegin(name, typeId, seqid) - log.Printf("%sWriteMessageBegin(name=%#v, typeId=%#v, seqid=%#v) => %#v", tdp.LogPrefix, name, typeId, seqid, err) - return err -} -func (tdp *TDebugProtocol) WriteMessageEnd() error { - err := tdp.Delegate.WriteMessageEnd() - log.Printf("%sWriteMessageEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteStructBegin(name string) error { - err := tdp.Delegate.WriteStructBegin(name) - log.Printf("%sWriteStructBegin(name=%#v) => %#v", tdp.LogPrefix, name, err) - return err -} -func (tdp *TDebugProtocol) WriteStructEnd() error { - err := tdp.Delegate.WriteStructEnd() - log.Printf("%sWriteStructEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - err := tdp.Delegate.WriteFieldBegin(name, typeId, id) - log.Printf("%sWriteFieldBegin(name=%#v, typeId=%#v, id%#v) => %#v", tdp.LogPrefix, name, typeId, id, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldEnd() error { - err := tdp.Delegate.WriteFieldEnd() - log.Printf("%sWriteFieldEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteFieldStop() error { - err := tdp.Delegate.WriteFieldStop() - log.Printf("%sWriteFieldStop() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - err := tdp.Delegate.WriteMapBegin(keyType, valueType, size) - log.Printf("%sWriteMapBegin(keyType=%#v, valueType=%#v, size=%#v) => %#v", tdp.LogPrefix, keyType, valueType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteMapEnd() error { - err := tdp.Delegate.WriteMapEnd() - log.Printf("%sWriteMapEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteListBegin(elemType TType, size int) error { - err := tdp.Delegate.WriteListBegin(elemType, size) - log.Printf("%sWriteListBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteListEnd() error { - err := tdp.Delegate.WriteListEnd() - log.Printf("%sWriteListEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteSetBegin(elemType TType, size int) error { - err := tdp.Delegate.WriteSetBegin(elemType, size) - log.Printf("%sWriteSetBegin(elemType=%#v, size=%#v) => %#v", tdp.LogPrefix, elemType, size, err) - return err -} -func (tdp *TDebugProtocol) WriteSetEnd() error { - err := tdp.Delegate.WriteSetEnd() - log.Printf("%sWriteSetEnd() => %#v", tdp.LogPrefix, err) - return err -} -func (tdp *TDebugProtocol) WriteBool(value bool) error { - err := tdp.Delegate.WriteBool(value) - log.Printf("%sWriteBool(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteByte(value int8) error { - err := tdp.Delegate.WriteByte(value) - log.Printf("%sWriteByte(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI16(value int16) error { - err := tdp.Delegate.WriteI16(value) - log.Printf("%sWriteI16(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI32(value int32) error { - err := tdp.Delegate.WriteI32(value) - log.Printf("%sWriteI32(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteI64(value int64) error { - err := tdp.Delegate.WriteI64(value) - log.Printf("%sWriteI64(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteDouble(value float64) error { - err := tdp.Delegate.WriteDouble(value) - log.Printf("%sWriteDouble(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteString(value string) error { - err := tdp.Delegate.WriteString(value) - log.Printf("%sWriteString(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} -func (tdp *TDebugProtocol) WriteBinary(value []byte) error { - err := tdp.Delegate.WriteBinary(value) - log.Printf("%sWriteBinary(value=%#v) => %#v", tdp.LogPrefix, value, err) - return err -} - -func (tdp *TDebugProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqid int32, err error) { - name, typeId, seqid, err = tdp.Delegate.ReadMessageBegin() - log.Printf("%sReadMessageBegin() (name=%#v, typeId=%#v, seqid=%#v, err=%#v)", tdp.LogPrefix, name, typeId, seqid, err) - return -} -func (tdp *TDebugProtocol) ReadMessageEnd() (err error) { - err = tdp.Delegate.ReadMessageEnd() - log.Printf("%sReadMessageEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadStructBegin() (name string, err error) { - name, err = tdp.Delegate.ReadStructBegin() - log.Printf("%sReadStructBegin() (name%#v, err=%#v)", tdp.LogPrefix, name, err) - return -} -func (tdp *TDebugProtocol) ReadStructEnd() (err error) { - err = tdp.Delegate.ReadStructEnd() - log.Printf("%sReadStructEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadFieldBegin() (name string, typeId TType, id int16, err error) { - name, typeId, id, err = tdp.Delegate.ReadFieldBegin() - log.Printf("%sReadFieldBegin() (name=%#v, typeId=%#v, id=%#v, err=%#v)", tdp.LogPrefix, name, typeId, id, err) - return -} -func (tdp *TDebugProtocol) ReadFieldEnd() (err error) { - err = tdp.Delegate.ReadFieldEnd() - log.Printf("%sReadFieldEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, err error) { - keyType, valueType, size, err = tdp.Delegate.ReadMapBegin() - log.Printf("%sReadMapBegin() (keyType=%#v, valueType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, keyType, valueType, size, err) - return -} -func (tdp *TDebugProtocol) ReadMapEnd() (err error) { - err = tdp.Delegate.ReadMapEnd() - log.Printf("%sReadMapEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadListBegin() (elemType TType, size int, err error) { - elemType, size, err = tdp.Delegate.ReadListBegin() - log.Printf("%sReadListBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) - return -} -func (tdp *TDebugProtocol) ReadListEnd() (err error) { - err = tdp.Delegate.ReadListEnd() - log.Printf("%sReadListEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadSetBegin() (elemType TType, size int, err error) { - elemType, size, err = tdp.Delegate.ReadSetBegin() - log.Printf("%sReadSetBegin() (elemType=%#v, size=%#v, err=%#v)", tdp.LogPrefix, elemType, size, err) - return -} -func (tdp *TDebugProtocol) ReadSetEnd() (err error) { - err = tdp.Delegate.ReadSetEnd() - log.Printf("%sReadSetEnd() err=%#v", tdp.LogPrefix, err) - return -} -func (tdp *TDebugProtocol) ReadBool() (value bool, err error) { - value, err = tdp.Delegate.ReadBool() - log.Printf("%sReadBool() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadByte() (value int8, err error) { - value, err = tdp.Delegate.ReadByte() - log.Printf("%sReadByte() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI16() (value int16, err error) { - value, err = tdp.Delegate.ReadI16() - log.Printf("%sReadI16() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI32() (value int32, err error) { - value, err = tdp.Delegate.ReadI32() - log.Printf("%sReadI32() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadI64() (value int64, err error) { - value, err = tdp.Delegate.ReadI64() - log.Printf("%sReadI64() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadDouble() (value float64, err error) { - value, err = tdp.Delegate.ReadDouble() - log.Printf("%sReadDouble() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadString() (value string, err error) { - value, err = tdp.Delegate.ReadString() - log.Printf("%sReadString() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) ReadBinary() (value []byte, err error) { - value, err = tdp.Delegate.ReadBinary() - log.Printf("%sReadBinary() (value=%#v, err=%#v)", tdp.LogPrefix, value, err) - return -} -func (tdp *TDebugProtocol) Skip(fieldType TType) (err error) { - err = tdp.Delegate.Skip(fieldType) - log.Printf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err) - return -} -func (tdp *TDebugProtocol) Flush(ctx context.Context) (err error) { - err = tdp.Delegate.Flush(ctx) - log.Printf("%sFlush() (err=%#v)", tdp.LogPrefix, err) - return -} - -func (tdp *TDebugProtocol) Transport() TTransport { - return tdp.Delegate.Transport() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go deleted file mode 100644 index 91a0983..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 - -type TDeserializer struct { - Transport TTransport - Protocol TProtocol -} - -func NewTDeserializer() *TDeserializer { - var transport TTransport - transport = NewTMemoryBufferLen(1024) - - protocol := NewTBinaryProtocolFactoryDefault().GetProtocol(transport) - - return &TDeserializer{ - transport, - protocol} -} - -func (t *TDeserializer) ReadString(msg TStruct, s string) (err error) { - err = nil - if _, err = t.Transport.Write([]byte(s)); err != nil { - return - } - if err = msg.Read(t.Protocol); err != nil { - return - } - return -} - -func (t *TDeserializer) Read(msg TStruct, b []byte) (err error) { - err = nil - if _, err = t.Transport.Write(b); err != nil { - return - } - if err = msg.Read(t.Protocol); err != nil { - return - } - return -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/exception.go deleted file mode 100644 index ea8d6f6..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/exception.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 ( - "errors" -) - -// Generic Thrift exception -type TException interface { - error -} - -// Prepends additional information to an error without losing the Thrift exception interface -func PrependError(prepend string, err error) error { - if t, ok := err.(TTransportException); ok { - return NewTTransportException(t.TypeId(), prepend+t.Error()) - } - if t, ok := err.(TProtocolException); ok { - return NewTProtocolExceptionWithType(t.TypeId(), errors.New(prepend+err.Error())) - } - if t, ok := err.(TApplicationException); ok { - return NewTApplicationException(t.TypeId(), prepend+t.Error()) - } - - return errors.New(prepend + err.Error()) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go deleted file mode 100644 index 71f5e2c..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 ( - "errors" - "testing" -) - -func TestPrependError(t *testing.T) { - err := NewTApplicationException(INTERNAL_ERROR, "original error") - err2, ok := PrependError("Prepend: ", err).(TApplicationException) - if !ok { - t.Fatal("Couldn't cast error TApplicationException") - } - if err2.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err2.TypeId() != INTERNAL_ERROR { - t.Fatal("Unexpected type error") - } - - err3 := NewTProtocolExceptionWithType(INVALID_DATA, errors.New("original error")) - err4, ok := PrependError("Prepend: ", err3).(TProtocolException) - if !ok { - t.Fatal("Couldn't cast error TProtocolException") - } - if err4.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err4.TypeId() != INVALID_DATA { - t.Fatal("Unexpected type error") - } - - err5 := NewTTransportException(TIMED_OUT, "original error") - err6, ok := PrependError("Prepend: ", err5).(TTransportException) - if !ok { - t.Fatal("Couldn't cast error TTransportException") - } - if err6.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } - if err6.TypeId() != TIMED_OUT { - t.Fatal("Unexpected type error") - } - - err7 := errors.New("original error") - err8 := PrependError("Prepend: ", err7) - if err8.Error() != "Prepend: original error" { - t.Fatal("Unexpected error string") - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/field.go b/vendor/github.com/apache/thrift/lib/go/thrift/field.go deleted file mode 100644 index 9d66525..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/field.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 - -// Helper class that encapsulates field metadata. -type field struct { - name string - typeId TType - id int -} - -func newField(n string, t TType, i int) *field { - return &field{name: n, typeId: t, id: i} -} - -func (p *field) Name() string { - if p == nil { - return "" - } - return p.name -} - -func (p *field) TypeId() TType { - if p == nil { - return TType(VOID) - } - return p.typeId -} - -func (p *field) Id() int { - if p == nil { - return -1 - } - return p.id -} - -func (p *field) String() string { - if p == nil { - return "" - } - return "" -} - -var ANONYMOUS_FIELD *field - -type fieldSlice []field - -func (p fieldSlice) Len() int { - return len(p) -} - -func (p fieldSlice) Less(i, j int) bool { - return p[i].Id() < p[j].Id() -} - -func (p fieldSlice) Swap(i, j int) { - p[i], p[j] = p[j], p[i] -} - -func init() { - ANONYMOUS_FIELD = newField("", STOP, 0) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go deleted file mode 100644 index 81fa65a..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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 ( - "bufio" - "bytes" - "context" - "encoding/binary" - "fmt" - "io" -) - -const DEFAULT_MAX_LENGTH = 16384000 - -type TFramedTransport struct { - transport TTransport - buf bytes.Buffer - reader *bufio.Reader - frameSize uint32 //Current remaining size of the frame. if ==0 read next frame header - buffer [4]byte - maxLength uint32 -} - -type tFramedTransportFactory struct { - factory TTransportFactory - maxLength uint32 -} - -func NewTFramedTransportFactory(factory TTransportFactory) TTransportFactory { - return &tFramedTransportFactory{factory: factory, maxLength: DEFAULT_MAX_LENGTH} -} - -func NewTFramedTransportFactoryMaxLength(factory TTransportFactory, maxLength uint32) TTransportFactory { - return &tFramedTransportFactory{factory: factory, maxLength: maxLength} -} - -func (p *tFramedTransportFactory) GetTransport(base TTransport) (TTransport, error) { - tt, err := p.factory.GetTransport(base) - if err != nil { - return nil, err - } - return NewTFramedTransportMaxLength(tt, p.maxLength), nil -} - -func NewTFramedTransport(transport TTransport) *TFramedTransport { - return &TFramedTransport{transport: transport, reader: bufio.NewReader(transport), maxLength: DEFAULT_MAX_LENGTH} -} - -func NewTFramedTransportMaxLength(transport TTransport, maxLength uint32) *TFramedTransport { - return &TFramedTransport{transport: transport, reader: bufio.NewReader(transport), maxLength: maxLength} -} - -func (p *TFramedTransport) Open() error { - return p.transport.Open() -} - -func (p *TFramedTransport) IsOpen() bool { - return p.transport.IsOpen() -} - -func (p *TFramedTransport) Close() error { - return p.transport.Close() -} - -func (p *TFramedTransport) Read(buf []byte) (l int, err error) { - if p.frameSize == 0 { - p.frameSize, err = p.readFrameHeader() - if err != nil { - return - } - } - if p.frameSize < uint32(len(buf)) { - frameSize := p.frameSize - tmp := make([]byte, p.frameSize) - l, err = p.Read(tmp) - copy(buf, tmp) - if err == nil { - err = NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", frameSize, len(buf))) - return - } - } - got, err := p.reader.Read(buf) - p.frameSize = p.frameSize - uint32(got) - //sanity check - if p.frameSize < 0 { - return 0, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Negative frame size") - } - return got, NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) ReadByte() (c byte, err error) { - if p.frameSize == 0 { - p.frameSize, err = p.readFrameHeader() - if err != nil { - return - } - } - if p.frameSize < 1 { - return 0, NewTTransportExceptionFromError(fmt.Errorf("Not enough frame size %d to read %d bytes", p.frameSize, 1)) - } - c, err = p.reader.ReadByte() - if err == nil { - p.frameSize-- - } - return -} - -func (p *TFramedTransport) Write(buf []byte) (int, error) { - n, err := p.buf.Write(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) WriteByte(c byte) error { - return p.buf.WriteByte(c) -} - -func (p *TFramedTransport) WriteString(s string) (n int, err error) { - return p.buf.WriteString(s) -} - -func (p *TFramedTransport) Flush(ctx context.Context) error { - size := p.buf.Len() - buf := p.buffer[:4] - binary.BigEndian.PutUint32(buf, uint32(size)) - _, err := p.transport.Write(buf) - if err != nil { - p.buf.Truncate(0) - return NewTTransportExceptionFromError(err) - } - if size > 0 { - if n, err := p.buf.WriteTo(p.transport); err != nil { - print("Error while flushing write buffer of size ", size, " to transport, only wrote ", n, " bytes: ", err.Error(), "\n") - p.buf.Truncate(0) - return NewTTransportExceptionFromError(err) - } - } - err = p.transport.Flush(ctx) - return NewTTransportExceptionFromError(err) -} - -func (p *TFramedTransport) readFrameHeader() (uint32, error) { - buf := p.buffer[:4] - if _, err := io.ReadFull(p.reader, buf); err != nil { - return 0, err - } - size := binary.BigEndian.Uint32(buf) - if size < 0 || size > p.maxLength { - return 0, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, fmt.Sprintf("Incorrect frame size (%d)", size)) - } - return size, nil -} - -func (p *TFramedTransport) RemainingBytes() (num_bytes uint64) { - return uint64(p.frameSize) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go deleted file mode 100644 index 8f683ef..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestFramedTransport(t *testing.T) { - trans := NewTFramedTransport(NewTMemoryBuffer()) - TransportTest(t, trans, trans) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go deleted file mode 100644 index 5c82bf5..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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" - "context" - "io" - "io/ioutil" - "net/http" - "net/url" - "strconv" -) - -// Default to using the shared http client. Library users are -// free to change this global client or specify one through -// THttpClientOptions. -var DefaultHttpClient *http.Client = http.DefaultClient - -type THttpClient struct { - client *http.Client - response *http.Response - url *url.URL - requestBuffer *bytes.Buffer - header http.Header - nsecConnectTimeout int64 - nsecReadTimeout int64 -} - -type THttpClientTransportFactory struct { - options THttpClientOptions - url string -} - -func (p *THttpClientTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - if trans != nil { - t, ok := trans.(*THttpClient) - if ok && t.url != nil { - return NewTHttpClientWithOptions(t.url.String(), p.options) - } - } - return NewTHttpClientWithOptions(p.url, p.options) -} - -type THttpClientOptions struct { - // If nil, DefaultHttpClient is used - Client *http.Client -} - -func NewTHttpClientTransportFactory(url string) *THttpClientTransportFactory { - return NewTHttpClientTransportFactoryWithOptions(url, THttpClientOptions{}) -} - -func NewTHttpClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return &THttpClientTransportFactory{url: url, options: options} -} - -func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { - parsedURL, err := url.Parse(urlstr) - if err != nil { - return nil, err - } - buf := make([]byte, 0, 1024) - client := options.Client - if client == nil { - client = DefaultHttpClient - } - httpHeader := map[string][]string{"Content-Type": {"application/x-thrift"}} - return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil -} - -func NewTHttpClient(urlstr string) (TTransport, error) { - return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) -} - -// Set the HTTP Header for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// httpTrans.SetHeader("User-Agent","Thrift Client 1.0") -func (p *THttpClient) SetHeader(key string, value string) { - p.header.Add(key, value) -} - -// Get the HTTP Header represented by the supplied Header Key for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// hdrValue := httpTrans.GetHeader("User-Agent") -func (p *THttpClient) GetHeader(key string) string { - return p.header.Get(key) -} - -// Deletes the HTTP Header given a Header Key for this specific Thrift Transport -// It is important that you first assert the TTransport as a THttpClient type -// like so: -// -// httpTrans := trans.(THttpClient) -// httpTrans.DelHeader("User-Agent") -func (p *THttpClient) DelHeader(key string) { - p.header.Del(key) -} - -func (p *THttpClient) Open() error { - // do nothing - return nil -} - -func (p *THttpClient) IsOpen() bool { - return p.response != nil || p.requestBuffer != nil -} - -func (p *THttpClient) closeResponse() error { - var err error - if p.response != nil && p.response.Body != nil { - // The docs specify that if keepalive is enabled and the response body is not - // read to completion the connection will never be returned to the pool and - // reused. Errors are being ignored here because if the connection is invalid - // and this fails for some reason, the Close() method will do any remaining - // cleanup. - io.Copy(ioutil.Discard, p.response.Body) - - err = p.response.Body.Close() - } - - p.response = nil - return err -} - -func (p *THttpClient) Close() error { - if p.requestBuffer != nil { - p.requestBuffer.Reset() - p.requestBuffer = nil - } - return p.closeResponse() -} - -func (p *THttpClient) Read(buf []byte) (int, error) { - if p.response == nil { - return 0, NewTTransportException(NOT_OPEN, "Response buffer is empty, no request.") - } - n, err := p.response.Body.Read(buf) - if n > 0 && (err == nil || err == io.EOF) { - return n, nil - } - return n, NewTTransportExceptionFromError(err) -} - -func (p *THttpClient) ReadByte() (c byte, err error) { - return readByte(p.response.Body) -} - -func (p *THttpClient) Write(buf []byte) (int, error) { - n, err := p.requestBuffer.Write(buf) - return n, err -} - -func (p *THttpClient) WriteByte(c byte) error { - return p.requestBuffer.WriteByte(c) -} - -func (p *THttpClient) WriteString(s string) (n int, err error) { - return p.requestBuffer.WriteString(s) -} - -func (p *THttpClient) Flush(ctx context.Context) error { - // Close any previous response body to avoid leaking connections. - p.closeResponse() - - req, err := http.NewRequest("POST", p.url.String(), p.requestBuffer) - if err != nil { - return NewTTransportExceptionFromError(err) - } - req.Header = p.header - if ctx != nil { - req = req.WithContext(ctx) - } - response, err := p.client.Do(req) - if err != nil { - return NewTTransportExceptionFromError(err) - } - if response.StatusCode != http.StatusOK { - // Close the response to avoid leaking file descriptors. closeResponse does - // more than just call Close(), so temporarily assign it and reuse the logic. - p.response = response - p.closeResponse() - - // TODO(pomack) log bad response - return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "HTTP Response code: "+strconv.Itoa(response.StatusCode)) - } - p.response = response - return nil -} - -func (p *THttpClient) RemainingBytes() (num_bytes uint64) { - len := p.response.ContentLength - if len >= 0 { - return uint64(len) - } - - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} - -// Deprecated: Use NewTHttpClientTransportFactory instead. -func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory { - return NewTHttpClientTransportFactoryWithOptions(url, THttpClientOptions{}) -} - -// Deprecated: Use NewTHttpClientTransportFactoryWithOptions instead. -func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return NewTHttpClientTransportFactoryWithOptions(url, options) -} - -// Deprecated: Use NewTHttpClientWithOptions instead. -func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { - return NewTHttpClientWithOptions(urlstr, options) -} - -// Deprecated: Use NewTHttpClient instead. -func NewTHttpPostClient(urlstr string) (TTransport, error) { - return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go deleted file mode 100644 index 453680a..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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 ( - "net/http" - "testing" -) - -func TestHttpClient(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportTest(t, trans, trans) -} - -func TestHttpClientHeaders(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) -} - -func TestHttpCustomClient(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - - httpTransport := &customHttpTransport{} - - trans, err := NewTHttpPostClientWithOptions("http://"+addr.String(), THttpClientOptions{ - Client: &http.Client{ - Transport: httpTransport, - }, - }) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) - - if !httpTransport.hit { - t.Fatalf("Custom client was not used") - } -} - -func TestHttpCustomClientPackageScope(t *testing.T) { - l, addr := HttpClientSetupForTest(t) - if l != nil { - defer l.Close() - } - httpTransport := &customHttpTransport{} - DefaultHttpClient = &http.Client{ - Transport: httpTransport, - } - - trans, err := NewTHttpPostClient("http://" + addr.String()) - if err != nil { - l.Close() - t.Fatalf("Unable to connect to %s: %s", addr.String(), err) - } - TransportHeaderTest(t, trans, trans) - - if !httpTransport.hit { - t.Fatalf("Custom client was not used") - } -} - -type customHttpTransport struct { - hit bool -} - -func (c *customHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { - c.hit = true - return http.DefaultTransport.RoundTrip(req) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go deleted file mode 100644 index 66f0f38..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 ( - "compress/gzip" - "io" - "net/http" - "strings" -) - -// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function -func NewThriftHandlerFunc(processor TProcessor, - inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) { - - return gz(func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("Content-Type", "application/x-thrift") - - transport := NewStreamTransport(r.Body, w) - processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport)) - }) -} - -// gz transparently compresses the HTTP response if the client supports it. -func gz(handler http.HandlerFunc) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { - handler(w, r) - return - } - w.Header().Set("Content-Encoding", "gzip") - gz := gzip.NewWriter(w) - defer gz.Close() - gzw := gzipResponseWriter{Writer: gz, ResponseWriter: w} - handler(gzw, r) - } -} - -type gzipResponseWriter struct { - io.Writer - http.ResponseWriter -} - -func (w gzipResponseWriter) Write(b []byte) (int, error) { - return w.Writer.Write(b) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go deleted file mode 100644 index fea93bc..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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 ( - "bufio" - "context" - "io" -) - -// StreamTransport is a Transport made of an io.Reader and/or an io.Writer -type StreamTransport struct { - io.Reader - io.Writer - isReadWriter bool - closed bool -} - -type StreamTransportFactory struct { - Reader io.Reader - Writer io.Writer - isReadWriter bool -} - -func (p *StreamTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - if trans != nil { - t, ok := trans.(*StreamTransport) - if ok { - if t.isReadWriter { - return NewStreamTransportRW(t.Reader.(io.ReadWriter)), nil - } - if t.Reader != nil && t.Writer != nil { - return NewStreamTransport(t.Reader, t.Writer), nil - } - if t.Reader != nil && t.Writer == nil { - return NewStreamTransportR(t.Reader), nil - } - if t.Reader == nil && t.Writer != nil { - return NewStreamTransportW(t.Writer), nil - } - return &StreamTransport{}, nil - } - } - if p.isReadWriter { - return NewStreamTransportRW(p.Reader.(io.ReadWriter)), nil - } - if p.Reader != nil && p.Writer != nil { - return NewStreamTransport(p.Reader, p.Writer), nil - } - if p.Reader != nil && p.Writer == nil { - return NewStreamTransportR(p.Reader), nil - } - if p.Reader == nil && p.Writer != nil { - return NewStreamTransportW(p.Writer), nil - } - return &StreamTransport{}, nil -} - -func NewStreamTransportFactory(reader io.Reader, writer io.Writer, isReadWriter bool) *StreamTransportFactory { - return &StreamTransportFactory{Reader: reader, Writer: writer, isReadWriter: isReadWriter} -} - -func NewStreamTransport(r io.Reader, w io.Writer) *StreamTransport { - return &StreamTransport{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)} -} - -func NewStreamTransportR(r io.Reader) *StreamTransport { - return &StreamTransport{Reader: bufio.NewReader(r)} -} - -func NewStreamTransportW(w io.Writer) *StreamTransport { - return &StreamTransport{Writer: bufio.NewWriter(w)} -} - -func NewStreamTransportRW(rw io.ReadWriter) *StreamTransport { - bufrw := bufio.NewReadWriter(bufio.NewReader(rw), bufio.NewWriter(rw)) - return &StreamTransport{Reader: bufrw, Writer: bufrw, isReadWriter: true} -} - -func (p *StreamTransport) IsOpen() bool { - return !p.closed -} - -// implicitly opened on creation, can't be reopened once closed -func (p *StreamTransport) Open() error { - if !p.closed { - return NewTTransportException(ALREADY_OPEN, "StreamTransport already open.") - } else { - return NewTTransportException(NOT_OPEN, "cannot reopen StreamTransport.") - } -} - -// Closes both the input and output streams. -func (p *StreamTransport) Close() error { - if p.closed { - return NewTTransportException(NOT_OPEN, "StreamTransport already closed.") - } - p.closed = true - closedReader := false - if p.Reader != nil { - c, ok := p.Reader.(io.Closer) - if ok { - e := c.Close() - closedReader = true - if e != nil { - return e - } - } - p.Reader = nil - } - if p.Writer != nil && (!closedReader || !p.isReadWriter) { - c, ok := p.Writer.(io.Closer) - if ok { - e := c.Close() - if e != nil { - return e - } - } - p.Writer = nil - } - return nil -} - -// Flushes the underlying output stream if not null. -func (p *StreamTransport) Flush(ctx context.Context) error { - if p.Writer == nil { - return NewTTransportException(NOT_OPEN, "Cannot flush null outputStream") - } - f, ok := p.Writer.(Flusher) - if ok { - err := f.Flush() - if err != nil { - return NewTTransportExceptionFromError(err) - } - } - return nil -} - -func (p *StreamTransport) Read(c []byte) (n int, err error) { - n, err = p.Reader.Read(c) - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) ReadByte() (c byte, err error) { - f, ok := p.Reader.(io.ByteReader) - if ok { - c, err = f.ReadByte() - } else { - c, err = readByte(p.Reader) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) Write(c []byte) (n int, err error) { - n, err = p.Writer.Write(c) - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) WriteByte(c byte) (err error) { - f, ok := p.Writer.(io.ByteWriter) - if ok { - err = f.WriteByte(c) - } else { - err = writeByte(p.Writer, c) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) WriteString(s string) (n int, err error) { - f, ok := p.Writer.(stringWriter) - if ok { - n, err = f.WriteString(s) - } else { - n, err = p.Writer.Write([]byte(s)) - } - if err != nil { - err = NewTTransportExceptionFromError(err) - } - return -} - -func (p *StreamTransport) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go deleted file mode 100644 index 15a6116..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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" - "testing" -) - -func TestStreamTransport(t *testing.T) { - trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) - TransportTest(t, trans, trans) -} - -func TestStreamTransportOpenClose(t *testing.T) { - trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) - if !trans.IsOpen() { - t.Fatal("StreamTransport should be already open") - } - if trans.Open() == nil { - t.Fatal("StreamTransport should return error when open twice") - } - if trans.Close() != nil { - t.Fatal("StreamTransport should not return error when closing open transport") - } - if trans.IsOpen() { - t.Fatal("StreamTransport should not be open after close") - } - if trans.Close() == nil { - t.Fatal("StreamTransport should return error when closing a non open transport") - } - if trans.Open() == nil { - t.Fatal("StreamTransport should not be able to reopen") - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go deleted file mode 100644 index 7be685d..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go +++ /dev/null @@ -1,584 +0,0 @@ -/* - * 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 ( - "context" - "encoding/base64" - "fmt" -) - -const ( - THRIFT_JSON_PROTOCOL_VERSION = 1 -) - -// for references to _ParseContext see tsimplejson_protocol.go - -// JSON protocol implementation for thrift. -// -// 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 TJSONProtocol struct { - *TSimpleJSONProtocol -} - -// Constructor -func NewTJSONProtocol(t TTransport) *TJSONProtocol { - v := &TJSONProtocol{TSimpleJSONProtocol: NewTSimpleJSONProtocol(t)} - v.parseContextStack = append(v.parseContextStack, int(_CONTEXT_IN_TOPLEVEL)) - v.dumpContext = append(v.dumpContext, int(_CONTEXT_IN_TOPLEVEL)) - return v -} - -// Factory -type TJSONProtocolFactory struct{} - -func (p *TJSONProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return NewTJSONProtocol(trans) -} - -func NewTJSONProtocolFactory() *TJSONProtocolFactory { - return &TJSONProtocolFactory{} -} - -func (p *TJSONProtocol) WriteMessageBegin(name string, typeId TMessageType, seqId int32) error { - p.resetContextStack() // THRIFT-3735 - if e := p.OutputListBegin(); e != nil { - return e - } - if e := p.WriteI32(THRIFT_JSON_PROTOCOL_VERSION); e != nil { - return e - } - if e := p.WriteString(name); e != nil { - return e - } - if e := p.WriteByte(int8(typeId)); e != nil { - return e - } - if e := p.WriteI32(seqId); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteMessageEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteStructBegin(name string) error { - if e := p.OutputObjectBegin(); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteStructEnd() error { - return p.OutputObjectEnd() -} - -func (p *TJSONProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - if e := p.WriteI16(id); e != nil { - return e - } - if e := p.OutputObjectBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(typeId) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) WriteFieldEnd() error { - return p.OutputObjectEnd() -} - -func (p *TJSONProtocol) WriteFieldStop() error { return nil } - -func (p *TJSONProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(keyType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - s, e1 = p.TypeIdToString(valueType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - if e := p.WriteI64(int64(size)); e != nil { - return e - } - return p.OutputObjectBegin() -} - -func (p *TJSONProtocol) WriteMapEnd() error { - if e := p.OutputObjectEnd(); e != nil { - return e - } - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteListBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TJSONProtocol) WriteListEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteSetBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TJSONProtocol) WriteSetEnd() error { - return p.OutputListEnd() -} - -func (p *TJSONProtocol) WriteBool(b bool) error { - if b { - return p.WriteI32(1) - } - return p.WriteI32(0) -} - -func (p *TJSONProtocol) WriteByte(b int8) error { - return p.WriteI32(int32(b)) -} - -func (p *TJSONProtocol) WriteI16(v int16) error { - return p.WriteI32(int32(v)) -} - -func (p *TJSONProtocol) WriteI32(v int32) error { - return p.OutputI64(int64(v)) -} - -func (p *TJSONProtocol) WriteI64(v int64) error { - return p.OutputI64(int64(v)) -} - -func (p *TJSONProtocol) WriteDouble(v float64) error { - return p.OutputF64(v) -} - -func (p *TJSONProtocol) WriteString(v string) error { - return p.OutputString(v) -} - -func (p *TJSONProtocol) WriteBinary(v []byte) error { - // JSON library only takes in a string, - // not an arbitrary byte array, to ensure bytes are transmitted - // efficiently we must convert this into a valid JSON string - // therefore we use base64 encoding to avoid excessive escaping/quoting - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - writer := base64.NewEncoder(base64.StdEncoding, p.writer) - if _, e := writer.Write(v); e != nil { - p.writer.Reset(p.trans) // THRIFT-3735 - return NewTProtocolException(e) - } - if e := writer.Close(); e != nil { - return NewTProtocolException(e) - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - return p.OutputPostValue() -} - -// Reading methods. -func (p *TJSONProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) { - p.resetContextStack() // THRIFT-3735 - if isNull, err := p.ParseListBegin(); isNull || err != nil { - return name, typeId, seqId, err - } - version, err := p.ReadI32() - if err != nil { - return name, typeId, seqId, err - } - if version != THRIFT_JSON_PROTOCOL_VERSION { - e := fmt.Errorf("Unknown Protocol version %d, expected version %d", version, THRIFT_JSON_PROTOCOL_VERSION) - return name, typeId, seqId, NewTProtocolExceptionWithType(INVALID_DATA, e) - - } - if name, err = p.ReadString(); err != nil { - return name, typeId, seqId, err - } - bTypeId, err := p.ReadByte() - typeId = TMessageType(bTypeId) - if err != nil { - return name, typeId, seqId, err - } - if seqId, err = p.ReadI32(); err != nil { - return name, typeId, seqId, err - } - return name, typeId, seqId, nil -} - -func (p *TJSONProtocol) ReadMessageEnd() error { - err := p.ParseListEnd() - return err -} - -func (p *TJSONProtocol) ReadStructBegin() (name string, err error) { - _, err = p.ParseObjectStart() - return "", err -} - -func (p *TJSONProtocol) ReadStructEnd() error { - return p.ParseObjectEnd() -} - -func (p *TJSONProtocol) ReadFieldBegin() (string, TType, int16, error) { - b, _ := p.reader.Peek(1) - if len(b) < 1 || b[0] == JSON_RBRACE[0] || b[0] == JSON_RBRACKET[0] { - return "", STOP, -1, nil - } - fieldId, err := p.ReadI16() - if err != nil { - return "", STOP, fieldId, err - } - if _, err = p.ParseObjectStart(); err != nil { - return "", STOP, fieldId, err - } - sType, err := p.ReadString() - if err != nil { - return "", STOP, fieldId, err - } - fType, err := p.StringToTypeId(sType) - return "", fType, fieldId, err -} - -func (p *TJSONProtocol) ReadFieldEnd() error { - return p.ParseObjectEnd() -} - -func (p *TJSONProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, VOID, 0, e - } - - // read keyType - sKeyType, e := p.ReadString() - if e != nil { - return keyType, valueType, size, e - } - keyType, e = p.StringToTypeId(sKeyType) - if e != nil { - return keyType, valueType, size, e - } - - // read valueType - sValueType, e := p.ReadString() - if e != nil { - return keyType, valueType, size, e - } - valueType, e = p.StringToTypeId(sValueType) - if e != nil { - return keyType, valueType, size, e - } - - // read size - iSize, e := p.ReadI64() - if e != nil { - return keyType, valueType, size, e - } - size = int(iSize) - - _, e = p.ParseObjectStart() - return keyType, valueType, size, e -} - -func (p *TJSONProtocol) ReadMapEnd() error { - e := p.ParseObjectEnd() - if e != nil { - return e - } - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadListBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TJSONProtocol) ReadListEnd() error { - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadSetBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TJSONProtocol) ReadSetEnd() error { - return p.ParseListEnd() -} - -func (p *TJSONProtocol) ReadBool() (bool, error) { - value, err := p.ReadI32() - return (value != 0), err -} - -func (p *TJSONProtocol) ReadByte() (int8, error) { - v, err := p.ReadI64() - return int8(v), err -} - -func (p *TJSONProtocol) ReadI16() (int16, error) { - v, err := p.ReadI64() - return int16(v), err -} - -func (p *TJSONProtocol) ReadI32() (int32, error) { - v, err := p.ReadI64() - return int32(v), err -} - -func (p *TJSONProtocol) ReadI64() (int64, error) { - v, _, err := p.ParseI64() - return v, err -} - -func (p *TJSONProtocol) ReadDouble() (float64, error) { - v, _, err := p.ParseF64() - return v, err -} - -func (p *TJSONProtocol) ReadString() (string, error) { - var v string - if err := p.ParsePreValue(); err != nil { - return v, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseStringBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return v, p.ParsePostValue() -} - -func (p *TJSONProtocol) ReadBinary() ([]byte, error) { - var v []byte - if err := p.ParsePreValue(); err != nil { - return nil, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseBase64EncodedBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - - return v, p.ParsePostValue() -} - -func (p *TJSONProtocol) Flush(ctx context.Context) (err error) { - err = p.writer.Flush() - if err == nil { - err = p.trans.Flush(ctx) - } - return NewTProtocolException(err) -} - -func (p *TJSONProtocol) Skip(fieldType TType) (err error) { - return SkipDefaultDepth(p, fieldType) -} - -func (p *TJSONProtocol) Transport() TTransport { - return p.trans -} - -func (p *TJSONProtocol) OutputElemListBegin(elemType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(elemType) - if e1 != nil { - return e1 - } - if e := p.WriteString(s); e != nil { - return e - } - if e := p.WriteI64(int64(size)); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) ParseElemListBegin() (elemType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, 0, e - } - sElemType, err := p.ReadString() - if err != nil { - return VOID, size, err - } - elemType, err = p.StringToTypeId(sElemType) - if err != nil { - return elemType, size, err - } - nSize, err2 := p.ReadI64() - size = int(nSize) - return elemType, size, err2 -} - -func (p *TJSONProtocol) readElemListBegin() (elemType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, 0, e - } - sElemType, err := p.ReadString() - if err != nil { - return VOID, size, err - } - elemType, err = p.StringToTypeId(sElemType) - if err != nil { - return elemType, size, err - } - nSize, err2 := p.ReadI64() - size = int(nSize) - return elemType, size, err2 -} - -func (p *TJSONProtocol) writeElemListBegin(elemType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - s, e1 := p.TypeIdToString(elemType) - if e1 != nil { - return e1 - } - if e := p.OutputString(s); e != nil { - return e - } - if e := p.OutputI64(int64(size)); e != nil { - return e - } - return nil -} - -func (p *TJSONProtocol) TypeIdToString(fieldType TType) (string, error) { - switch byte(fieldType) { - case BOOL: - return "tf", nil - case BYTE: - return "i8", nil - case I16: - return "i16", nil - case I32: - return "i32", nil - case I64: - return "i64", nil - case DOUBLE: - return "dbl", nil - case STRING: - return "str", nil - case STRUCT: - return "rec", nil - case MAP: - return "map", nil - case SET: - return "set", nil - case LIST: - return "lst", nil - } - - e := fmt.Errorf("Unknown fieldType: %d", int(fieldType)) - return "", NewTProtocolExceptionWithType(INVALID_DATA, e) -} - -func (p *TJSONProtocol) StringToTypeId(fieldType string) (TType, error) { - switch fieldType { - case "tf": - return TType(BOOL), nil - case "i8": - return TType(BYTE), nil - case "i16": - return TType(I16), nil - case "i32": - return TType(I32), nil - case "i64": - return TType(I64), nil - case "dbl": - return TType(DOUBLE), nil - case "str": - return TType(STRING), nil - case "rec": - return TType(STRUCT), nil - case "map": - return TType(MAP), nil - case "set": - return TType(SET), nil - case "lst": - return TType(LIST), nil - } - - e := fmt.Errorf("Unknown type identifier: %s", fieldType) - return TType(STOP), NewTProtocolExceptionWithType(INVALID_DATA, e) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go deleted file mode 100644 index 59c4d64..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go +++ /dev/null @@ -1,650 +0,0 @@ -/* - * 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 ( - "context" - "encoding/base64" - "encoding/json" - "fmt" - "math" - "strconv" - "testing" -) - -func TestWriteJSONProtocolBool(t *testing.T) { - thetype := "boolean" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range BOOL_VALUES { - if e := p.WriteBool(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - expected := "" - if value { - expected = "1" - } else { - expected = "0" - } - if s != expected { - t.Fatalf("Bad value for %s %v: %s expected", thetype, value, s) - } - v := -1 - if err := json.Unmarshal([]byte(s), &v); err != nil || (v != 0) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolBool(t *testing.T) { - thetype := "boolean" - for _, value := range BOOL_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - if value { - trans.Write([]byte{'1'}) // not JSON_TRUE - } else { - trans.Write([]byte{'0'}) // not JSON_FALSE - } - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadBool() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - vv := -1 - if err := json.Unmarshal([]byte(s), &vv); err != nil || (vv != 0) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, vv) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolByte(t *testing.T) { - thetype := "byte" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range BYTE_VALUES { - if e := p.WriteByte(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int8(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolByte(t *testing.T) { - thetype := "byte" - for _, value := range BYTE_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadByte() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI16(t *testing.T) { - thetype := "int16" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT16_VALUES { - if e := p.WriteI16(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int16(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI16(t *testing.T) { - thetype := "int16" - for _, value := range INT16_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI16() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI32(t *testing.T) { - thetype := "int32" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT32_VALUES { - if e := p.WriteI32(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int32(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI32(t *testing.T) { - thetype := "int32" - for _, value := range INT32_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI32() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolI64(t *testing.T) { - thetype := "int64" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range INT64_VALUES { - if e := p.WriteI64(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolI64(t *testing.T) { - thetype := "int64" - for _, value := range INT64_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(strconv.FormatInt(value, 10)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI64() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolDouble(t *testing.T) { - thetype := "double" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, -1) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) - } - } else { - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolDouble(t *testing.T) { - thetype := "double" - for _, value := range DOUBLE_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - n := NewNumericFromDouble(value) - trans.WriteString(n.String()) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadDouble() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if math.IsInf(value, 1) { - if !math.IsInf(v, 1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsInf(value, -1) { - if !math.IsInf(v, -1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsNaN(value) { - if !math.IsNaN(v) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else { - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolString(t *testing.T) { - thetype := "string" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - for _, value := range STRING_VALUES { - if e := p.WriteString(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s[0] != '"' || s[len(s)-1] != '"' { - t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) - } - v := new(string) - if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadJSONProtocolString(t *testing.T) { - thetype := "string" - for _, value := range STRING_VALUES { - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(jsonQuote(value)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - if e := p.WriteBinary(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - expectedString := fmt.Sprint("\"", b64String, "\"") - if s != expectedString { - t.Fatalf("Bad value for %s %v\n wrote: \"%v\"\nexpected: \"%v\"", thetype, value, s, expectedString) - } - v1, err := p.ReadBinary() - if err != nil { - t.Fatalf("Unable to read binary: %s", err.Error()) - } - if len(v1) != len(value) { - t.Fatalf("Invalid value for binary\nexpected: \"%v\"\n read: \"%v\"", value, v1) - } - for k, v := range value { - if v1[k] != v { - t.Fatalf("Invalid value for binary at %v\nexpected: \"%v\"\n read: \"%v\"", k, v, v1[k]) - } - } - trans.Close() -} - -func TestReadJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - trans.WriteString(jsonQuote(b64String)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadBinary() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if len(v) != len(value) { - t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) - } - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) - } - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() -} - -func TestWriteJSONProtocolList(t *testing.T) { - thetype := "list" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteListEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("List must be at least of length two to include metadata") - } - if l[0] != "dbl" { - t.Fatal("Invalid type for list, expected: ", STRING, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteJSONProtocolSet(t *testing.T) { - thetype := "set" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteSetEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("Set must be at least of length two to include metadata") - } - if l[0] != "dbl" { - t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteJSONProtocolMap(t *testing.T) { - thetype := "map" - trans := NewTMemoryBuffer() - p := NewTJSONProtocol(trans) - p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) - for k, value := range DOUBLE_VALUES { - if e := p.WriteI32(int32(k)); e != nil { - t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) - } - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteMapEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - if str[0] != '[' || str[len(str)-1] != ']' { - t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES) - } - expectedKeyType, expectedValueType, expectedSize, err := p.ReadMapBegin() - if err != nil { - t.Fatalf("Error while reading map begin: %s", err.Error()) - } - if expectedKeyType != I32 { - t.Fatal("Expected map key type ", I32, ", but was ", expectedKeyType) - } - if expectedValueType != DOUBLE { - t.Fatal("Expected map value type ", DOUBLE, ", but was ", expectedValueType) - } - if expectedSize != len(DOUBLE_VALUES) { - t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", expectedSize) - } - for k, value := range DOUBLE_VALUES { - ik, err := p.ReadI32() - if err != nil { - t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, ik, string(k), err.Error()) - } - if int(ik) != k { - t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v", thetype, k, ik, k) - } - dv, err := p.ReadDouble() - if err != nil { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, dv, value, err.Error()) - } - s := strconv.FormatFloat(dv, 'g', 10, 64) - if math.IsInf(value, 1) { - if !math.IsInf(dv, 1) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, 0) { - if !math.IsInf(dv, 0) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if !math.IsNaN(dv) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) - } - } else { - expected := strconv.FormatFloat(value, 'g', 10, 64) - if s != expected { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - } - err = p.ReadMapEnd() - if err != nil { - t.Fatalf("Error while reading map end: %s", err.Error()) - } - trans.Close() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go deleted file mode 100644 index e173655..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go +++ /dev/null @@ -1,540 +0,0 @@ -/* - * 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" - "testing" -) - -var binaryProtoF = NewTBinaryProtocolFactoryDefault() -var compactProtoF = NewTCompactProtocolFactory() - -var buf = bytes.NewBuffer(make([]byte, 0, 1024)) - -var tfv = []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), -} - -func BenchmarkBinaryBool_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkBinaryBool_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkBinaryBool_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkBinaryByte_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkBinaryI16_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkBinaryI32_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkBinaryI64_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkBinaryDouble_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkBinaryString_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkBinaryBinary_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := binaryProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary0(b *testing.B) { - trans, err := tfv[0].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary1(b *testing.B) { - trans, err := tfv[1].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} - -func BenchmarkCompactBool_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBool(b, p, trans) - } -} - -func BenchmarkCompactByte_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteByte(b, p, trans) - } -} - -func BenchmarkCompactI16_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI16(b, p, trans) - } -} - -func BenchmarkCompactI32_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI32(b, p, trans) - } -} -func BenchmarkCompactI64_2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteI64(b, p, trans) - } -} -func BenchmarkCompactDouble2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteDouble(b, p, trans) - } -} -func BenchmarkCompactString2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteString(b, p, trans) - } -} -func BenchmarkCompactBinary2(b *testing.B) { - trans, err := tfv[2].GetTransport(nil) - if err != nil { - b.Fatal(err) - } - p := compactProtoF.GetProtocol(trans) - for i := 0; i < b.N; i++ { - ReadWriteBinary(b, p, trans) - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go deleted file mode 100644 index 5936d27..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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" - "context" -) - -// Memory buffer-based implementation of the TTransport interface. -type TMemoryBuffer struct { - *bytes.Buffer - size int -} - -type TMemoryBufferTransportFactory struct { - size int -} - -func (p *TMemoryBufferTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - if trans != nil { - t, ok := trans.(*TMemoryBuffer) - if ok && t.size > 0 { - return NewTMemoryBufferLen(t.size), nil - } - } - return NewTMemoryBufferLen(p.size), nil -} - -func NewTMemoryBufferTransportFactory(size int) *TMemoryBufferTransportFactory { - return &TMemoryBufferTransportFactory{size: size} -} - -func NewTMemoryBuffer() *TMemoryBuffer { - return &TMemoryBuffer{Buffer: &bytes.Buffer{}, size: 0} -} - -func NewTMemoryBufferLen(size int) *TMemoryBuffer { - buf := make([]byte, 0, size) - return &TMemoryBuffer{Buffer: bytes.NewBuffer(buf), size: size} -} - -func (p *TMemoryBuffer) IsOpen() bool { - return true -} - -func (p *TMemoryBuffer) Open() error { - return nil -} - -func (p *TMemoryBuffer) Close() error { - p.Buffer.Reset() - return nil -} - -// Flushing a memory buffer is a no-op -func (p *TMemoryBuffer) Flush(ctx context.Context) error { - return nil -} - -func (p *TMemoryBuffer) RemainingBytes() (num_bytes uint64) { - return uint64(p.Buffer.Len()) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go deleted file mode 100644 index af2e8bf..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestMemoryBuffer(t *testing.T) { - trans := NewTMemoryBufferLen(1024) - TransportTest(t, trans, trans) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go b/vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go deleted file mode 100644 index 25ab2e9..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - -// Message type constants in the Thrift protocol. -type TMessageType int32 - -const ( - INVALID_TMESSAGE_TYPE TMessageType = 0 - CALL TMessageType = 1 - REPLY TMessageType = 2 - EXCEPTION TMessageType = 3 - ONEWAY TMessageType = 4 -) diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go deleted file mode 100644 index d028a30..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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 ( - "context" - "fmt" - "strings" -) - -/* -TMultiplexedProtocol is a protocol-independent concrete decorator -that allows a Thrift client to communicate with a multiplexing Thrift server, -by prepending the service name to the function name during function calls. - -NOTE: THIS IS NOT USED BY SERVERS. On the server, use TMultiplexedProcessor to handle request -from a multiplexing client. - -This example uses a single socket transport to invoke two services: - -socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT) -transport := thrift.NewTFramedTransport(socket) -protocol := thrift.NewTBinaryProtocolTransport(transport) - -mp := thrift.NewTMultiplexedProtocol(protocol, "Calculator") -service := Calculator.NewCalculatorClient(mp) - -mp2 := thrift.NewTMultiplexedProtocol(protocol, "WeatherReport") -service2 := WeatherReport.NewWeatherReportClient(mp2) - -err := transport.Open() -if err != nil { - t.Fatal("Unable to open client socket", err) -} - -fmt.Println(service.Add(2,2)) -fmt.Println(service2.GetTemperature()) -*/ - -type TMultiplexedProtocol struct { - TProtocol - serviceName string -} - -const MULTIPLEXED_SEPARATOR = ":" - -func NewTMultiplexedProtocol(protocol TProtocol, serviceName string) *TMultiplexedProtocol { - return &TMultiplexedProtocol{ - TProtocol: protocol, - serviceName: serviceName, - } -} - -func (t *TMultiplexedProtocol) WriteMessageBegin(name string, typeId TMessageType, seqid int32) error { - if typeId == CALL || typeId == ONEWAY { - return t.TProtocol.WriteMessageBegin(t.serviceName+MULTIPLEXED_SEPARATOR+name, typeId, seqid) - } else { - return t.TProtocol.WriteMessageBegin(name, typeId, seqid) - } -} - -/* -TMultiplexedProcessor is a TProcessor allowing -a single TServer to provide multiple services. - -To do so, you instantiate the processor and then register additional -processors with it, as shown in the following example: - -var processor = thrift.NewTMultiplexedProcessor() - -firstProcessor := -processor.RegisterProcessor("FirstService", firstProcessor) - -processor.registerProcessor( - "Calculator", - Calculator.NewCalculatorProcessor(&CalculatorHandler{}), -) - -processor.registerProcessor( - "WeatherReport", - WeatherReport.NewWeatherReportProcessor(&WeatherReportHandler{}), -) - -serverTransport, err := thrift.NewTServerSocketTimeout(addr, TIMEOUT) -if err != nil { - t.Fatal("Unable to create server socket", err) -} -server := thrift.NewTSimpleServer2(processor, serverTransport) -server.Serve(); -*/ - -type TMultiplexedProcessor struct { - serviceProcessorMap map[string]TProcessor - DefaultProcessor TProcessor -} - -func NewTMultiplexedProcessor() *TMultiplexedProcessor { - return &TMultiplexedProcessor{ - serviceProcessorMap: make(map[string]TProcessor), - } -} - -func (t *TMultiplexedProcessor) RegisterDefault(processor TProcessor) { - t.DefaultProcessor = processor -} - -func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProcessor) { - if t.serviceProcessorMap == nil { - t.serviceProcessorMap = make(map[string]TProcessor) - } - t.serviceProcessorMap[name] = processor -} - -func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) { - name, typeId, seqid, err := in.ReadMessageBegin() - if err != nil { - return false, err - } - if typeId != CALL && typeId != ONEWAY { - return false, fmt.Errorf("Unexpected message type %v", typeId) - } - //extract the service name - v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2) - if len(v) != 2 { - if t.DefaultProcessor != nil { - smb := NewStoredMessageProtocol(in, name, typeId, seqid) - return t.DefaultProcessor.Process(ctx, smb, out) - } - return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name) - } - actualProcessor, ok := t.serviceProcessorMap[v[0]] - if !ok { - return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0]) - } - smb := NewStoredMessageProtocol(in, v[1], typeId, seqid) - return actualProcessor.Process(ctx, smb, out) -} - -//Protocol that use stored message for ReadMessageBegin -type storedMessageProtocol struct { - TProtocol - name string - typeId TMessageType - seqid int32 -} - -func NewStoredMessageProtocol(protocol TProtocol, name string, typeId TMessageType, seqid int32) *storedMessageProtocol { - return &storedMessageProtocol{protocol, name, typeId, seqid} -} - -func (s *storedMessageProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqid int32, err error) { - return s.name, s.typeId, s.seqid, nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/numeric.go b/vendor/github.com/apache/thrift/lib/go/thrift/numeric.go deleted file mode 100644 index aa8daa9..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/numeric.go +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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 ( - "math" - "strconv" -) - -type Numeric interface { - Int64() int64 - Int32() int32 - Int16() int16 - Byte() byte - Int() int - Float64() float64 - Float32() float32 - String() string - isNull() bool -} - -type numeric struct { - iValue int64 - dValue float64 - sValue string - isNil bool -} - -var ( - INFINITY Numeric - NEGATIVE_INFINITY Numeric - NAN Numeric - ZERO Numeric - NUMERIC_NULL Numeric -) - -func NewNumericFromDouble(dValue float64) Numeric { - if math.IsInf(dValue, 1) { - return INFINITY - } - if math.IsInf(dValue, -1) { - return NEGATIVE_INFINITY - } - if math.IsNaN(dValue) { - return NAN - } - iValue := int64(dValue) - sValue := strconv.FormatFloat(dValue, 'g', 10, 64) - isNil := false - return &numeric{iValue: iValue, dValue: dValue, sValue: sValue, isNil: isNil} -} - -func NewNumericFromI64(iValue int64) Numeric { - dValue := float64(iValue) - sValue := string(iValue) - isNil := false - return &numeric{iValue: iValue, dValue: dValue, sValue: sValue, isNil: isNil} -} - -func NewNumericFromI32(iValue int32) Numeric { - dValue := float64(iValue) - sValue := string(iValue) - isNil := false - return &numeric{iValue: int64(iValue), dValue: dValue, sValue: sValue, isNil: isNil} -} - -func NewNumericFromString(sValue string) Numeric { - if sValue == INFINITY.String() { - return INFINITY - } - if sValue == NEGATIVE_INFINITY.String() { - return NEGATIVE_INFINITY - } - if sValue == NAN.String() { - return NAN - } - iValue, _ := strconv.ParseInt(sValue, 10, 64) - dValue, _ := strconv.ParseFloat(sValue, 64) - isNil := len(sValue) == 0 - return &numeric{iValue: iValue, dValue: dValue, sValue: sValue, isNil: isNil} -} - -func NewNumericFromJSONString(sValue string, isNull bool) Numeric { - if isNull { - return NewNullNumeric() - } - if sValue == JSON_INFINITY { - return INFINITY - } - if sValue == JSON_NEGATIVE_INFINITY { - return NEGATIVE_INFINITY - } - if sValue == JSON_NAN { - return NAN - } - iValue, _ := strconv.ParseInt(sValue, 10, 64) - dValue, _ := strconv.ParseFloat(sValue, 64) - return &numeric{iValue: iValue, dValue: dValue, sValue: sValue, isNil: isNull} -} - -func NewNullNumeric() Numeric { - return &numeric{iValue: 0, dValue: 0.0, sValue: "", isNil: true} -} - -func (p *numeric) Int64() int64 { - return p.iValue -} - -func (p *numeric) Int32() int32 { - return int32(p.iValue) -} - -func (p *numeric) Int16() int16 { - return int16(p.iValue) -} - -func (p *numeric) Byte() byte { - return byte(p.iValue) -} - -func (p *numeric) Int() int { - return int(p.iValue) -} - -func (p *numeric) Float64() float64 { - return p.dValue -} - -func (p *numeric) Float32() float32 { - return float32(p.dValue) -} - -func (p *numeric) String() string { - return p.sValue -} - -func (p *numeric) isNull() bool { - return p.isNil -} - -func init() { - INFINITY = &numeric{iValue: 0, dValue: math.Inf(1), sValue: "Infinity", isNil: false} - NEGATIVE_INFINITY = &numeric{iValue: 0, dValue: math.Inf(-1), sValue: "-Infinity", isNil: false} - NAN = &numeric{iValue: 0, dValue: math.NaN(), sValue: "NaN", isNil: false} - ZERO = &numeric{iValue: 0, dValue: 0, sValue: "0", isNil: false} - NUMERIC_NULL = &numeric{iValue: 0, dValue: 0, sValue: "0", isNil: true} -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go b/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go deleted file mode 100644 index 8d6b2c2..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 - -/////////////////////////////////////////////////////////////////////////////// -// This file is home to helpers that convert from various base types to -// respective pointer types. This is necessary because Go does not permit -// references to constants, nor can a pointer type to base type be allocated -// and initialized in a single expression. -// -// E.g., this is not allowed: -// -// var ip *int = &5 -// -// But this *is* allowed: -// -// func IntPtr(i int) *int { return &i } -// var ip *int = IntPtr(5) -// -// Since pointers to base types are commonplace as [optional] fields in -// exported thrift structs, we factor such helpers here. -/////////////////////////////////////////////////////////////////////////////// - -func Float32Ptr(v float32) *float32 { return &v } -func Float64Ptr(v float64) *float64 { return &v } -func IntPtr(v int) *int { return &v } -func Int32Ptr(v int32) *int32 { return &v } -func Int64Ptr(v int64) *int64 { return &v } -func StringPtr(v string) *string { return &v } -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 } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go deleted file mode 100644 index e4b132b..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 "context" - -// A processor is a generic object which operates upon an input stream and -// writes to some output stream. -type TProcessor interface { - Process(ctx context.Context, in, out TProtocol) (bool, TException) -} - -type TProcessorFunction interface { - Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException) -} - -// The default processor factory just returns a singleton -// instance. -type TProcessorFactory interface { - GetProcessor(trans TTransport) TProcessor -} - -type tProcessorFactory struct { - processor TProcessor -} - -func NewTProcessorFactory(p TProcessor) TProcessorFactory { - return &tProcessorFactory{processor: p} -} - -func (p *tProcessorFactory) GetProcessor(trans TTransport) TProcessor { - return p.processor -} - -/** - * The default processor factory just returns a singleton - * instance. - */ -type TProcessorFunctionFactory interface { - GetProcessorFunction(trans TTransport) TProcessorFunction -} - -type tProcessorFunctionFactory struct { - processor TProcessorFunction -} - -func NewTProcessorFunctionFactory(p TProcessorFunction) TProcessorFunctionFactory { - return &tProcessorFunctionFactory{processor: p} -} - -func (p *tProcessorFunctionFactory) GetProcessorFunction(trans TTransport) TProcessorFunction { - return p.processor -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go deleted file mode 100644 index 615b7a4..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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 ( - "context" - "errors" - "fmt" -) - -const ( - VERSION_MASK = 0xffff0000 - VERSION_1 = 0x80010000 -) - -type TProtocol interface { - WriteMessageBegin(name string, typeId TMessageType, seqid int32) error - WriteMessageEnd() error - WriteStructBegin(name string) error - WriteStructEnd() error - WriteFieldBegin(name string, typeId TType, id int16) error - WriteFieldEnd() error - WriteFieldStop() error - WriteMapBegin(keyType TType, valueType TType, size int) error - WriteMapEnd() error - WriteListBegin(elemType TType, size int) error - WriteListEnd() error - WriteSetBegin(elemType TType, size int) error - WriteSetEnd() error - WriteBool(value bool) error - WriteByte(value int8) error - WriteI16(value int16) error - WriteI32(value int32) error - WriteI64(value int64) error - WriteDouble(value float64) error - WriteString(value string) error - WriteBinary(value []byte) error - - ReadMessageBegin() (name string, typeId TMessageType, seqid int32, err error) - ReadMessageEnd() error - ReadStructBegin() (name string, err error) - ReadStructEnd() error - ReadFieldBegin() (name string, typeId TType, id int16, err error) - ReadFieldEnd() error - ReadMapBegin() (keyType TType, valueType TType, size int, err error) - ReadMapEnd() error - ReadListBegin() (elemType TType, size int, err error) - ReadListEnd() error - ReadSetBegin() (elemType TType, size int, err error) - ReadSetEnd() error - ReadBool() (value bool, err error) - ReadByte() (value int8, err error) - ReadI16() (value int16, err error) - ReadI32() (value int32, err error) - ReadI64() (value int64, err error) - ReadDouble() (value float64, err error) - ReadString() (value string, err error) - ReadBinary() (value []byte, err error) - - Skip(fieldType TType) (err error) - Flush(ctx context.Context) (err error) - - Transport() TTransport -} - -// The maximum recursive depth the skip() function will traverse -const DEFAULT_RECURSION_DEPTH = 64 - -// Skips over the next data element from the provided input TProtocol object. -func SkipDefaultDepth(prot TProtocol, typeId TType) (err error) { - return Skip(prot, typeId, DEFAULT_RECURSION_DEPTH) -} - -// Skips over the next data element from the provided input TProtocol object. -func Skip(self TProtocol, fieldType TType, maxDepth int) (err error) { - - if maxDepth <= 0 { - return NewTProtocolExceptionWithType(DEPTH_LIMIT, errors.New("Depth limit exceeded")) - } - - switch fieldType { - case STOP: - return - case BOOL: - _, err = self.ReadBool() - return - case BYTE: - _, err = self.ReadByte() - return - case I16: - _, err = self.ReadI16() - return - case I32: - _, err = self.ReadI32() - return - case I64: - _, err = self.ReadI64() - return - case DOUBLE: - _, err = self.ReadDouble() - return - case STRING: - _, err = self.ReadString() - return - case STRUCT: - if _, err = self.ReadStructBegin(); err != nil { - return err - } - for { - _, typeId, _, _ := self.ReadFieldBegin() - if typeId == STOP { - break - } - err := Skip(self, typeId, maxDepth-1) - if err != nil { - return err - } - self.ReadFieldEnd() - } - return self.ReadStructEnd() - case MAP: - keyType, valueType, size, err := self.ReadMapBegin() - if err != nil { - return err - } - for i := 0; i < size; i++ { - err := Skip(self, keyType, maxDepth-1) - if err != nil { - return err - } - self.Skip(valueType) - } - return self.ReadMapEnd() - case SET: - elemType, size, err := self.ReadSetBegin() - if err != nil { - return err - } - for i := 0; i < size; i++ { - err := Skip(self, elemType, maxDepth-1) - if err != nil { - return err - } - } - return self.ReadSetEnd() - case LIST: - elemType, size, err := self.ReadListBegin() - if err != nil { - return err - } - for i := 0; i < size; i++ { - err := Skip(self, elemType, maxDepth-1) - if err != nil { - return err - } - } - return self.ReadListEnd() - default: - return NewTProtocolExceptionWithType(INVALID_DATA, errors.New(fmt.Sprintf("Unknown data type %d", fieldType))) - } - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go deleted file mode 100644 index 29ab75d..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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/base64" -) - -// Thrift Protocol exception -type TProtocolException interface { - TException - TypeId() int -} - -const ( - UNKNOWN_PROTOCOL_EXCEPTION = 0 - INVALID_DATA = 1 - NEGATIVE_SIZE = 2 - SIZE_LIMIT = 3 - BAD_VERSION = 4 - NOT_IMPLEMENTED = 5 - DEPTH_LIMIT = 6 -) - -type tProtocolException struct { - typeId int - message string -} - -func (p *tProtocolException) TypeId() int { - return p.typeId -} - -func (p *tProtocolException) String() string { - return p.message -} - -func (p *tProtocolException) Error() string { - return p.message -} - -func NewTProtocolException(err error) TProtocolException { - if err == nil { - return nil - } - if e, ok := err.(TProtocolException); ok { - return e - } - if _, ok := err.(base64.CorruptInputError); ok { - return &tProtocolException{INVALID_DATA, err.Error()} - } - return &tProtocolException{UNKNOWN_PROTOCOL_EXCEPTION, err.Error()} -} - -func NewTProtocolExceptionWithType(errType int, err error) TProtocolException { - if err == nil { - return nil - } - return &tProtocolException{errType, err.Error()} -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go deleted file mode 100644 index c40f796..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 - -// Factory interface for constructing protocol instances. -type TProtocolFactory interface { - GetProtocol(trans TTransport) TProtocol -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go deleted file mode 100644 index 944055c..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go +++ /dev/null @@ -1,517 +0,0 @@ -/* - * 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" - "context" - "io/ioutil" - "math" - "net" - "net/http" - "testing" -) - -const PROTOCOL_BINARY_DATA_SIZE = 155 - -var ( - protocol_bdata []byte // test data for writing; same as data - BOOL_VALUES []bool - BYTE_VALUES []int8 - INT16_VALUES []int16 - INT32_VALUES []int32 - INT64_VALUES []int64 - DOUBLE_VALUES []float64 - STRING_VALUES []string -) - -func init() { - protocol_bdata = make([]byte, PROTOCOL_BINARY_DATA_SIZE) - for i := 0; i < PROTOCOL_BINARY_DATA_SIZE; i++ { - protocol_bdata[i] = byte((i + 'a') % 255) - } - BOOL_VALUES = []bool{false, true, false, false, true} - BYTE_VALUES = []int8{117, 0, 1, 32, 127, -128, -1} - INT16_VALUES = []int16{459, 0, 1, -1, -128, 127, 32767, -32768} - INT32_VALUES = []int32{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535} - 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"} -} - -type HTTPEchoServer struct{} -type HTTPHeaderEchoServer struct{} - -func (p *HTTPEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - w.Write(buf) - } else { - w.WriteHeader(http.StatusOK) - w.Write(buf) - } -} - -func (p *HTTPHeaderEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - w.Write(buf) - } else { - w.WriteHeader(http.StatusOK) - w.Write(buf) - } -} - -func HttpClientSetupForTest(t *testing.T) (net.Listener, net.Addr) { - addr, err := FindAvailableTCPServerPort(40000) - if err != nil { - t.Fatalf("Unable to find available tcp port addr: %s", err) - return nil, addr - } - l, err := net.Listen(addr.Network(), addr.String()) - if err != nil { - t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) - return l, addr - } - go http.Serve(l, &HTTPEchoServer{}) - return l, addr -} - -func HttpClientSetupForHeaderTest(t *testing.T) (net.Listener, net.Addr) { - addr, err := FindAvailableTCPServerPort(40000) - if err != nil { - t.Fatalf("Unable to find available tcp port addr: %s", err) - return nil, addr - } - l, err := net.Listen(addr.Network(), addr.String()) - if err != nil { - t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) - return l, addr - } - go http.Serve(l, &HTTPHeaderEchoServer{}) - return l, addr -} - -func ReadWriteProtocolTest(t *testing.T, protocolFactory TProtocolFactory) { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - l, addr := HttpClientSetupForTest(t) - defer l.Close() - transports := []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), - NewTZlibTransportFactoryWithFactory(0, NewTMemoryBufferTransportFactory(1024)), - NewTZlibTransportFactoryWithFactory(6, NewTMemoryBufferTransportFactory(1024)), - NewTZlibTransportFactoryWithFactory(9, NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024))), - NewTHttpPostClientTransportFactory("http://" + addr.String()), - } - for _, tf := range transports { - trans, err := tf.GetTransport(nil) - if err != nil { - t.Error(err) - continue - } - p := protocolFactory.GetProtocol(trans) - ReadWriteBool(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) - ReadWriteByte(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) - ReadWriteI16(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) - ReadWriteI32(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) - trans.Close() - } - for _, tf := range transports { - trans, err := tf.GetTransport(nil) - if err != nil { - t.Error(err) - continue - } - p := protocolFactory.GetProtocol(trans) - ReadWriteDouble(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) - ReadWriteString(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) - ReadWriteBinary(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) - trans.Close() - } -} - -func ReadWriteBool(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(BOOL) - thelen := len(BOOL_VALUES) - err := p.WriteListBegin(thetype, thelen) - if err != nil { - t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteBool", p, trans, err, thetype) - } - for k, v := range BOOL_VALUES { - err = p.WriteBool(v) - if err != nil { - t.Errorf("%s: %T %T %v Error writing bool in list at index %v: %v", "ReadWriteBool", p, trans, err, k, v) - } - } - p.WriteListEnd() - if err != nil { - t.Errorf("%s: %T %T %v Error writing list end: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES) - } - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteBool", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteBool", p, trans, thelen, thelen2) - } - } - for k, v := range BOOL_VALUES { - value, err := p.ReadBool() - if err != nil { - t.Errorf("%s: %T %T %v Error reading bool at index %v: %v", "ReadWriteBool", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: index %v %v %v %v != %v", "ReadWriteBool", k, p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteBool", p, trans, err) - } -} - -func ReadWriteByte(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(BYTE) - thelen := len(BYTE_VALUES) - err := p.WriteListBegin(thetype, thelen) - if err != nil { - t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteByte", p, trans, err, thetype) - } - for k, v := range BYTE_VALUES { - err = p.WriteByte(v) - if err != nil { - t.Errorf("%s: %T %T %q Error writing byte in list at index %d: %q", "ReadWriteByte", p, trans, err, k, v) - } - } - err = p.WriteListEnd() - if err != nil { - t.Errorf("%s: %T %T %q Error writing list end: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - err = p.Flush(context.Background()) - if err != nil { - t.Errorf("%s: %T %T %q Error flushing list of bytes: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteByte", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteByte", p, trans, thelen, thelen2) - } - } - for k, v := range BYTE_VALUES { - value, err := p.ReadByte() - if err != nil { - t.Errorf("%s: %T %T %q Error reading byte at index %d: %q", "ReadWriteByte", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteByte", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteByte", p, trans, err) - } -} - -func ReadWriteI16(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I16) - thelen := len(INT16_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT16_VALUES { - p.WriteI16(v) - } - p.WriteListEnd() - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI16", p, trans, err, INT16_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI16", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI16", p, trans, thelen, thelen2) - } - } - for k, v := range INT16_VALUES { - value, err := p.ReadI16() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int16 at index %d: %q", "ReadWriteI16", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteI16", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI16", p, trans, err) - } -} - -func ReadWriteI32(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I32) - thelen := len(INT32_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT32_VALUES { - p.WriteI32(v) - } - p.WriteListEnd() - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI32", p, trans, err, INT32_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI32", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI32", p, trans, thelen, thelen2) - } - } - for k, v := range INT32_VALUES { - value, err := p.ReadI32() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int32 at index %d: %q", "ReadWriteI32", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %d != %d", "ReadWriteI32", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI32", p, trans, err) - } -} - -func ReadWriteI64(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(I64) - thelen := len(INT64_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range INT64_VALUES { - p.WriteI64(v) - } - p.WriteListEnd() - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI64", p, trans, err, INT64_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI64", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI64", p, trans, thelen, thelen2) - } - } - for k, v := range INT64_VALUES { - value, err := p.ReadI64() - if err != nil { - t.Errorf("%s: %T %T %q Error reading int64 at index %d: %q", "ReadWriteI64", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %q != %q", "ReadWriteI64", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI64", p, trans, err) - } -} - -func ReadWriteDouble(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(DOUBLE) - thelen := len(DOUBLE_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range DOUBLE_VALUES { - p.WriteDouble(v) - } - p.WriteListEnd() - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteDouble", p, trans, err, DOUBLE_VALUES) - } - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteDouble", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteDouble", p, trans, thelen, thelen2) - } - for k, v := range DOUBLE_VALUES { - value, err := p.ReadDouble() - if err != nil { - t.Errorf("%s: %T %T %q Error reading double at index %d: %v", "ReadWriteDouble", p, trans, err, k, v) - } - if math.IsNaN(v) { - if !math.IsNaN(value) { - t.Errorf("%s: %T %T math.IsNaN(%v) != math.IsNaN(%v)", "ReadWriteDouble", p, trans, v, value) - } - } else if v != value { - t.Errorf("%s: %T %T %v != %v", "ReadWriteDouble", p, trans, v, value) - } - } - err = p.ReadListEnd() - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteDouble", p, trans, err) - } -} - -func ReadWriteString(t testing.TB, p TProtocol, trans TTransport) { - thetype := TType(STRING) - thelen := len(STRING_VALUES) - p.WriteListBegin(thetype, thelen) - for _, v := range STRING_VALUES { - p.WriteString(v) - } - p.WriteListEnd() - p.Flush(context.Background()) - thetype2, thelen2, err := p.ReadListBegin() - if err != nil { - t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteString", p, trans, err, STRING_VALUES) - } - _, ok := p.(*TSimpleJSONProtocol) - if !ok { - if thetype != thetype2 { - t.Errorf("%s: %T %T type %s != type %s", "ReadWriteString", p, trans, thetype, thetype2) - } - if thelen != thelen2 { - t.Errorf("%s: %T %T len %v != len %v", "ReadWriteString", p, trans, thelen, thelen2) - } - } - for k, v := range STRING_VALUES { - value, err := p.ReadString() - if err != nil { - t.Errorf("%s: %T %T %q Error reading string at index %d: %q", "ReadWriteString", p, trans, err, k, v) - } - if v != value { - t.Errorf("%s: %T %T %v != %v", "ReadWriteString", p, trans, v, value) - } - } - if err != nil { - t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteString", p, trans, err) - } -} - -func ReadWriteBinary(t testing.TB, p TProtocol, trans TTransport) { - v := protocol_bdata - p.WriteBinary(v) - p.Flush(context.Background()) - value, err := p.ReadBinary() - if err != nil { - t.Errorf("%s: %T %T Unable to read binary: %s", "ReadWriteBinary", p, trans, err.Error()) - } - if len(v) != len(value) { - t.Errorf("%s: %T %T len(v) != len(value)... %d != %d", "ReadWriteBinary", p, trans, len(v), len(value)) - } else { - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Errorf("%s: %T %T %s != %s", "ReadWriteBinary", p, trans, v, value) - } - } - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go deleted file mode 100644 index 4025beb..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 "io" - -type RichTransport struct { - TTransport -} - -// Wraps Transport to provide TRichTransport interface -func NewTRichTransport(trans TTransport) *RichTransport { - return &RichTransport{trans} -} - -func (r *RichTransport) ReadByte() (c byte, err error) { - return readByte(r.TTransport) -} - -func (r *RichTransport) WriteByte(c byte) error { - return writeByte(r.TTransport, c) -} - -func (r *RichTransport) WriteString(s string) (n int, err error) { - return r.Write([]byte(s)) -} - -func (r *RichTransport) RemainingBytes() (num_bytes uint64) { - return r.TTransport.RemainingBytes() -} - -func readByte(r io.Reader) (c byte, err error) { - v := [1]byte{0} - n, err := r.Read(v[0:1]) - if n > 0 && (err == nil || err == io.EOF) { - return v[0], nil - } - if n > 0 && err != nil { - return v[0], err - } - if err != nil { - return 0, err - } - return v[0], nil -} - -func writeByte(w io.Writer, c byte) error { - v := [1]byte{c} - _, err := w.Write(v[0:1]) - return err -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go deleted file mode 100644 index 25c3fd5..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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" - "errors" - "io" - "reflect" - "testing" -) - -func TestEnsureTransportsAreRich(t *testing.T) { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - - transports := []TTransportFactory{ - NewTMemoryBufferTransportFactory(1024), - NewStreamTransportFactory(buf, buf, true), - NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), - NewTHttpPostClientTransportFactory("http://127.0.0.1"), - } - for _, tf := range transports { - trans, err := tf.GetTransport(nil) - if err != nil { - t.Error(err) - continue - } - _, ok := trans.(TRichTransport) - if !ok { - t.Errorf("Transport %s does not implement TRichTransport interface", reflect.ValueOf(trans)) - } - } -} - -// TestReadByte tests whether readByte handles error cases correctly. -func TestReadByte(t *testing.T) { - for i, test := range readByteTests { - v, err := readByte(test.r) - if v != test.v { - t.Fatalf("TestReadByte %d: value differs. Expected %d, got %d", i, test.v, test.r.v) - } - if err != test.err { - t.Fatalf("TestReadByte %d: error differs. Expected %s, got %s", i, test.err, test.r.err) - } - } -} - -var someError = errors.New("Some error") -var readByteTests = []struct { - r *mockReader - v byte - err error -}{ - {&mockReader{0, 55, io.EOF}, 0, io.EOF}, // reader sends EOF w/o data - {&mockReader{0, 55, someError}, 0, someError}, // reader sends some other error - {&mockReader{1, 55, nil}, 55, nil}, // reader sends data w/o error - {&mockReader{1, 55, io.EOF}, 55, nil}, // reader sends data with EOF - {&mockReader{1, 55, someError}, 55, someError}, // reader sends data withsome error -} - -type mockReader struct { - n int - v byte - err error -} - -func (r *mockReader) Read(p []byte) (n int, err error) { - if r.n > 0 { - p[0] = r.v - } - return r.n, r.err -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go deleted file mode 100644 index 1ff4d37..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 ( - "context" -) - -type TSerializer struct { - Transport *TMemoryBuffer - Protocol TProtocol -} - -type TStruct interface { - Write(p TProtocol) error - Read(p TProtocol) error -} - -func NewTSerializer() *TSerializer { - transport := NewTMemoryBufferLen(1024) - protocol := NewTBinaryProtocolFactoryDefault().GetProtocol(transport) - - return &TSerializer{ - transport, - protocol} -} - -func (t *TSerializer) WriteString(ctx context.Context, msg TStruct) (s string, err error) { - t.Transport.Reset() - - if err = msg.Write(t.Protocol); err != nil { - return - } - - if err = t.Protocol.Flush(ctx); err != nil { - return - } - if err = t.Transport.Flush(ctx); err != nil { - return - } - - return t.Transport.String(), nil -} - -func (t *TSerializer) Write(ctx context.Context, msg TStruct) (b []byte, err error) { - t.Transport.Reset() - - if err = msg.Write(t.Protocol); err != nil { - return - } - - if err = t.Protocol.Flush(ctx); err != nil { - return - } - - if err = t.Transport.Flush(ctx); err != nil { - return - } - - b = append(b, t.Transport.Bytes()...) - return -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go deleted file mode 100644 index 32227ef..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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 ( - "context" - "errors" - "fmt" - "testing" -) - -type ProtocolFactory interface { - GetProtocol(t TTransport) TProtocol -} - -func compareStructs(m, m1 MyTestStruct) (bool, error) { - switch { - case m.On != m1.On: - return false, errors.New("Boolean not equal") - case m.B != m1.B: - return false, errors.New("Byte not equal") - case m.Int16 != m1.Int16: - return false, errors.New("Int16 not equal") - case m.Int32 != m1.Int32: - return false, errors.New("Int32 not equal") - case m.Int64 != m1.Int64: - return false, errors.New("Int64 not equal") - case m.D != m1.D: - return false, errors.New("Double not equal") - case m.St != m1.St: - return false, errors.New("String not equal") - - case len(m.Bin) != len(m1.Bin): - return false, errors.New("Binary size not equal") - case len(m.Bin) == len(m1.Bin): - for i := range m.Bin { - if m.Bin[i] != m1.Bin[i] { - return false, errors.New("Binary not equal") - } - } - case len(m.StringMap) != len(m1.StringMap): - return false, errors.New("StringMap size not equal") - case len(m.StringList) != len(m1.StringList): - return false, errors.New("StringList size not equal") - case len(m.StringSet) != len(m1.StringSet): - return false, errors.New("StringSet size not equal") - - case m.E != m1.E: - return false, errors.New("MyTestEnum not equal") - - default: - return true, nil - - } - return true, nil -} - -func ProtocolTest1(test *testing.T, pf ProtocolFactory) (bool, error) { - t := NewTSerializer() - t.Protocol = pf.GetProtocol(t.Transport) - var m = MyTestStruct{} - m.On = true - m.B = int8(0) - m.Int16 = 1 - m.Int32 = 2 - m.Int64 = 3 - m.D = 4.1 - m.St = "Test" - m.Bin = make([]byte, 10) - m.StringMap = make(map[string]string, 5) - m.StringList = make([]string, 5) - m.StringSet = make(map[string]struct{}, 5) - m.E = 2 - - s, err := t.WriteString(context.Background(), &m) - if err != nil { - return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) - } - - t1 := NewTDeserializer() - t1.Protocol = pf.GetProtocol(t1.Transport) - var m1 = MyTestStruct{} - if err = t1.ReadString(&m1, s); err != nil { - return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) - - } - - return compareStructs(m, m1) - -} - -func ProtocolTest2(test *testing.T, pf ProtocolFactory) (bool, error) { - t := NewTSerializer() - t.Protocol = pf.GetProtocol(t.Transport) - var m = MyTestStruct{} - m.On = false - m.B = int8(0) - m.Int16 = 1 - m.Int32 = 2 - m.Int64 = 3 - m.D = 4.1 - m.St = "Test" - m.Bin = make([]byte, 10) - m.StringMap = make(map[string]string, 5) - m.StringList = make([]string, 5) - m.StringSet = make(map[string]struct{}, 5) - m.E = 2 - - s, err := t.WriteString(context.Background(), &m) - if err != nil { - return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) - - } - - t1 := NewTDeserializer() - t1.Protocol = pf.GetProtocol(t1.Transport) - var m1 = MyTestStruct{} - if err = t1.ReadString(&m1, s); err != nil { - return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) - - } - - return compareStructs(m, m1) - -} - -func TestSerializer(t *testing.T) { - - var protocol_factories map[string]ProtocolFactory - protocol_factories = make(map[string]ProtocolFactory) - protocol_factories["Binary"] = NewTBinaryProtocolFactoryDefault() - protocol_factories["Compact"] = NewTCompactProtocolFactory() - //protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design - protocol_factories["JSON"] = NewTJSONProtocolFactory() - - var tests map[string]func(*testing.T, ProtocolFactory) (bool, error) - tests = make(map[string]func(*testing.T, ProtocolFactory) (bool, error)) - tests["Test 1"] = ProtocolTest1 - tests["Test 2"] = ProtocolTest2 - //tests["Test 3"] = ProtocolTest3 // Example of how to add additional tests - - for name, pf := range protocol_factories { - - for test, f := range tests { - - if s, err := f(t, pf); !s || err != nil { - t.Errorf("%s Failed for %s protocol\n\t %s", test, name, err) - } - - } - } - -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go deleted file mode 100644 index ef7cc3a..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go +++ /dev/null @@ -1,633 +0,0 @@ -/* - * 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 - -// Autogenerated by Thrift Compiler (0.12.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -/* THE FOLLOWING THRIFT FILE WAS USED TO CREATE THIS - -enum MyTestEnum { - FIRST = 1, - SECOND = 2, - THIRD = 3, - FOURTH = 4, -} - -struct MyTestStruct { - 1: bool on, - 2: byte b, - 3: i16 int16, - 4: i32 int32, - 5: i64 int64, - 6: double d, - 7: string st, - 8: binary bin, - 9: map stringMap, - 10: list stringList, - 11: set stringSet, - 12: MyTestEnum e, -} -*/ - -import ( - "fmt" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = ZERO -var _ = fmt.Printf - -var GoUnusedProtection__ int - -type MyTestEnum int64 - -const ( - MyTestEnum_FIRST MyTestEnum = 1 - MyTestEnum_SECOND MyTestEnum = 2 - MyTestEnum_THIRD MyTestEnum = 3 - MyTestEnum_FOURTH MyTestEnum = 4 -) - -func (p MyTestEnum) String() string { - switch p { - case MyTestEnum_FIRST: - return "FIRST" - case MyTestEnum_SECOND: - return "SECOND" - case MyTestEnum_THIRD: - return "THIRD" - case MyTestEnum_FOURTH: - return "FOURTH" - } - return "" -} - -func MyTestEnumFromString(s string) (MyTestEnum, error) { - switch s { - case "FIRST": - return MyTestEnum_FIRST, nil - case "SECOND": - return MyTestEnum_SECOND, nil - case "THIRD": - return MyTestEnum_THIRD, nil - case "FOURTH": - return MyTestEnum_FOURTH, nil - } - return MyTestEnum(0), fmt.Errorf("not a valid MyTestEnum string") -} - -func MyTestEnumPtr(v MyTestEnum) *MyTestEnum { return &v } - -type MyTestStruct struct { - On bool `thrift:"on,1" json:"on"` - B int8 `thrift:"b,2" json:"b"` - Int16 int16 `thrift:"int16,3" json:"int16"` - Int32 int32 `thrift:"int32,4" json:"int32"` - Int64 int64 `thrift:"int64,5" json:"int64"` - D float64 `thrift:"d,6" json:"d"` - St string `thrift:"st,7" json:"st"` - Bin []byte `thrift:"bin,8" json:"bin"` - StringMap map[string]string `thrift:"stringMap,9" json:"stringMap"` - StringList []string `thrift:"stringList,10" json:"stringList"` - StringSet map[string]struct{} `thrift:"stringSet,11" json:"stringSet"` - E MyTestEnum `thrift:"e,12" json:"e"` -} - -func NewMyTestStruct() *MyTestStruct { - return &MyTestStruct{} -} - -func (p *MyTestStruct) GetOn() bool { - return p.On -} - -func (p *MyTestStruct) GetB() int8 { - return p.B -} - -func (p *MyTestStruct) GetInt16() int16 { - return p.Int16 -} - -func (p *MyTestStruct) GetInt32() int32 { - return p.Int32 -} - -func (p *MyTestStruct) GetInt64() int64 { - return p.Int64 -} - -func (p *MyTestStruct) GetD() float64 { - return p.D -} - -func (p *MyTestStruct) GetSt() string { - return p.St -} - -func (p *MyTestStruct) GetBin() []byte { - return p.Bin -} - -func (p *MyTestStruct) GetStringMap() map[string]string { - return p.StringMap -} - -func (p *MyTestStruct) GetStringList() []string { - return p.StringList -} - -func (p *MyTestStruct) GetStringSet() map[string]struct{} { - return p.StringSet -} - -func (p *MyTestStruct) GetE() MyTestEnum { - return p.E -} -func (p *MyTestStruct) Read(iprot TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return PrependError(fmt.Sprintf("%T read error: ", p), err) - } - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 10: - if err := p.readField10(iprot); err != nil { - return err - } - case 11: - if err := p.readField11(iprot); err != nil { - return err - } - case 12: - if err := p.readField12(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MyTestStruct) readField1(iprot TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return PrependError("error reading field 1: ", err) - } else { - p.On = v - } - return nil -} - -func (p *MyTestStruct) readField2(iprot TProtocol) error { - if v, err := iprot.ReadByte(); err != nil { - return PrependError("error reading field 2: ", err) - } else { - temp := int8(v) - p.B = temp - } - return nil -} - -func (p *MyTestStruct) readField3(iprot TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return PrependError("error reading field 3: ", err) - } else { - p.Int16 = v - } - return nil -} - -func (p *MyTestStruct) readField4(iprot TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return PrependError("error reading field 4: ", err) - } else { - p.Int32 = v - } - return nil -} - -func (p *MyTestStruct) readField5(iprot TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return PrependError("error reading field 5: ", err) - } else { - p.Int64 = v - } - return nil -} - -func (p *MyTestStruct) readField6(iprot TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return PrependError("error reading field 6: ", err) - } else { - p.D = v - } - return nil -} - -func (p *MyTestStruct) readField7(iprot TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 7: ", err) - } else { - p.St = v - } - return nil -} - -func (p *MyTestStruct) readField8(iprot TProtocol) error { - if v, err := iprot.ReadBinary(); err != nil { - return PrependError("error reading field 8: ", err) - } else { - p.Bin = v - } - return nil -} - -func (p *MyTestStruct) readField9(iprot TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.StringMap = tMap - for i := 0; i < size; i++ { - var _key0 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _key0 = v - } - var _val1 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _val1 = v - } - p.StringMap[_key0] = _val1 - } - if err := iprot.ReadMapEnd(); err != nil { - return PrependError("error reading map end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField10(iprot TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.StringList = tSlice - for i := 0; i < size; i++ { - var _elem2 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _elem2 = v - } - p.StringList = append(p.StringList, _elem2) - } - if err := iprot.ReadListEnd(); err != nil { - return PrependError("error reading list end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField11(iprot TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return PrependError("error reading set begin: ", err) - } - tSet := make(map[string]struct{}, size) - p.StringSet = tSet - for i := 0; i < size; i++ { - var _elem3 string - if v, err := iprot.ReadString(); err != nil { - return PrependError("error reading field 0: ", err) - } else { - _elem3 = v - } - p.StringSet[_elem3] = struct{}{} - } - if err := iprot.ReadSetEnd(); err != nil { - return PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MyTestStruct) readField12(iprot TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return PrependError("error reading field 12: ", err) - } else { - temp := MyTestEnum(v) - p.E = temp - } - return nil -} - -func (p *MyTestStruct) Write(oprot TProtocol) error { - if err := oprot.WriteStructBegin("MyTestStruct"); err != nil { - return PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := p.writeField10(oprot); err != nil { - return err - } - if err := p.writeField11(oprot); err != nil { - return err - } - if err := p.writeField12(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *MyTestStruct) writeField1(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("on", BOOL, 1); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 1:on: ", p), err) - } - if err := oprot.WriteBool(bool(p.On)); err != nil { - return PrependError(fmt.Sprintf("%T.on (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 1:on: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField2(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("b", BYTE, 2); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) - } - if err := oprot.WriteByte(int8(p.B)); err != nil { - return PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField3(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int16", I16, 3); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 3:int16: ", p), err) - } - if err := oprot.WriteI16(int16(p.Int16)); err != nil { - return PrependError(fmt.Sprintf("%T.int16 (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 3:int16: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField4(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int32", I32, 4); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 4:int32: ", p), err) - } - if err := oprot.WriteI32(int32(p.Int32)); err != nil { - return PrependError(fmt.Sprintf("%T.int32 (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 4:int32: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField5(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int64", I64, 5); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 5:int64: ", p), err) - } - if err := oprot.WriteI64(int64(p.Int64)); err != nil { - return PrependError(fmt.Sprintf("%T.int64 (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 5:int64: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField6(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("d", DOUBLE, 6); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 6:d: ", p), err) - } - if err := oprot.WriteDouble(float64(p.D)); err != nil { - return PrependError(fmt.Sprintf("%T.d (6) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 6:d: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField7(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("st", STRING, 7); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 7:st: ", p), err) - } - if err := oprot.WriteString(string(p.St)); err != nil { - return PrependError(fmt.Sprintf("%T.st (7) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 7:st: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField8(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("bin", STRING, 8); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 8:bin: ", p), err) - } - if err := oprot.WriteBinary(p.Bin); err != nil { - return PrependError(fmt.Sprintf("%T.bin (8) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 8:bin: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField9(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringMap", MAP, 9); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 9:stringMap: ", p), err) - } - if err := oprot.WriteMapBegin(STRING, STRING, len(p.StringMap)); err != nil { - return PrependError("error writing map begin: ", err) - } - for k, v := range p.StringMap { - if err := oprot.WriteString(string(k)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 9:stringMap: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField10(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringList", LIST, 10); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 10:stringList: ", p), err) - } - if err := oprot.WriteListBegin(STRING, len(p.StringList)); err != nil { - return PrependError("error writing list begin: ", err) - } - for _, v := range p.StringList { - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 10:stringList: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField11(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringSet", SET, 11); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 11:stringSet: ", p), err) - } - if err := oprot.WriteSetBegin(STRING, len(p.StringSet)); err != nil { - return PrependError("error writing set begin: ", err) - } - for v := range p.StringSet { - if err := oprot.WriteString(string(v)); err != nil { - return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 11:stringSet: ", p), err) - } - return err -} - -func (p *MyTestStruct) writeField12(oprot TProtocol) (err error) { - if err := oprot.WriteFieldBegin("e", I32, 12); err != nil { - return PrependError(fmt.Sprintf("%T write field begin error 12:e: ", p), err) - } - if err := oprot.WriteI32(int32(p.E)); err != nil { - return PrependError(fmt.Sprintf("%T.e (12) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return PrependError(fmt.Sprintf("%T write field end error 12:e: ", p), err) - } - return err -} - -func (p *MyTestStruct) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MyTestStruct(%+v)", *p) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server.go b/vendor/github.com/apache/thrift/lib/go/thrift/server.go deleted file mode 100644 index f813fa3..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server.go +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - -type TServer interface { - ProcessorFactory() TProcessorFactory - ServerTransport() TServerTransport - InputTransportFactory() TTransportFactory - OutputTransportFactory() TTransportFactory - InputProtocolFactory() TProtocolFactory - OutputProtocolFactory() TProtocolFactory - - // Starts the server - Serve() error - // Stops the server. This is optional on a per-implementation basis. Not - // all servers are required to be cleanly stoppable. - Stop() error -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go deleted file mode 100644 index 7dd24ae..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 ( - "net" - "sync" - "time" -) - -type TServerSocket struct { - listener net.Listener - addr net.Addr - clientTimeout time.Duration - - // Protects the interrupted value to make it thread safe. - mu sync.RWMutex - interrupted bool -} - -func NewTServerSocket(listenAddr string) (*TServerSocket, error) { - return NewTServerSocketTimeout(listenAddr, 0) -} - -func NewTServerSocketTimeout(listenAddr string, clientTimeout time.Duration) (*TServerSocket, error) { - addr, err := net.ResolveTCPAddr("tcp", listenAddr) - if err != nil { - return nil, err - } - return &TServerSocket{addr: addr, clientTimeout: clientTimeout}, nil -} - -// Creates a TServerSocket from a net.Addr -func NewTServerSocketFromAddrTimeout(addr net.Addr, clientTimeout time.Duration) *TServerSocket { - return &TServerSocket{addr: addr, clientTimeout: clientTimeout} -} - -func (p *TServerSocket) Listen() error { - p.mu.Lock() - defer p.mu.Unlock() - if p.IsListening() { - return nil - } - l, err := net.Listen(p.addr.Network(), p.addr.String()) - if err != nil { - return err - } - p.listener = l - return nil -} - -func (p *TServerSocket) Accept() (TTransport, error) { - p.mu.RLock() - interrupted := p.interrupted - p.mu.RUnlock() - - if interrupted { - return nil, errTransportInterrupted - } - - p.mu.Lock() - listener := p.listener - p.mu.Unlock() - if listener == nil { - return nil, NewTTransportException(NOT_OPEN, "No underlying server socket") - } - - conn, err := listener.Accept() - if err != nil { - return nil, NewTTransportExceptionFromError(err) - } - return NewTSocketFromConnTimeout(conn, p.clientTimeout), nil -} - -// Checks whether the socket is listening. -func (p *TServerSocket) IsListening() bool { - return p.listener != nil -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TServerSocket) Open() error { - p.mu.Lock() - defer p.mu.Unlock() - if p.IsListening() { - return NewTTransportException(ALREADY_OPEN, "Server socket already open") - } - if l, err := net.Listen(p.addr.Network(), p.addr.String()); err != nil { - return err - } else { - p.listener = l - } - return nil -} - -func (p *TServerSocket) Addr() net.Addr { - if p.listener != nil { - return p.listener.Addr() - } - return p.addr -} - -func (p *TServerSocket) Close() error { - var err error - p.mu.Lock() - if p.IsListening() { - err = p.listener.Close() - p.listener = nil - } - p.mu.Unlock() - return err -} - -func (p *TServerSocket) Interrupt() error { - p.mu.Lock() - p.interrupted = true - p.mu.Unlock() - p.Close() - - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go deleted file mode 100644 index f1e1983..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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" -) - -func TestSocketIsntListeningAfterInterrupt(t *testing.T) { - host := "127.0.0.1" - port := 9090 - addr := fmt.Sprintf("%s:%d", host, port) - - socket := CreateServerSocket(t, addr) - socket.Listen() - socket.Interrupt() - - newSocket := CreateServerSocket(t, addr) - err := newSocket.Listen() - defer newSocket.Interrupt() - if err != nil { - t.Fatalf("Failed to rebinds: %s", err) - } -} - -func TestSocketConcurrency(t *testing.T) { - host := "127.0.0.1" - port := 9090 - addr := fmt.Sprintf("%s:%d", host, port) - - socket := CreateServerSocket(t, addr) - go func() { socket.Listen() }() - go func() { socket.Interrupt() }() -} - -func CreateServerSocket(t *testing.T, addr string) *TServerSocket { - socket, err := NewTServerSocket(addr) - if err != nil { - t.Fatalf("Failed to create server socket: %s", err) - } - return socket -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_test.go deleted file mode 100644 index ffaf457..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_test.go +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 ( - "testing" -) - -func TestNothing(t *testing.T) { - -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go deleted file mode 100644 index 51c40b6..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - -// Server transport. Object which provides client transports. -type TServerTransport interface { - Listen() error - Accept() (TTransport, error) - Close() error - - // Optional method implementation. This signals to the server transport - // that it should break out of any accept() or listen() that it is currently - // blocked on. This method, if implemented, MUST be thread safe, as it may - // be called from a different thread context than the other TServerTransport - // methods. - Interrupt() error -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go deleted file mode 100644 index 2e8a711..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go +++ /dev/null @@ -1,1338 +0,0 @@ -/* - * 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 ( - "bufio" - "bytes" - "context" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "math" - "strconv" -) - -type _ParseContext int - -const ( - _CONTEXT_IN_TOPLEVEL _ParseContext = 1 - _CONTEXT_IN_LIST_FIRST _ParseContext = 2 - _CONTEXT_IN_LIST _ParseContext = 3 - _CONTEXT_IN_OBJECT_FIRST _ParseContext = 4 - _CONTEXT_IN_OBJECT_NEXT_KEY _ParseContext = 5 - _CONTEXT_IN_OBJECT_NEXT_VALUE _ParseContext = 6 -) - -func (p _ParseContext) String() string { - switch p { - case _CONTEXT_IN_TOPLEVEL: - return "TOPLEVEL" - case _CONTEXT_IN_LIST_FIRST: - return "LIST-FIRST" - case _CONTEXT_IN_LIST: - return "LIST" - case _CONTEXT_IN_OBJECT_FIRST: - return "OBJECT-FIRST" - case _CONTEXT_IN_OBJECT_NEXT_KEY: - return "OBJECT-NEXT-KEY" - case _CONTEXT_IN_OBJECT_NEXT_VALUE: - return "OBJECT-NEXT-VALUE" - } - return "UNKNOWN-PARSE-CONTEXT" -} - -// JSON protocol implementation for thrift. -// -// 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 - - parseContextStack []int - dumpContext []int - - writer *bufio.Writer - reader *bufio.Reader -} - -// Constructor -func NewTSimpleJSONProtocol(t TTransport) *TSimpleJSONProtocol { - v := &TSimpleJSONProtocol{trans: t, - writer: bufio.NewWriter(t), - reader: bufio.NewReader(t), - } - v.parseContextStack = append(v.parseContextStack, int(_CONTEXT_IN_TOPLEVEL)) - v.dumpContext = append(v.dumpContext, int(_CONTEXT_IN_TOPLEVEL)) - return v -} - -// Factory -type TSimpleJSONProtocolFactory struct{} - -func (p *TSimpleJSONProtocolFactory) GetProtocol(trans TTransport) TProtocol { - return NewTSimpleJSONProtocol(trans) -} - -func NewTSimpleJSONProtocolFactory() *TSimpleJSONProtocolFactory { - return &TSimpleJSONProtocolFactory{} -} - -var ( - JSON_COMMA []byte - JSON_COLON []byte - JSON_LBRACE []byte - JSON_RBRACE []byte - JSON_LBRACKET []byte - JSON_RBRACKET []byte - JSON_QUOTE byte - JSON_QUOTE_BYTES []byte - JSON_NULL []byte - JSON_TRUE []byte - JSON_FALSE []byte - JSON_INFINITY string - JSON_NEGATIVE_INFINITY string - JSON_NAN string - JSON_INFINITY_BYTES []byte - JSON_NEGATIVE_INFINITY_BYTES []byte - JSON_NAN_BYTES []byte - json_nonbase_map_elem_bytes []byte -) - -func init() { - JSON_COMMA = []byte{','} - JSON_COLON = []byte{':'} - JSON_LBRACE = []byte{'{'} - JSON_RBRACE = []byte{'}'} - JSON_LBRACKET = []byte{'['} - JSON_RBRACKET = []byte{']'} - JSON_QUOTE = '"' - JSON_QUOTE_BYTES = []byte{'"'} - JSON_NULL = []byte{'n', 'u', 'l', 'l'} - JSON_TRUE = []byte{'t', 'r', 'u', 'e'} - JSON_FALSE = []byte{'f', 'a', 'l', 's', 'e'} - JSON_INFINITY = "Infinity" - JSON_NEGATIVE_INFINITY = "-Infinity" - JSON_NAN = "NaN" - JSON_INFINITY_BYTES = []byte{'I', 'n', 'f', 'i', 'n', 'i', 't', 'y'} - JSON_NEGATIVE_INFINITY_BYTES = []byte{'-', 'I', 'n', 'f', 'i', 'n', 'i', 't', 'y'} - JSON_NAN_BYTES = []byte{'N', 'a', 'N'} - json_nonbase_map_elem_bytes = []byte{']', ',', '['} -} - -func jsonQuote(s string) string { - b, _ := json.Marshal(s) - s1 := string(b) - return s1 -} - -func jsonUnquote(s string) (string, bool) { - s1 := new(string) - err := json.Unmarshal([]byte(s), s1) - return *s1, err == nil -} - -func mismatch(expected, actual string) error { - return fmt.Errorf("Expected '%s' but found '%s' while parsing JSON.", expected, actual) -} - -func (p *TSimpleJSONProtocol) WriteMessageBegin(name string, typeId TMessageType, seqId int32) error { - p.resetContextStack() // THRIFT-3735 - if e := p.OutputListBegin(); e != nil { - return e - } - if e := p.WriteString(name); e != nil { - return e - } - if e := p.WriteByte(int8(typeId)); e != nil { - return e - } - if e := p.WriteI32(seqId); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) WriteMessageEnd() error { - return p.OutputListEnd() -} - -func (p *TSimpleJSONProtocol) WriteStructBegin(name string) error { - if e := p.OutputObjectBegin(); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) WriteStructEnd() error { - return p.OutputObjectEnd() -} - -func (p *TSimpleJSONProtocol) WriteFieldBegin(name string, typeId TType, id int16) error { - if e := p.WriteString(name); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) WriteFieldEnd() error { - //return p.OutputListEnd() - return nil -} - -func (p *TSimpleJSONProtocol) WriteFieldStop() error { return nil } - -func (p *TSimpleJSONProtocol) WriteMapBegin(keyType TType, valueType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - if e := p.WriteByte(int8(keyType)); e != nil { - return e - } - if e := p.WriteByte(int8(valueType)); e != nil { - return e - } - return p.WriteI32(int32(size)) -} - -func (p *TSimpleJSONProtocol) WriteMapEnd() error { - return p.OutputListEnd() -} - -func (p *TSimpleJSONProtocol) WriteListBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TSimpleJSONProtocol) WriteListEnd() error { - return p.OutputListEnd() -} - -func (p *TSimpleJSONProtocol) WriteSetBegin(elemType TType, size int) error { - return p.OutputElemListBegin(elemType, size) -} - -func (p *TSimpleJSONProtocol) WriteSetEnd() error { - return p.OutputListEnd() -} - -func (p *TSimpleJSONProtocol) WriteBool(b bool) error { - return p.OutputBool(b) -} - -func (p *TSimpleJSONProtocol) WriteByte(b int8) error { - return p.WriteI32(int32(b)) -} - -func (p *TSimpleJSONProtocol) WriteI16(v int16) error { - return p.WriteI32(int32(v)) -} - -func (p *TSimpleJSONProtocol) WriteI32(v int32) error { - return p.OutputI64(int64(v)) -} - -func (p *TSimpleJSONProtocol) WriteI64(v int64) error { - return p.OutputI64(int64(v)) -} - -func (p *TSimpleJSONProtocol) WriteDouble(v float64) error { - return p.OutputF64(v) -} - -func (p *TSimpleJSONProtocol) WriteString(v string) error { - return p.OutputString(v) -} - -func (p *TSimpleJSONProtocol) WriteBinary(v []byte) error { - // JSON library only takes in a string, - // not an arbitrary byte array, to ensure bytes are transmitted - // efficiently we must convert this into a valid JSON string - // therefore we use base64 encoding to avoid excessive escaping/quoting - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - writer := base64.NewEncoder(base64.StdEncoding, p.writer) - if _, e := writer.Write(v); e != nil { - p.writer.Reset(p.trans) // THRIFT-3735 - return NewTProtocolException(e) - } - if e := writer.Close(); e != nil { - return NewTProtocolException(e) - } - if _, e := p.write(JSON_QUOTE_BYTES); e != nil { - return NewTProtocolException(e) - } - return p.OutputPostValue() -} - -// Reading methods. -func (p *TSimpleJSONProtocol) ReadMessageBegin() (name string, typeId TMessageType, seqId int32, err error) { - p.resetContextStack() // THRIFT-3735 - if isNull, err := p.ParseListBegin(); isNull || err != nil { - return name, typeId, seqId, err - } - if name, err = p.ReadString(); err != nil { - return name, typeId, seqId, err - } - bTypeId, err := p.ReadByte() - typeId = TMessageType(bTypeId) - if err != nil { - return name, typeId, seqId, err - } - if seqId, err = p.ReadI32(); err != nil { - return name, typeId, seqId, err - } - return name, typeId, seqId, nil -} - -func (p *TSimpleJSONProtocol) ReadMessageEnd() error { - return p.ParseListEnd() -} - -func (p *TSimpleJSONProtocol) ReadStructBegin() (name string, err error) { - _, err = p.ParseObjectStart() - return "", err -} - -func (p *TSimpleJSONProtocol) ReadStructEnd() error { - return p.ParseObjectEnd() -} - -func (p *TSimpleJSONProtocol) ReadFieldBegin() (string, TType, int16, error) { - if err := p.ParsePreValue(); err != nil { - return "", STOP, 0, err - } - b, _ := p.reader.Peek(1) - if len(b) > 0 { - switch b[0] { - case JSON_RBRACE[0]: - return "", STOP, 0, nil - case JSON_QUOTE: - p.reader.ReadByte() - name, err := p.ParseStringBody() - // simplejson is not meant to be read back into thrift - // - see http://wiki.apache.org/thrift/ThriftUsageJava - // - use JSON instead - if err != nil { - return name, STOP, 0, err - } - return name, STOP, -1, p.ParsePostValue() - /* - if err = p.ParsePostValue(); err != nil { - return name, STOP, 0, err - } - if isNull, err := p.ParseListBegin(); isNull || err != nil { - return name, STOP, 0, err - } - bType, err := p.ReadByte() - thetype := TType(bType) - if err != nil { - return name, thetype, 0, err - } - id, err := p.ReadI16() - return name, thetype, id, err - */ - } - e := fmt.Errorf("Expected \"}\" or '\"', but found: '%s'", string(b)) - return "", STOP, 0, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return "", STOP, 0, NewTProtocolException(io.EOF) -} - -func (p *TSimpleJSONProtocol) ReadFieldEnd() error { - return nil - //return p.ParseListEnd() -} - -func (p *TSimpleJSONProtocol) ReadMapBegin() (keyType TType, valueType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, VOID, 0, e - } - - // read keyType - bKeyType, e := p.ReadByte() - keyType = TType(bKeyType) - if e != nil { - return keyType, valueType, size, e - } - - // read valueType - bValueType, e := p.ReadByte() - valueType = TType(bValueType) - if e != nil { - return keyType, valueType, size, e - } - - // read size - iSize, err := p.ReadI64() - size = int(iSize) - return keyType, valueType, size, err -} - -func (p *TSimpleJSONProtocol) ReadMapEnd() error { - return p.ParseListEnd() -} - -func (p *TSimpleJSONProtocol) ReadListBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TSimpleJSONProtocol) ReadListEnd() error { - return p.ParseListEnd() -} - -func (p *TSimpleJSONProtocol) ReadSetBegin() (elemType TType, size int, e error) { - return p.ParseElemListBegin() -} - -func (p *TSimpleJSONProtocol) ReadSetEnd() error { - return p.ParseListEnd() -} - -func (p *TSimpleJSONProtocol) ReadBool() (bool, error) { - var value bool - - if err := p.ParsePreValue(); err != nil { - return value, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 { - switch f[0] { - case JSON_TRUE[0]: - b := make([]byte, len(JSON_TRUE)) - _, err := p.reader.Read(b) - if err != nil { - return false, NewTProtocolException(err) - } - if string(b) == string(JSON_TRUE) { - value = true - } else { - e := fmt.Errorf("Expected \"true\" but found: %s", string(b)) - return value, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - break - case JSON_FALSE[0]: - b := make([]byte, len(JSON_FALSE)) - _, err := p.reader.Read(b) - if err != nil { - return false, NewTProtocolException(err) - } - if string(b) == string(JSON_FALSE) { - value = false - } else { - e := fmt.Errorf("Expected \"false\" but found: %s", string(b)) - return value, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - break - case JSON_NULL[0]: - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return false, NewTProtocolException(err) - } - if string(b) == string(JSON_NULL) { - value = false - } else { - e := fmt.Errorf("Expected \"null\" but found: %s", string(b)) - return value, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - default: - e := fmt.Errorf("Expected \"true\", \"false\", or \"null\" but found: %s", string(f)) - return value, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - return value, p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) ReadByte() (int8, error) { - v, err := p.ReadI64() - return int8(v), err -} - -func (p *TSimpleJSONProtocol) ReadI16() (int16, error) { - v, err := p.ReadI64() - return int16(v), err -} - -func (p *TSimpleJSONProtocol) ReadI32() (int32, error) { - v, err := p.ReadI64() - return int32(v), err -} - -func (p *TSimpleJSONProtocol) ReadI64() (int64, error) { - v, _, err := p.ParseI64() - return v, err -} - -func (p *TSimpleJSONProtocol) ReadDouble() (float64, error) { - v, _, err := p.ParseF64() - return v, err -} - -func (p *TSimpleJSONProtocol) ReadString() (string, error) { - var v string - if err := p.ParsePreValue(); err != nil { - return v, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseStringBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return v, p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) ReadBinary() ([]byte, error) { - var v []byte - if err := p.ParsePreValue(); err != nil { - return nil, err - } - f, _ := p.reader.Peek(1) - if len(f) > 0 && f[0] == JSON_QUOTE { - p.reader.ReadByte() - value, err := p.ParseBase64EncodedBody() - v = value - if err != nil { - return v, err - } - } else if len(f) > 0 && f[0] == JSON_NULL[0] { - b := make([]byte, len(JSON_NULL)) - _, err := p.reader.Read(b) - if err != nil { - return v, NewTProtocolException(err) - } - if string(b) != string(JSON_NULL) { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(b)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } else { - e := fmt.Errorf("Expected a JSON string, found unquoted data started with %s", string(f)) - return v, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - - return v, p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) Flush(ctx context.Context) (err error) { - return NewTProtocolException(p.writer.Flush()) -} - -func (p *TSimpleJSONProtocol) Skip(fieldType TType) (err error) { - return SkipDefaultDepth(p, fieldType) -} - -func (p *TSimpleJSONProtocol) Transport() TTransport { - return p.trans -} - -func (p *TSimpleJSONProtocol) OutputPreValue() error { - cxt := _ParseContext(p.dumpContext[len(p.dumpContext)-1]) - switch cxt { - case _CONTEXT_IN_LIST, _CONTEXT_IN_OBJECT_NEXT_KEY: - if _, e := p.write(JSON_COMMA); e != nil { - return NewTProtocolException(e) - } - break - case _CONTEXT_IN_OBJECT_NEXT_VALUE: - if _, e := p.write(JSON_COLON); e != nil { - return NewTProtocolException(e) - } - break - } - return nil -} - -func (p *TSimpleJSONProtocol) OutputPostValue() error { - cxt := _ParseContext(p.dumpContext[len(p.dumpContext)-1]) - switch cxt { - case _CONTEXT_IN_LIST_FIRST: - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_LIST)) - break - case _CONTEXT_IN_OBJECT_FIRST: - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_OBJECT_NEXT_VALUE)) - break - case _CONTEXT_IN_OBJECT_NEXT_KEY: - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_OBJECT_NEXT_VALUE)) - break - case _CONTEXT_IN_OBJECT_NEXT_VALUE: - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_OBJECT_NEXT_KEY)) - break - } - return nil -} - -func (p *TSimpleJSONProtocol) OutputBool(value bool) error { - if e := p.OutputPreValue(); e != nil { - return e - } - var v string - if value { - v = string(JSON_TRUE) - } else { - v = string(JSON_FALSE) - } - switch _ParseContext(p.dumpContext[len(p.dumpContext)-1]) { - case _CONTEXT_IN_OBJECT_FIRST, _CONTEXT_IN_OBJECT_NEXT_KEY: - v = jsonQuote(v) - default: - } - if e := p.OutputStringData(v); e != nil { - return e - } - return p.OutputPostValue() -} - -func (p *TSimpleJSONProtocol) OutputNull() error { - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_NULL); e != nil { - return NewTProtocolException(e) - } - return p.OutputPostValue() -} - -func (p *TSimpleJSONProtocol) OutputF64(value float64) error { - if e := p.OutputPreValue(); e != nil { - return e - } - var v string - if math.IsNaN(value) { - v = string(JSON_QUOTE) + JSON_NAN + string(JSON_QUOTE) - } else if math.IsInf(value, 1) { - v = string(JSON_QUOTE) + JSON_INFINITY + string(JSON_QUOTE) - } else if math.IsInf(value, -1) { - v = string(JSON_QUOTE) + JSON_NEGATIVE_INFINITY + string(JSON_QUOTE) - } else { - v = strconv.FormatFloat(value, 'g', -1, 64) - switch _ParseContext(p.dumpContext[len(p.dumpContext)-1]) { - case _CONTEXT_IN_OBJECT_FIRST, _CONTEXT_IN_OBJECT_NEXT_KEY: - v = string(JSON_QUOTE) + v + string(JSON_QUOTE) - default: - } - } - if e := p.OutputStringData(v); e != nil { - return e - } - return p.OutputPostValue() -} - -func (p *TSimpleJSONProtocol) OutputI64(value int64) error { - if e := p.OutputPreValue(); e != nil { - return e - } - v := strconv.FormatInt(value, 10) - switch _ParseContext(p.dumpContext[len(p.dumpContext)-1]) { - case _CONTEXT_IN_OBJECT_FIRST, _CONTEXT_IN_OBJECT_NEXT_KEY: - v = jsonQuote(v) - default: - } - if e := p.OutputStringData(v); e != nil { - return e - } - return p.OutputPostValue() -} - -func (p *TSimpleJSONProtocol) OutputString(s string) error { - if e := p.OutputPreValue(); e != nil { - return e - } - if e := p.OutputStringData(jsonQuote(s)); e != nil { - return e - } - return p.OutputPostValue() -} - -func (p *TSimpleJSONProtocol) OutputStringData(s string) error { - _, e := p.write([]byte(s)) - return NewTProtocolException(e) -} - -func (p *TSimpleJSONProtocol) OutputObjectBegin() error { - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_LBRACE); e != nil { - return NewTProtocolException(e) - } - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_OBJECT_FIRST)) - return nil -} - -func (p *TSimpleJSONProtocol) OutputObjectEnd() error { - if _, e := p.write(JSON_RBRACE); e != nil { - return NewTProtocolException(e) - } - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - if e := p.OutputPostValue(); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) OutputListBegin() error { - if e := p.OutputPreValue(); e != nil { - return e - } - if _, e := p.write(JSON_LBRACKET); e != nil { - return NewTProtocolException(e) - } - p.dumpContext = append(p.dumpContext, int(_CONTEXT_IN_LIST_FIRST)) - return nil -} - -func (p *TSimpleJSONProtocol) OutputListEnd() error { - if _, e := p.write(JSON_RBRACKET); e != nil { - return NewTProtocolException(e) - } - p.dumpContext = p.dumpContext[:len(p.dumpContext)-1] - if e := p.OutputPostValue(); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) OutputElemListBegin(elemType TType, size int) error { - if e := p.OutputListBegin(); e != nil { - return e - } - if e := p.WriteByte(int8(elemType)); e != nil { - return e - } - if e := p.WriteI64(int64(size)); e != nil { - return e - } - return nil -} - -func (p *TSimpleJSONProtocol) ParsePreValue() error { - if e := p.readNonSignificantWhitespace(); e != nil { - return NewTProtocolException(e) - } - cxt := _ParseContext(p.parseContextStack[len(p.parseContextStack)-1]) - b, _ := p.reader.Peek(1) - switch cxt { - case _CONTEXT_IN_LIST: - if len(b) > 0 { - switch b[0] { - case JSON_RBRACKET[0]: - return nil - case JSON_COMMA[0]: - p.reader.ReadByte() - if e := p.readNonSignificantWhitespace(); e != nil { - return NewTProtocolException(e) - } - return nil - default: - e := fmt.Errorf("Expected \"]\" or \",\" in list context, but found \"%s\"", string(b)) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - break - case _CONTEXT_IN_OBJECT_NEXT_KEY: - if len(b) > 0 { - switch b[0] { - case JSON_RBRACE[0]: - return nil - case JSON_COMMA[0]: - p.reader.ReadByte() - if e := p.readNonSignificantWhitespace(); e != nil { - return NewTProtocolException(e) - } - return nil - default: - e := fmt.Errorf("Expected \"}\" or \",\" in object context, but found \"%s\"", string(b)) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - break - case _CONTEXT_IN_OBJECT_NEXT_VALUE: - if len(b) > 0 { - switch b[0] { - case JSON_COLON[0]: - p.reader.ReadByte() - if e := p.readNonSignificantWhitespace(); e != nil { - return NewTProtocolException(e) - } - return nil - default: - e := fmt.Errorf("Expected \":\" in object context, but found \"%s\"", string(b)) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - break - } - return nil -} - -func (p *TSimpleJSONProtocol) ParsePostValue() error { - if e := p.readNonSignificantWhitespace(); e != nil { - return NewTProtocolException(e) - } - cxt := _ParseContext(p.parseContextStack[len(p.parseContextStack)-1]) - switch cxt { - case _CONTEXT_IN_LIST_FIRST: - p.parseContextStack = p.parseContextStack[:len(p.parseContextStack)-1] - p.parseContextStack = append(p.parseContextStack, int(_CONTEXT_IN_LIST)) - break - case _CONTEXT_IN_OBJECT_FIRST, _CONTEXT_IN_OBJECT_NEXT_KEY: - p.parseContextStack = p.parseContextStack[:len(p.parseContextStack)-1] - p.parseContextStack = append(p.parseContextStack, int(_CONTEXT_IN_OBJECT_NEXT_VALUE)) - break - case _CONTEXT_IN_OBJECT_NEXT_VALUE: - p.parseContextStack = p.parseContextStack[:len(p.parseContextStack)-1] - p.parseContextStack = append(p.parseContextStack, int(_CONTEXT_IN_OBJECT_NEXT_KEY)) - break - } - return nil -} - -func (p *TSimpleJSONProtocol) readNonSignificantWhitespace() error { - for { - b, _ := p.reader.Peek(1) - if len(b) < 1 { - return nil - } - switch b[0] { - case ' ', '\r', '\n', '\t': - p.reader.ReadByte() - continue - default: - break - } - break - } - return nil -} - -func (p *TSimpleJSONProtocol) ParseStringBody() (string, error) { - line, err := p.reader.ReadString(JSON_QUOTE) - if err != nil { - return "", NewTProtocolException(err) - } - l := len(line) - // count number of escapes to see if we need to keep going - i := 1 - for ; i < l; i++ { - if line[l-i-1] != '\\' { - break - } - } - if i&0x01 == 1 { - v, ok := jsonUnquote(string(JSON_QUOTE) + line) - if !ok { - return "", NewTProtocolException(err) - } - return v, nil - } - s, err := p.ParseQuotedStringBody() - if err != nil { - return "", NewTProtocolException(err) - } - str := string(JSON_QUOTE) + line + s - v, ok := jsonUnquote(str) - if !ok { - e := fmt.Errorf("Unable to parse as JSON string %s", str) - return "", NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return v, nil -} - -func (p *TSimpleJSONProtocol) ParseQuotedStringBody() (string, error) { - line, err := p.reader.ReadString(JSON_QUOTE) - if err != nil { - return "", NewTProtocolException(err) - } - l := len(line) - // count number of escapes to see if we need to keep going - i := 1 - for ; i < l; i++ { - if line[l-i-1] != '\\' { - break - } - } - if i&0x01 == 1 { - return line, nil - } - s, err := p.ParseQuotedStringBody() - if err != nil { - return "", NewTProtocolException(err) - } - v := line + s - return v, nil -} - -func (p *TSimpleJSONProtocol) ParseBase64EncodedBody() ([]byte, error) { - line, err := p.reader.ReadBytes(JSON_QUOTE) - if err != nil { - return line, NewTProtocolException(err) - } - line2 := line[0 : len(line)-1] - l := len(line2) - if (l % 4) != 0 { - pad := 4 - (l % 4) - fill := [...]byte{'=', '=', '='} - line2 = append(line2, fill[:pad]...) - l = len(line2) - } - output := make([]byte, base64.StdEncoding.DecodedLen(l)) - n, err := base64.StdEncoding.Decode(output, line2) - return output[0:n], NewTProtocolException(err) -} - -func (p *TSimpleJSONProtocol) ParseI64() (int64, bool, error) { - if err := p.ParsePreValue(); err != nil { - return 0, false, err - } - var value int64 - var isnull bool - if p.safePeekContains(JSON_NULL) { - p.reader.Read(make([]byte, len(JSON_NULL))) - isnull = true - } else { - num, err := p.readNumeric() - isnull = (num == nil) - if !isnull { - value = num.Int64() - } - if err != nil { - return value, isnull, err - } - } - return value, isnull, p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) ParseF64() (float64, bool, error) { - if err := p.ParsePreValue(); err != nil { - return 0, false, err - } - var value float64 - var isnull bool - if p.safePeekContains(JSON_NULL) { - p.reader.Read(make([]byte, len(JSON_NULL))) - isnull = true - } else { - num, err := p.readNumeric() - isnull = (num == nil) - if !isnull { - value = num.Float64() - } - if err != nil { - return value, isnull, err - } - } - return value, isnull, p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) ParseObjectStart() (bool, error) { - if err := p.ParsePreValue(); err != nil { - return false, err - } - var b []byte - b, err := p.reader.Peek(1) - if err != nil { - return false, err - } - if len(b) > 0 && b[0] == JSON_LBRACE[0] { - p.reader.ReadByte() - p.parseContextStack = append(p.parseContextStack, int(_CONTEXT_IN_OBJECT_FIRST)) - return false, nil - } else if p.safePeekContains(JSON_NULL) { - return true, nil - } - e := fmt.Errorf("Expected '{' or null, but found '%s'", string(b)) - return false, NewTProtocolExceptionWithType(INVALID_DATA, e) -} - -func (p *TSimpleJSONProtocol) ParseObjectEnd() error { - if isNull, err := p.readIfNull(); isNull || err != nil { - return err - } - cxt := _ParseContext(p.parseContextStack[len(p.parseContextStack)-1]) - if (cxt != _CONTEXT_IN_OBJECT_FIRST) && (cxt != _CONTEXT_IN_OBJECT_NEXT_KEY) { - e := fmt.Errorf("Expected to be in the Object Context, but not in Object Context (%d)", cxt) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - } - line, err := p.reader.ReadString(JSON_RBRACE[0]) - if err != nil { - return NewTProtocolException(err) - } - for _, char := range line { - switch char { - default: - e := fmt.Errorf("Expecting end of object \"}\", but found: \"%s\"", line) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - case ' ', '\n', '\r', '\t', '}': - break - } - } - p.parseContextStack = p.parseContextStack[:len(p.parseContextStack)-1] - return p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) ParseListBegin() (isNull bool, err error) { - if e := p.ParsePreValue(); e != nil { - return false, e - } - var b []byte - b, err = p.reader.Peek(1) - if err != nil { - return false, err - } - if len(b) >= 1 && b[0] == JSON_LBRACKET[0] { - p.parseContextStack = append(p.parseContextStack, int(_CONTEXT_IN_LIST_FIRST)) - p.reader.ReadByte() - isNull = false - } else if p.safePeekContains(JSON_NULL) { - isNull = true - } else { - err = fmt.Errorf("Expected \"null\" or \"[\", received %q", b) - } - return isNull, NewTProtocolExceptionWithType(INVALID_DATA, err) -} - -func (p *TSimpleJSONProtocol) ParseElemListBegin() (elemType TType, size int, e error) { - if isNull, e := p.ParseListBegin(); isNull || e != nil { - return VOID, 0, e - } - bElemType, err := p.ReadByte() - elemType = TType(bElemType) - if err != nil { - return elemType, size, err - } - nSize, err2 := p.ReadI64() - size = int(nSize) - return elemType, size, err2 -} - -func (p *TSimpleJSONProtocol) ParseListEnd() error { - if isNull, err := p.readIfNull(); isNull || err != nil { - return err - } - cxt := _ParseContext(p.parseContextStack[len(p.parseContextStack)-1]) - if cxt != _CONTEXT_IN_LIST { - e := fmt.Errorf("Expected to be in the List Context, but not in List Context (%d)", cxt) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - } - line, err := p.reader.ReadString(JSON_RBRACKET[0]) - if err != nil { - return NewTProtocolException(err) - } - for _, char := range line { - switch char { - default: - e := fmt.Errorf("Expecting end of list \"]\", but found: \"%v\"", line) - return NewTProtocolExceptionWithType(INVALID_DATA, e) - case ' ', '\n', '\r', '\t', rune(JSON_RBRACKET[0]): - break - } - } - p.parseContextStack = p.parseContextStack[:len(p.parseContextStack)-1] - if _ParseContext(p.parseContextStack[len(p.parseContextStack)-1]) == _CONTEXT_IN_TOPLEVEL { - return nil - } - return p.ParsePostValue() -} - -func (p *TSimpleJSONProtocol) readSingleValue() (interface{}, TType, error) { - e := p.readNonSignificantWhitespace() - if e != nil { - return nil, VOID, NewTProtocolException(e) - } - b, e := p.reader.Peek(1) - if len(b) > 0 { - c := b[0] - switch c { - case JSON_NULL[0]: - buf := make([]byte, len(JSON_NULL)) - _, e := p.reader.Read(buf) - if e != nil { - return nil, VOID, NewTProtocolException(e) - } - if string(JSON_NULL) != string(buf) { - e = mismatch(string(JSON_NULL), string(buf)) - return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return nil, VOID, nil - case JSON_QUOTE: - p.reader.ReadByte() - v, e := p.ParseStringBody() - if e != nil { - return v, UTF8, NewTProtocolException(e) - } - if v == JSON_INFINITY { - return INFINITY, DOUBLE, nil - } else if v == JSON_NEGATIVE_INFINITY { - return NEGATIVE_INFINITY, DOUBLE, nil - } else if v == JSON_NAN { - return NAN, DOUBLE, nil - } - return v, UTF8, nil - case JSON_TRUE[0]: - buf := make([]byte, len(JSON_TRUE)) - _, e := p.reader.Read(buf) - if e != nil { - return true, BOOL, NewTProtocolException(e) - } - if string(JSON_TRUE) != string(buf) { - e := mismatch(string(JSON_TRUE), string(buf)) - return true, BOOL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return true, BOOL, nil - case JSON_FALSE[0]: - buf := make([]byte, len(JSON_FALSE)) - _, e := p.reader.Read(buf) - if e != nil { - return false, BOOL, NewTProtocolException(e) - } - if string(JSON_FALSE) != string(buf) { - e := mismatch(string(JSON_FALSE), string(buf)) - return false, BOOL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return false, BOOL, nil - case JSON_LBRACKET[0]: - _, e := p.reader.ReadByte() - return make([]interface{}, 0), LIST, NewTProtocolException(e) - case JSON_LBRACE[0]: - _, e := p.reader.ReadByte() - return make(map[string]interface{}), STRUCT, NewTProtocolException(e) - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'e', 'E', '.', '+', '-', JSON_INFINITY[0], JSON_NAN[0]: - // assume numeric - v, e := p.readNumeric() - return v, DOUBLE, e - default: - e := fmt.Errorf("Expected element in list but found '%s' while parsing JSON.", string(c)) - return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - e = fmt.Errorf("Cannot read a single element while parsing JSON.") - return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e) - -} - -func (p *TSimpleJSONProtocol) readIfNull() (bool, error) { - cont := true - for cont { - b, _ := p.reader.Peek(1) - if len(b) < 1 { - return false, nil - } - switch b[0] { - default: - return false, nil - case JSON_NULL[0]: - cont = false - break - case ' ', '\n', '\r', '\t': - p.reader.ReadByte() - break - } - } - if p.safePeekContains(JSON_NULL) { - p.reader.Read(make([]byte, len(JSON_NULL))) - return true, nil - } - return false, nil -} - -func (p *TSimpleJSONProtocol) readQuoteIfNext() { - b, _ := p.reader.Peek(1) - if len(b) > 0 && b[0] == JSON_QUOTE { - p.reader.ReadByte() - } -} - -func (p *TSimpleJSONProtocol) readNumeric() (Numeric, error) { - isNull, err := p.readIfNull() - if isNull || err != nil { - return NUMERIC_NULL, err - } - hasDecimalPoint := false - nextCanBeSign := true - hasE := false - MAX_LEN := 40 - buf := bytes.NewBuffer(make([]byte, 0, MAX_LEN)) - continueFor := true - inQuotes := false - for continueFor { - c, err := p.reader.ReadByte() - if err != nil { - if err == io.EOF { - break - } - return NUMERIC_NULL, NewTProtocolException(err) - } - switch c { - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - buf.WriteByte(c) - nextCanBeSign = false - case '.': - if hasDecimalPoint { - e := fmt.Errorf("Unable to parse number with multiple decimal points '%s.'", buf.String()) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - if hasE { - e := fmt.Errorf("Unable to parse number with decimal points in the exponent '%s.'", buf.String()) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - buf.WriteByte(c) - hasDecimalPoint, nextCanBeSign = true, false - case 'e', 'E': - if hasE { - e := fmt.Errorf("Unable to parse number with multiple exponents '%s%c'", buf.String(), c) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - buf.WriteByte(c) - hasE, nextCanBeSign = true, true - case '-', '+': - if !nextCanBeSign { - e := fmt.Errorf("Negative sign within number") - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - buf.WriteByte(c) - nextCanBeSign = false - case ' ', 0, '\t', '\n', '\r', JSON_RBRACE[0], JSON_RBRACKET[0], JSON_COMMA[0], JSON_COLON[0]: - p.reader.UnreadByte() - continueFor = false - case JSON_NAN[0]: - if buf.Len() == 0 { - buffer := make([]byte, len(JSON_NAN)) - buffer[0] = c - _, e := p.reader.Read(buffer[1:]) - if e != nil { - return NUMERIC_NULL, NewTProtocolException(e) - } - if JSON_NAN != string(buffer) { - e := mismatch(JSON_NAN, string(buffer)) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - if inQuotes { - p.readQuoteIfNext() - } - return NAN, nil - } else { - e := fmt.Errorf("Unable to parse number starting with character '%c'", c) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - case JSON_INFINITY[0]: - if buf.Len() == 0 || (buf.Len() == 1 && buf.Bytes()[0] == '+') { - buffer := make([]byte, len(JSON_INFINITY)) - buffer[0] = c - _, e := p.reader.Read(buffer[1:]) - if e != nil { - return NUMERIC_NULL, NewTProtocolException(e) - } - if JSON_INFINITY != string(buffer) { - e := mismatch(JSON_INFINITY, string(buffer)) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - if inQuotes { - p.readQuoteIfNext() - } - return INFINITY, nil - } else if buf.Len() == 1 && buf.Bytes()[0] == JSON_NEGATIVE_INFINITY[0] { - buffer := make([]byte, len(JSON_NEGATIVE_INFINITY)) - buffer[0] = JSON_NEGATIVE_INFINITY[0] - buffer[1] = c - _, e := p.reader.Read(buffer[2:]) - if e != nil { - return NUMERIC_NULL, NewTProtocolException(e) - } - if JSON_NEGATIVE_INFINITY != string(buffer) { - e := mismatch(JSON_NEGATIVE_INFINITY, string(buffer)) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - if inQuotes { - p.readQuoteIfNext() - } - return NEGATIVE_INFINITY, nil - } else { - e := fmt.Errorf("Unable to parse number starting with character '%c' due to existing buffer %s", c, buf.String()) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - case JSON_QUOTE: - if !inQuotes { - inQuotes = true - } else { - break - } - default: - e := fmt.Errorf("Unable to parse number starting with character '%c'", c) - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - } - if buf.Len() == 0 { - e := fmt.Errorf("Unable to parse number from empty string ''") - return NUMERIC_NULL, NewTProtocolExceptionWithType(INVALID_DATA, e) - } - return NewNumericFromJSONString(buf.String(), false), nil -} - -// Safely peeks into the buffer, reading only what is necessary -func (p *TSimpleJSONProtocol) safePeekContains(b []byte) bool { - for i := 0; i < len(b); i++ { - a, _ := p.reader.Peek(i + 1) - if len(a) == 0 || a[i] != b[i] { - return false - } - } - return true -} - -// Reset the context stack to its initial state. -func (p *TSimpleJSONProtocol) resetContextStack() { - p.parseContextStack = []int{int(_CONTEXT_IN_TOPLEVEL)} - p.dumpContext = []int{int(_CONTEXT_IN_TOPLEVEL)} -} - -func (p *TSimpleJSONProtocol) write(b []byte) (int, error) { - n, err := p.writer.Write(b) - if err != nil { - p.writer.Reset(p.trans) // THRIFT-3735 - } - return n, err -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go deleted file mode 100644 index 7b98082..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go +++ /dev/null @@ -1,716 +0,0 @@ -/* - * 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 ( - "context" - "encoding/base64" - "encoding/json" - "fmt" - "math" - "strconv" - "strings" - "testing" -) - -func TestWriteSimpleJSONProtocolBool(t *testing.T) { - thetype := "boolean" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range BOOL_VALUES { - if e := p.WriteBool(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := false - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolBool(t *testing.T) { - thetype := "boolean" - for _, value := range BOOL_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - if value { - trans.Write(JSON_TRUE) - } else { - trans.Write(JSON_FALSE) - } - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadBool() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolByte(t *testing.T) { - thetype := "byte" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range BYTE_VALUES { - if e := p.WriteByte(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int8(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolByte(t *testing.T) { - thetype := "byte" - for _, value := range BYTE_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadByte() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolI16(t *testing.T) { - thetype := "int16" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT16_VALUES { - if e := p.WriteI16(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int16(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI16(t *testing.T) { - thetype := "int16" - for _, value := range INT16_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI16() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolI32(t *testing.T) { - thetype := "int32" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT32_VALUES { - if e := p.WriteI32(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int32(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI32(t *testing.T) { - thetype := "int32" - for _, value := range INT32_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.Itoa(int(value))) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI32() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestReadSimpleJSONProtocolI32Null(t *testing.T) { - thetype := "int32" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI32() - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != 0 { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolI64(t *testing.T) { - thetype := "int64" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range INT64_VALUES { - if e := p.WriteI64(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := int64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolI64(t *testing.T) { - thetype := "int64" - for _, value := range INT64_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(strconv.FormatInt(value, 10)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI64() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - trans.Reset() - trans.Close() - } -} - -func TestReadSimpleJSONProtocolI64Null(t *testing.T) { - thetype := "int32" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadI64() - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != 0 { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolDouble(t *testing.T) { - thetype := "double" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, -1) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) - } - } else { - if s != fmt.Sprint(value) { - t.Fatalf("Bad value for %s %v: %s", thetype, value, s) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolDouble(t *testing.T) { - thetype := "double" - for _, value := range DOUBLE_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - n := NewNumericFromDouble(value) - trans.WriteString(n.String()) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadDouble() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if math.IsInf(value, 1) { - if !math.IsInf(v, 1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsInf(value, -1) { - if !math.IsInf(v, -1) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else if math.IsNaN(value) { - if !math.IsNaN(v) { - t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) - } - } else { - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - trans.Close() - } -} - -func TestWriteSimpleJSONProtocolString(t *testing.T) { - thetype := "string" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - for _, value := range STRING_VALUES { - if e := p.WriteString(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s[0] != '"' || s[len(s)-1] != '"' { - t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) - } - v := new(string) - if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) - } - trans.Reset() - } - trans.Close() -} - -func TestReadSimpleJSONProtocolString(t *testing.T) { - thetype := "string" - for _, value := range STRING_VALUES { - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(jsonQuote(value)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != value { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() - } -} -func TestReadSimpleJSONProtocolStringNull(t *testing.T) { - thetype := "string" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadString() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != "" { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - if e := p.WriteBinary(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) - } - s := trans.String() - if s != fmt.Sprint("\"", b64String, "\"") { - t.Fatalf("Bad value for %s %v\n wrote: %v\nexpected: %v", thetype, value, s, "\""+b64String+"\"") - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Close() -} - -func TestReadSimpleJSONProtocolBinary(t *testing.T) { - thetype := "binary" - value := protocol_bdata - b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) - base64.StdEncoding.Encode(b64value, value) - b64String := string(b64value) - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(jsonQuote(b64String)) - trans.Flush(context.Background()) - s := trans.String() - v, e := p.ReadBinary() - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if len(v) != len(value) { - t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) - } - for i := 0; i < len(v); i++ { - if v[i] != value[i] { - t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) - } - } - v1 := new(string) - if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) - } - trans.Reset() - trans.Close() -} - -func TestReadSimpleJSONProtocolBinaryNull(t *testing.T) { - thetype := "binary" - value := "null" - - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - trans.WriteString(value) - trans.Flush(context.Background()) - s := trans.String() - b, e := p.ReadBinary() - v := string(b) - - if e != nil { - t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) - } - if v != "" { - t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) - } - trans.Reset() - trans.Close() -} - -func TestWriteSimpleJSONProtocolList(t *testing.T) { - thetype := "list" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteListEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("List must be at least of length two to include metadata") - } - if int(l[0].(float64)) != DOUBLE { - t.Fatal("Invalid type for list, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteSimpleJSONProtocolSet(t *testing.T) { - thetype := "set" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) - for _, value := range DOUBLE_VALUES { - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteSetEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - str1 := new([]interface{}) - err := json.Unmarshal([]byte(str), str1) - if err != nil { - t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) - } - l := *str1 - if len(l) < 2 { - t.Fatalf("Set must be at least of length two to include metadata") - } - if int(l[0].(float64)) != DOUBLE { - t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) - } - if int(l[1].(float64)) != len(DOUBLE_VALUES) { - t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) - } - for k, value := range DOUBLE_VALUES { - s := l[k+2] - if math.IsInf(value, 1) { - if s.(string) != JSON_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) - } - } else if math.IsInf(value, 0) { - if s.(string) != JSON_NEGATIVE_INFINITY { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) - } - } else if math.IsNaN(value) { - if s.(string) != JSON_NAN { - t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) - } - } else { - if s.(float64) != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) - } - } - trans.Reset() - } - trans.Close() -} - -func TestWriteSimpleJSONProtocolMap(t *testing.T) { - thetype := "map" - trans := NewTMemoryBuffer() - p := NewTSimpleJSONProtocol(trans) - p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) - for k, value := range DOUBLE_VALUES { - if e := p.WriteI32(int32(k)); e != nil { - t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) - } - if e := p.WriteDouble(value); e != nil { - t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) - } - } - p.WriteMapEnd() - if e := p.Flush(context.Background()); e != nil { - t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) - } - str := trans.String() - if str[0] != '[' || str[len(str)-1] != ']' { - t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES) - } - l := strings.Split(str[1:len(str)-1], ",") - if len(l) < 3 { - t.Fatal("Expected list of at least length 3 for map for metadata, but was of length ", len(l)) - } - expectedKeyType, _ := strconv.Atoi(l[0]) - expectedValueType, _ := strconv.Atoi(l[1]) - expectedSize, _ := strconv.Atoi(l[2]) - if expectedKeyType != I32 { - t.Fatal("Expected map key type ", I32, ", but was ", l[0]) - } - if expectedValueType != DOUBLE { - t.Fatal("Expected map value type ", DOUBLE, ", but was ", l[1]) - } - if expectedSize != len(DOUBLE_VALUES) { - t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", l[2]) - } - for k, value := range DOUBLE_VALUES { - strk := l[k*2+3] - strv := l[k*2+4] - ik, err := strconv.Atoi(strk) - if err != nil { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, strk, string(k), err.Error()) - } - if ik != k { - t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v", thetype, k, strk, k) - } - s := strv - if math.IsInf(value, 1) { - if s != jsonQuote(JSON_INFINITY) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) - } - } else if math.IsInf(value, 0) { - if s != jsonQuote(JSON_NEGATIVE_INFINITY) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) - } - } else if math.IsNaN(value) { - if s != jsonQuote(JSON_NAN) { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) - } - } else { - expected := strconv.FormatFloat(value, 'g', 10, 64) - if s != expected { - t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) - } - v := float64(0) - if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { - t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) - } - } - trans.Reset() - } - trans.Close() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go deleted file mode 100644 index 6035802..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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 ( - "log" - "runtime/debug" - "sync" - "sync/atomic" -) - -/* - * This is not a typical TSimpleServer as it is not blocked after accept a socket. - * It is more like a TThreadedServer that can handle different connections in different goroutines. - * This will work if golang user implements a conn-pool like thing in client side. - */ -type TSimpleServer struct { - closed int32 - wg sync.WaitGroup - mu sync.Mutex - - processorFactory TProcessorFactory - serverTransport TServerTransport - inputTransportFactory TTransportFactory - outputTransportFactory TTransportFactory - inputProtocolFactory TProtocolFactory - outputProtocolFactory TProtocolFactory -} - -func NewTSimpleServer2(processor TProcessor, serverTransport TServerTransport) *TSimpleServer { - return NewTSimpleServerFactory2(NewTProcessorFactory(processor), serverTransport) -} - -func NewTSimpleServer4(processor TProcessor, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory4(NewTProcessorFactory(processor), - serverTransport, - transportFactory, - protocolFactory, - ) -} - -func NewTSimpleServer6(processor TProcessor, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory6(NewTProcessorFactory(processor), - serverTransport, - inputTransportFactory, - outputTransportFactory, - inputProtocolFactory, - outputProtocolFactory, - ) -} - -func NewTSimpleServerFactory2(processorFactory TProcessorFactory, serverTransport TServerTransport) *TSimpleServer { - return NewTSimpleServerFactory6(processorFactory, - serverTransport, - NewTTransportFactory(), - NewTTransportFactory(), - NewTBinaryProtocolFactoryDefault(), - NewTBinaryProtocolFactoryDefault(), - ) -} - -func NewTSimpleServerFactory4(processorFactory TProcessorFactory, serverTransport TServerTransport, transportFactory TTransportFactory, protocolFactory TProtocolFactory) *TSimpleServer { - return NewTSimpleServerFactory6(processorFactory, - serverTransport, - transportFactory, - transportFactory, - protocolFactory, - protocolFactory, - ) -} - -func NewTSimpleServerFactory6(processorFactory TProcessorFactory, serverTransport TServerTransport, inputTransportFactory TTransportFactory, outputTransportFactory TTransportFactory, inputProtocolFactory TProtocolFactory, outputProtocolFactory TProtocolFactory) *TSimpleServer { - return &TSimpleServer{ - processorFactory: processorFactory, - serverTransport: serverTransport, - inputTransportFactory: inputTransportFactory, - outputTransportFactory: outputTransportFactory, - inputProtocolFactory: inputProtocolFactory, - outputProtocolFactory: outputProtocolFactory, - } -} - -func (p *TSimpleServer) ProcessorFactory() TProcessorFactory { - return p.processorFactory -} - -func (p *TSimpleServer) ServerTransport() TServerTransport { - return p.serverTransport -} - -func (p *TSimpleServer) InputTransportFactory() TTransportFactory { - return p.inputTransportFactory -} - -func (p *TSimpleServer) OutputTransportFactory() TTransportFactory { - return p.outputTransportFactory -} - -func (p *TSimpleServer) InputProtocolFactory() TProtocolFactory { - return p.inputProtocolFactory -} - -func (p *TSimpleServer) OutputProtocolFactory() TProtocolFactory { - return p.outputProtocolFactory -} - -func (p *TSimpleServer) Listen() error { - return p.serverTransport.Listen() -} - -func (p *TSimpleServer) innerAccept() (int32, error) { - client, err := p.serverTransport.Accept() - p.mu.Lock() - defer p.mu.Unlock() - closed := atomic.LoadInt32(&p.closed) - if closed != 0 { - return closed, nil - } - if err != nil { - return 0, err - } - if client != nil { - p.wg.Add(1) - go func() { - defer p.wg.Done() - if err := p.processRequests(client); err != nil { - log.Println("error processing request:", err) - } - }() - } - return 0, nil -} - -func (p *TSimpleServer) AcceptLoop() error { - for { - closed, err := p.innerAccept() - if err != nil { - return err - } - if closed != 0 { - return nil - } - } -} - -func (p *TSimpleServer) Serve() error { - err := p.Listen() - if err != nil { - return err - } - p.AcceptLoop() - return nil -} - -func (p *TSimpleServer) Stop() error { - p.mu.Lock() - defer p.mu.Unlock() - if atomic.LoadInt32(&p.closed) != 0 { - return nil - } - atomic.StoreInt32(&p.closed, 1) - p.serverTransport.Interrupt() - p.wg.Wait() - return nil -} - -func (p *TSimpleServer) processRequests(client TTransport) error { - processor := p.processorFactory.GetProcessor(client) - inputTransport, err := p.inputTransportFactory.GetTransport(client) - if err != nil { - return err - } - outputTransport, err := p.outputTransportFactory.GetTransport(client) - if err != nil { - return err - } - inputProtocol := p.inputProtocolFactory.GetProtocol(inputTransport) - outputProtocol := p.outputProtocolFactory.GetProtocol(outputTransport) - defer func() { - if e := recover(); e != nil { - log.Printf("panic in processor: %s: %s", e, debug.Stack()) - } - }() - - if inputTransport != nil { - defer inputTransport.Close() - } - if outputTransport != nil { - defer outputTransport.Close() - } - for { - if atomic.LoadInt32(&p.closed) != 0 { - return nil - } - - ok, err := processor.Process(defaultCtx, inputProtocol, outputProtocol) - if err, ok := err.(TTransportException); ok && err.TypeId() == END_OF_FILE { - return nil - } else if err != nil { - return err - } - if err, ok := err.(TApplicationException); ok && err.TypeId() == UNKNOWN_METHOD { - continue - } - if !ok { - break - } - } - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go deleted file mode 100644 index 58149a8..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 ( - "testing" - "errors" - "runtime" -) - -type mockServerTransport struct { - ListenFunc func() error - AcceptFunc func() (TTransport, error) - CloseFunc func() error - InterruptFunc func() error -} - -func (m *mockServerTransport) Listen() error { - return m.ListenFunc() -} - -func (m *mockServerTransport) Accept() (TTransport, error) { - return m.AcceptFunc() -} - -func (m *mockServerTransport) Close() error { - return m.CloseFunc() -} - -func (m *mockServerTransport) Interrupt() error { - return m.InterruptFunc() -} - -type mockTTransport struct { - TTransport -} - -func (m *mockTTransport) Close() error { - return nil -} - -func TestMultipleStop(t *testing.T) { - proc := &mockProcessor{ - ProcessFunc: func(in, out TProtocol) (bool, TException) { - return false, nil - }, - } - - var interruptCalled bool - c := make(chan struct{}) - trans := &mockServerTransport{ - ListenFunc: func() error { - return nil - }, - AcceptFunc: func() (TTransport, error) { - <-c - return nil, nil - }, - CloseFunc: func() error { - c <- struct{}{} - return nil - }, - InterruptFunc: func() error { - interruptCalled = true - return nil - }, - } - - serv := NewTSimpleServer2(proc, trans) - go serv.Serve() - serv.Stop() - if !interruptCalled { - t.Error("first server transport should have been interrupted") - } - - serv = NewTSimpleServer2(proc, trans) - interruptCalled = false - go serv.Serve() - serv.Stop() - if !interruptCalled { - t.Error("second server transport should have been interrupted") - } -} - -func TestWaitRace(t *testing.T) { - proc := &mockProcessor{ - ProcessFunc: func(in, out TProtocol) (bool, TException) { - return false, nil - }, - } - - trans := &mockServerTransport{ - ListenFunc: func() error { - return nil - }, - AcceptFunc: func() (TTransport, error) { - return &mockTTransport{}, nil - }, - CloseFunc: func() error { - return nil - }, - InterruptFunc: func() error { - return nil - }, - } - - serv := NewTSimpleServer2(proc, trans) - go serv.Serve() - runtime.Gosched() - serv.Stop() -} - -func TestNoHangDuringStopFromDanglingLockAcquireDuringAcceptLoop(t *testing.T) { - proc := &mockProcessor{ - ProcessFunc: func(in, out TProtocol) (bool, TException) { - return false, nil - }, - } - - trans := &mockServerTransport{ - ListenFunc: func() error { - return nil - }, - AcceptFunc: func() (TTransport, error) { - return nil, errors.New("no sir") - }, - CloseFunc: func() error { - return nil - }, - InterruptFunc: func() error { - return nil - }, - } - - serv := NewTSimpleServer2(proc, trans) - go serv.Serve() - runtime.Gosched() - serv.Stop() -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go deleted file mode 100644 index 8854279..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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 ( - "context" - "net" - "time" -) - -type TSocket struct { - conn net.Conn - addr net.Addr - timeout time.Duration -} - -// NewTSocket creates a net.Conn-backed TTransport, given a host and port -// -// Example: -// trans, err := thrift.NewTSocket("localhost:9090") -func NewTSocket(hostPort string) (*TSocket, error) { - return NewTSocketTimeout(hostPort, 0) -} - -// NewTSocketTimeout creates a net.Conn-backed TTransport, given a host and port -// it also accepts a timeout as a time.Duration -func NewTSocketTimeout(hostPort string, timeout time.Duration) (*TSocket, error) { - //conn, err := net.DialTimeout(network, address, timeout) - addr, err := net.ResolveTCPAddr("tcp", hostPort) - if err != nil { - return nil, err - } - return NewTSocketFromAddrTimeout(addr, timeout), nil -} - -// Creates a TSocket from a net.Addr -func NewTSocketFromAddrTimeout(addr net.Addr, timeout time.Duration) *TSocket { - return &TSocket{addr: addr, timeout: timeout} -} - -// Creates a TSocket from an existing net.Conn -func NewTSocketFromConnTimeout(conn net.Conn, timeout time.Duration) *TSocket { - return &TSocket{conn: conn, addr: conn.RemoteAddr(), timeout: timeout} -} - -// Sets the socket timeout -func (p *TSocket) SetTimeout(timeout time.Duration) error { - p.timeout = timeout - return nil -} - -func (p *TSocket) pushDeadline(read, write bool) { - var t time.Time - if p.timeout > 0 { - t = time.Now().Add(time.Duration(p.timeout)) - } - if read && write { - p.conn.SetDeadline(t) - } else if read { - p.conn.SetReadDeadline(t) - } else if write { - p.conn.SetWriteDeadline(t) - } -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSocket) Open() error { - if p.IsOpen() { - return NewTTransportException(ALREADY_OPEN, "Socket already connected.") - } - if p.addr == nil { - return NewTTransportException(NOT_OPEN, "Cannot open nil address.") - } - if len(p.addr.Network()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad network name.") - } - if len(p.addr.String()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad address.") - } - var err error - if p.conn, err = net.DialTimeout(p.addr.Network(), p.addr.String(), p.timeout); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - return nil -} - -// Retrieve the underlying net.Conn -func (p *TSocket) Conn() net.Conn { - return p.conn -} - -// Returns true if the connection is open -func (p *TSocket) IsOpen() bool { - if p.conn == nil { - return false - } - return true -} - -// Closes the socket. -func (p *TSocket) Close() error { - // Close the socket - if p.conn != nil { - err := p.conn.Close() - if err != nil { - return err - } - p.conn = nil - } - return nil -} - -//Returns the remote address of the socket. -func (p *TSocket) Addr() net.Addr { - return p.addr -} - -func (p *TSocket) Read(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(true, false) - n, err := p.conn.Read(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TSocket) Write(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(false, true) - return p.conn.Write(buf) -} - -func (p *TSocket) Flush(ctx context.Context) error { - return nil -} - -func (p *TSocket) Interrupt() error { - if !p.IsOpen() { - return nil - } - return p.conn.Close() -} - -func (p *TSocket) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go deleted file mode 100644 index 907afca..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 ( - "crypto/tls" - "net" - "time" -) - -type TSSLServerSocket struct { - listener net.Listener - addr net.Addr - clientTimeout time.Duration - interrupted bool - cfg *tls.Config -} - -func NewTSSLServerSocket(listenAddr string, cfg *tls.Config) (*TSSLServerSocket, error) { - return NewTSSLServerSocketTimeout(listenAddr, cfg, 0) -} - -func NewTSSLServerSocketTimeout(listenAddr string, cfg *tls.Config, clientTimeout time.Duration) (*TSSLServerSocket, error) { - if cfg.MinVersion == 0 { - cfg.MinVersion = tls.VersionTLS10 - } - addr, err := net.ResolveTCPAddr("tcp", listenAddr) - if err != nil { - return nil, err - } - return &TSSLServerSocket{addr: addr, clientTimeout: clientTimeout, cfg: cfg}, nil -} - -func (p *TSSLServerSocket) Listen() error { - if p.IsListening() { - return nil - } - l, err := tls.Listen(p.addr.Network(), p.addr.String(), p.cfg) - if err != nil { - return err - } - p.listener = l - return nil -} - -func (p *TSSLServerSocket) Accept() (TTransport, error) { - if p.interrupted { - return nil, errTransportInterrupted - } - if p.listener == nil { - return nil, NewTTransportException(NOT_OPEN, "No underlying server socket") - } - conn, err := p.listener.Accept() - if err != nil { - return nil, NewTTransportExceptionFromError(err) - } - return NewTSSLSocketFromConnTimeout(conn, p.cfg, p.clientTimeout), nil -} - -// Checks whether the socket is listening. -func (p *TSSLServerSocket) IsListening() bool { - return p.listener != nil -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSSLServerSocket) Open() error { - if p.IsListening() { - return NewTTransportException(ALREADY_OPEN, "Server socket already open") - } - if l, err := tls.Listen(p.addr.Network(), p.addr.String(), p.cfg); err != nil { - return err - } else { - p.listener = l - } - return nil -} - -func (p *TSSLServerSocket) Addr() net.Addr { - return p.addr -} - -func (p *TSSLServerSocket) Close() error { - defer func() { - p.listener = nil - }() - if p.IsListening() { - return p.listener.Close() - } - return nil -} - -func (p *TSSLServerSocket) Interrupt() error { - p.interrupted = true - return nil -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go deleted file mode 100644 index ba63377..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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 ( - "context" - "crypto/tls" - "net" - "time" -) - -type TSSLSocket struct { - conn net.Conn - // hostPort contains host:port (e.g. "asdf.com:12345"). The field is - // only valid if addr is nil. - hostPort string - // addr is nil when hostPort is not "", and is only used when the - // TSSLSocket is constructed from a net.Addr. - addr net.Addr - timeout time.Duration - cfg *tls.Config -} - -// NewTSSLSocket creates a net.Conn-backed TTransport, given a host and port and tls Configuration -// -// Example: -// trans, err := thrift.NewTSSLSocket("localhost:9090", nil) -func NewTSSLSocket(hostPort string, cfg *tls.Config) (*TSSLSocket, error) { - return NewTSSLSocketTimeout(hostPort, cfg, 0) -} - -// NewTSSLSocketTimeout creates a net.Conn-backed TTransport, given a host and port -// it also accepts a tls Configuration and a timeout as a time.Duration -func NewTSSLSocketTimeout(hostPort string, cfg *tls.Config, timeout time.Duration) (*TSSLSocket, error) { - if cfg.MinVersion == 0 { - cfg.MinVersion = tls.VersionTLS10 - } - return &TSSLSocket{hostPort: hostPort, timeout: timeout, cfg: cfg}, nil -} - -// Creates a TSSLSocket from a net.Addr -func NewTSSLSocketFromAddrTimeout(addr net.Addr, cfg *tls.Config, timeout time.Duration) *TSSLSocket { - return &TSSLSocket{addr: addr, timeout: timeout, cfg: cfg} -} - -// Creates a TSSLSocket from an existing net.Conn -func NewTSSLSocketFromConnTimeout(conn net.Conn, cfg *tls.Config, timeout time.Duration) *TSSLSocket { - return &TSSLSocket{conn: conn, addr: conn.RemoteAddr(), timeout: timeout, cfg: cfg} -} - -// Sets the socket timeout -func (p *TSSLSocket) SetTimeout(timeout time.Duration) error { - p.timeout = timeout - return nil -} - -func (p *TSSLSocket) pushDeadline(read, write bool) { - var t time.Time - if p.timeout > 0 { - t = time.Now().Add(time.Duration(p.timeout)) - } - if read && write { - p.conn.SetDeadline(t) - } else if read { - p.conn.SetReadDeadline(t) - } else if write { - p.conn.SetWriteDeadline(t) - } -} - -// Connects the socket, creating a new socket object if necessary. -func (p *TSSLSocket) Open() error { - var err error - // If we have a hostname, we need to pass the hostname to tls.Dial for - // certificate hostname checks. - if p.hostPort != "" { - if p.conn, err = tls.DialWithDialer(&net.Dialer{ - Timeout: p.timeout}, "tcp", p.hostPort, p.cfg); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - } else { - if p.IsOpen() { - return NewTTransportException(ALREADY_OPEN, "Socket already connected.") - } - if p.addr == nil { - return NewTTransportException(NOT_OPEN, "Cannot open nil address.") - } - if len(p.addr.Network()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad network name.") - } - if len(p.addr.String()) == 0 { - return NewTTransportException(NOT_OPEN, "Cannot open bad address.") - } - if p.conn, err = tls.DialWithDialer(&net.Dialer{ - Timeout: p.timeout}, p.addr.Network(), p.addr.String(), p.cfg); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) - } - } - return nil -} - -// Retrieve the underlying net.Conn -func (p *TSSLSocket) Conn() net.Conn { - return p.conn -} - -// Returns true if the connection is open -func (p *TSSLSocket) IsOpen() bool { - if p.conn == nil { - return false - } - return true -} - -// Closes the socket. -func (p *TSSLSocket) Close() error { - // Close the socket - if p.conn != nil { - err := p.conn.Close() - if err != nil { - return err - } - p.conn = nil - } - return nil -} - -func (p *TSSLSocket) Read(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(true, false) - n, err := p.conn.Read(buf) - return n, NewTTransportExceptionFromError(err) -} - -func (p *TSSLSocket) Write(buf []byte) (int, error) { - if !p.IsOpen() { - return 0, NewTTransportException(NOT_OPEN, "Connection not open") - } - p.pushDeadline(false, true) - return p.conn.Write(buf) -} - -func (p *TSSLSocket) Flush(ctx context.Context) error { - return nil -} - -func (p *TSSLSocket) Interrupt() error { - if !p.IsOpen() { - return nil - } - return p.conn.Close() -} - -func (p *TSSLSocket) RemainingBytes() (num_bytes uint64) { - const maxSize = ^uint64(0) - return maxSize // the thruth is, we just don't know unless framed is used -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport.go deleted file mode 100644 index ba2738a..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/transport.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 ( - "context" - "errors" - "io" -) - -var errTransportInterrupted = errors.New("Transport Interrupted") - -type Flusher interface { - Flush() (err error) -} - -type ContextFlusher interface { - Flush(ctx context.Context) (err error) -} - -type ReadSizeProvider interface { - RemainingBytes() (num_bytes uint64) -} - -// Encapsulates the I/O layer -type TTransport interface { - io.ReadWriteCloser - ContextFlusher - ReadSizeProvider - - // Opens the transport for communication - Open() error - - // Returns true if the transport is open - IsOpen() bool -} - -type stringWriter interface { - WriteString(s string) (n int, err error) -} - -// This is "enchanced" transport with extra capabilities. You need to use one of these -// to construct protocol. -// Notably, TSocket does not implement this interface, and it is always a mistake to use -// TSocket directly in protocol. -type TRichTransport interface { - io.ReadWriter - io.ByteReader - io.ByteWriter - stringWriter - ContextFlusher - ReadSizeProvider -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go deleted file mode 100644 index 9505b44..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 ( - "errors" - "io" -) - -type timeoutable interface { - Timeout() bool -} - -// Thrift Transport exception -type TTransportException interface { - TException - TypeId() int - Err() error -} - -const ( - UNKNOWN_TRANSPORT_EXCEPTION = 0 - NOT_OPEN = 1 - ALREADY_OPEN = 2 - TIMED_OUT = 3 - END_OF_FILE = 4 -) - -type tTransportException struct { - typeId int - err error -} - -func (p *tTransportException) TypeId() int { - return p.typeId -} - -func (p *tTransportException) Error() string { - return p.err.Error() -} - -func (p *tTransportException) Err() error { - return p.err -} - -func NewTTransportException(t int, e string) TTransportException { - return &tTransportException{typeId: t, err: errors.New(e)} -} - -func NewTTransportExceptionFromError(e error) TTransportException { - if e == nil { - return nil - } - - if t, ok := e.(TTransportException); ok { - return t - } - - switch v := e.(type) { - case TTransportException: - return v - case timeoutable: - if v.Timeout() { - return &tTransportException{typeId: TIMED_OUT, err: e} - } - } - - if e == io.EOF { - return &tTransportException{typeId: END_OF_FILE, err: e} - } - - return &tTransportException{typeId: UNKNOWN_TRANSPORT_EXCEPTION, err: e} -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go deleted file mode 100644 index b44314f..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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" - "io" - - "testing" -) - -type timeout struct{ timedout bool } - -func (t *timeout) Timeout() bool { - return t.timedout -} - -func (t *timeout) Error() string { - return fmt.Sprintf("Timeout: %v", t.timedout) -} - -func TestTExceptionTimeout(t *testing.T) { - timeout := &timeout{true} - exception := NewTTransportExceptionFromError(timeout) - if timeout.Error() != exception.Error() { - t.Fatalf("Error did not match: expected %q, got %q", timeout.Error(), exception.Error()) - } - - if exception.TypeId() != TIMED_OUT { - t.Fatalf("TypeId was not TIMED_OUT: expected %v, got %v", TIMED_OUT, exception.TypeId()) - } -} - -func TestTExceptionEOF(t *testing.T) { - exception := NewTTransportExceptionFromError(io.EOF) - if io.EOF.Error() != exception.Error() { - t.Fatalf("Error did not match: expected %q, got %q", io.EOF.Error(), exception.Error()) - } - - if exception.TypeId() != END_OF_FILE { - t.Fatalf("TypeId was not END_OF_FILE: expected %v, got %v", END_OF_FILE, exception.TypeId()) - } -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go deleted file mode 100644 index c805807..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 - -// Factory class used to create wrapped instance of Transports. -// This is used primarily in servers, which get Transports from -// a ServerTransport and then may want to mutate them (i.e. create -// a BufferedTransport from the underlying base transport) -type TTransportFactory interface { - GetTransport(trans TTransport) (TTransport, error) -} - -type tTransportFactory struct{} - -// Return a wrapped instance of the base Transport. -func (p *tTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - return trans, nil -} - -func NewTTransportFactory() TTransportFactory { - return &tTransportFactory{} -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go deleted file mode 100644 index 0127803..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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 ( - "context" - "io" - "net" - "strconv" - "testing" -) - -const TRANSPORT_BINARY_DATA_SIZE = 4096 - -var ( - transport_bdata []byte // test data for writing; same as data - transport_header map[string]string -) - -func init() { - transport_bdata = make([]byte, TRANSPORT_BINARY_DATA_SIZE) - for i := 0; i < TRANSPORT_BINARY_DATA_SIZE; i++ { - transport_bdata[i] = byte((i + 'a') % 255) - } - transport_header = map[string]string{"key": "User-Agent", - "value": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"} -} - -func TransportTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { - buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) - if !writeTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) - } - if !readTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", readTrans, readTrans) - } - _, err := writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush(context.Background()) - if err != nil { - t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) - } - n, err := io.ReadFull(readTrans, buf) - if err != nil { - t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } - _, err = writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data 2 of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush(context.Background()) - if err != nil { - t.Fatalf("Transport %T cannot flush write binary data 2: %s", writeTrans, err) - } - buf = make([]byte, TRANSPORT_BINARY_DATA_SIZE) - read := 1 - for n = 0; n < TRANSPORT_BINARY_DATA_SIZE && read != 0; { - read, err = readTrans.Read(buf[n:]) - if err != nil { - t.Errorf("Transport %T cannot read binary data 2 of total length %d from offset %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, n, err) - } - n += read - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data 2", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } -} - -func TransportHeaderTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { - buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) - if !writeTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) - } - if !readTrans.IsOpen() { - t.Fatalf("Transport %T not open: %s", readTrans, readTrans) - } - // Need to assert type of TTransport to THttpClient to expose the Setter - httpWPostTrans := writeTrans.(*THttpClient) - httpWPostTrans.SetHeader(transport_header["key"], transport_header["value"]) - - _, err := writeTrans.Write(transport_bdata) - if err != nil { - t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) - } - err = writeTrans.Flush(context.Background()) - if err != nil { - t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) - } - // Need to assert type of TTransport to THttpClient to expose the Getter - httpRPostTrans := readTrans.(*THttpClient) - readHeader := httpRPostTrans.GetHeader(transport_header["key"]) - if err != nil { - t.Errorf("Transport %T cannot read HTTP Header Value", httpRPostTrans) - } - - if transport_header["value"] != readHeader { - t.Errorf("Expected HTTP Header Value %s, got %s", transport_header["value"], readHeader) - } - n, err := io.ReadFull(readTrans, buf) - if err != nil { - t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) - } - if n != TRANSPORT_BINARY_DATA_SIZE { - t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) - } - for k, v := range buf { - if v != transport_bdata[k] { - t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) - } - } -} - -func CloseTransports(t *testing.T, readTrans TTransport, writeTrans TTransport) { - err := readTrans.Close() - if err != nil { - t.Errorf("Transport %T cannot close read transport: %s", readTrans, err) - } - if writeTrans != readTrans { - err = writeTrans.Close() - if err != nil { - t.Errorf("Transport %T cannot close write transport: %s", writeTrans, err) - } - } -} - -func FindAvailableTCPServerPort(startPort int) (net.Addr, error) { - for i := startPort; i < 65535; i++ { - s := "127.0.0.1:" + strconv.Itoa(i) - l, err := net.Listen("tcp", s) - if err == nil { - l.Close() - return net.ResolveTCPAddr("tcp", s) - } - } - return nil, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Could not find available server port") -} - -func valueInSlice(value string, slice []string) bool { - for _, v := range slice { - if value == v { - return true - } - } - return false -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/type.go b/vendor/github.com/apache/thrift/lib/go/thrift/type.go deleted file mode 100644 index 4292ffc..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/type.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - -// Type constants in the Thrift protocol -type TType byte - -const ( - STOP = 0 - VOID = 1 - BOOL = 2 - BYTE = 3 - I08 = 3 - DOUBLE = 4 - I16 = 6 - I32 = 8 - I64 = 10 - STRING = 11 - UTF7 = 11 - STRUCT = 12 - MAP = 13 - SET = 14 - LIST = 15 - UTF8 = 16 - UTF16 = 17 - //BINARY = 18 wrong and unusued -) - -var typeNames = map[int]string{ - STOP: "STOP", - VOID: "VOID", - BOOL: "BOOL", - BYTE: "BYTE", - DOUBLE: "DOUBLE", - I16: "I16", - I32: "I32", - I64: "I64", - STRING: "STRING", - STRUCT: "STRUCT", - MAP: "MAP", - SET: "SET", - LIST: "LIST", - UTF8: "UTF8", - UTF16: "UTF16", -} - -func (p TType) String() string { - if s, ok := typeNames[int(p)]; ok { - return s - } - return "Unknown" -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go deleted file mode 100644 index f3d4267..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go +++ /dev/null @@ -1,132 +0,0 @@ -/* -* 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 ( - "compress/zlib" - "context" - "io" - "log" -) - -// TZlibTransportFactory is a factory for TZlibTransport instances -type TZlibTransportFactory struct { - level int - factory TTransportFactory -} - -// TZlibTransport is a TTransport implementation that makes use of zlib compression. -type TZlibTransport struct { - reader io.ReadCloser - transport TTransport - writer *zlib.Writer -} - -// GetTransport constructs a new instance of NewTZlibTransport -func (p *TZlibTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - if p.factory != nil { - // wrap other factory - var err error - trans, err = p.factory.GetTransport(trans) - if err != nil { - return nil, err - } - } - return NewTZlibTransport(trans, p.level) -} - -// NewTZlibTransportFactory constructs a new instance of NewTZlibTransportFactory -func NewTZlibTransportFactory(level int) *TZlibTransportFactory { - return &TZlibTransportFactory{level: level, factory: nil} -} - -// NewTZlibTransportFactory constructs a new instance of TZlibTransportFactory -// as a wrapper over existing transport factory -func NewTZlibTransportFactoryWithFactory(level int, factory TTransportFactory) *TZlibTransportFactory { - return &TZlibTransportFactory{level: level, factory: factory} -} - -// NewTZlibTransport constructs a new instance of TZlibTransport -func NewTZlibTransport(trans TTransport, level int) (*TZlibTransport, error) { - w, err := zlib.NewWriterLevel(trans, level) - if err != nil { - log.Println(err) - return nil, err - } - - return &TZlibTransport{ - writer: w, - transport: trans, - }, nil -} - -// Close closes the reader and writer (flushing any unwritten data) and closes -// the underlying transport. -func (z *TZlibTransport) Close() error { - if z.reader != nil { - if err := z.reader.Close(); err != nil { - return err - } - } - if err := z.writer.Close(); err != nil { - return err - } - return z.transport.Close() -} - -// Flush flushes the writer and its underlying transport. -func (z *TZlibTransport) Flush(ctx context.Context) error { - if err := z.writer.Flush(); err != nil { - return err - } - return z.transport.Flush(ctx) -} - -// IsOpen returns true if the transport is open -func (z *TZlibTransport) IsOpen() bool { - return z.transport.IsOpen() -} - -// Open opens the transport for communication -func (z *TZlibTransport) Open() error { - return z.transport.Open() -} - -func (z *TZlibTransport) Read(p []byte) (int, error) { - if z.reader == nil { - r, err := zlib.NewReader(z.transport) - if err != nil { - return 0, NewTTransportExceptionFromError(err) - } - z.reader = r - } - - return z.reader.Read(p) -} - -// RemainingBytes returns the size in bytes of the data that is still to be -// read. -func (z *TZlibTransport) RemainingBytes() uint64 { - return z.transport.RemainingBytes() -} - -func (z *TZlibTransport) Write(p []byte) (int, error) { - return z.writer.Write(p) -} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go deleted file mode 100644 index 3c6f11e..0000000 --- a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 ( - "compress/zlib" - "testing" -) - -func TestZlibTransport(t *testing.T) { - trans, err := NewTZlibTransport(NewTMemoryBuffer(), zlib.BestCompression) - if err != nil { - t.Fatal(err) - } - TransportTest(t, trans, trans) -} - -type DummyTransportFactory struct{} - -func (p *DummyTransportFactory) GetTransport(trans TTransport) (TTransport, error) { - return NewTMemoryBuffer(), nil -} - -func TestZlibFactoryTransportWithFactory(t *testing.T) { - factory := NewTZlibTransportFactoryWithFactory( - zlib.BestCompression, - &DummyTransportFactory{}, - ) - buffer := NewTMemoryBuffer() - trans, err := factory.GetTransport(buffer) - if err != nil { - t.Fatal(err) - } - TransportTest(t, trans, trans) -} - -func TestZlibFactoryTransportWithoutFactory(t *testing.T) { - factory := NewTZlibTransportFactoryWithFactory(zlib.BestCompression, nil) - buffer := NewTMemoryBuffer() - trans, err := factory.GetTransport(buffer) - if err != nil { - t.Fatal(err) - } - TransportTest(t, trans, trans) -} diff --git a/vendor/github.com/davecgh/go-spew/.gitignore b/vendor/github.com/davecgh/go-spew/.gitignore deleted file mode 100644 index 0026861..0000000 --- a/vendor/github.com/davecgh/go-spew/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/davecgh/go-spew/.travis.yml b/vendor/github.com/davecgh/go-spew/.travis.yml deleted file mode 100644 index 1f4cbf5..0000000 --- a/vendor/github.com/davecgh/go-spew/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: go -go_import_path: github.com/davecgh/go-spew -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - tip -sudo: false -install: - - go get -v github.com/alecthomas/gometalinter - - gometalinter --install -script: - - export PATH=$PATH:$HOME/gopath/bin - - export GORACE="halt_on_error=1" - - test -z "$(gometalinter --disable-all - --enable=gofmt - --enable=golint - --enable=vet - --enable=gosimple - --enable=unconvert - --deadline=4m ./spew | tee /dev/stderr)" - - go test -v -race -tags safe ./spew - - go test -v -race -tags testcgo ./spew -covermode=atomic -coverprofile=profile.cov -after_success: - - go get -v github.com/mattn/goveralls - - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE deleted file mode 100644 index bc52e96..0000000 --- a/vendor/github.com/davecgh/go-spew/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -ISC License - -Copyright (c) 2012-2016 Dave Collins - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/davecgh/go-spew/README.md b/vendor/github.com/davecgh/go-spew/README.md deleted file mode 100644 index f6ed02c..0000000 --- a/vendor/github.com/davecgh/go-spew/README.md +++ /dev/null @@ -1,201 +0,0 @@ -go-spew -======= - -[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)](https://travis-ci.org/davecgh/go-spew) -[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![Coverage Status](https://img.shields.io/coveralls/davecgh/go-spew.svg)](https://coveralls.io/r/davecgh/go-spew?branch=master) - -Go-spew implements a deep pretty printer for Go data structures to aid in -debugging. A comprehensive suite of tests with 100% test coverage is provided -to ensure proper functionality. See `test_coverage.txt` for the gocov coverage -report. Go-spew is licensed under the liberal ISC license, so it may be used in -open source or commercial projects. - -If you're interested in reading about how this package came to life and some -of the challenges involved in providing a deep pretty printer, there is a blog -post about it -[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/). - -## Documentation - -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/davecgh/go-spew/spew) - -Full `go doc` style documentation for the project can be viewed online without -installing this package by using the excellent GoDoc site here: -http://godoc.org/github.com/davecgh/go-spew/spew - -You can also view the documentation locally once the package is installed with -the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to -http://localhost:6060/pkg/github.com/davecgh/go-spew/spew - -## Installation - -```bash -$ go get -u github.com/davecgh/go-spew/spew -``` - -## Quick Start - -Add this import line to the file you're working in: - -```Go -import "github.com/davecgh/go-spew/spew" -``` - -To dump a variable with full newlines, indentation, type, and pointer -information use Dump, Fdump, or Sdump: - -```Go -spew.Dump(myVar1, myVar2, ...) -spew.Fdump(someWriter, myVar1, myVar2, ...) -str := spew.Sdump(myVar1, myVar2, ...) -``` - -Alternatively, if you would prefer to use format strings with a compacted inline -printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most -compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types -and pointer addresses): - -```Go -spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) -spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) -spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) -spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) -``` - -## Debugging a Web Application Example - -Here is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production. - -```Go -package main - -import ( - "fmt" - "html" - "net/http" - - "github.com/davecgh/go-spew/spew" -) - -func handler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/html") - fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:]) - fmt.Fprintf(w, "") -} - -func main() { - http.HandleFunc("/", handler) - http.ListenAndServe(":8080", nil) -} -``` - -## Sample Dump Output - -``` -(main.Foo) { - unexportedField: (*main.Bar)(0xf84002e210)({ - flag: (main.Flag) flagTwo, - data: (uintptr) - }), - ExportedField: (map[interface {}]interface {}) { - (string) "one": (bool) true - } -} -([]uint8) { - 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | - 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| - 00000020 31 32 |12| -} -``` - -## Sample Formatter Output - -Double pointer to a uint8: -``` - %v: <**>5 - %+v: <**>(0xf8400420d0->0xf8400420c8)5 - %#v: (**uint8)5 - %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 -``` - -Pointer to circular struct with a uint8 field and a pointer to itself: -``` - %v: <*>{1 <*>} - %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} - %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} - %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} -``` - -## Configuration Options - -Configuration of spew is handled by fields in the ConfigState type. For -convenience, all of the top-level functions use a global state available via the -spew.Config global. - -It is also possible to create a ConfigState instance that provides methods -equivalent to the top-level functions. This allows concurrent configuration -options. See the ConfigState documentation for more details. - -``` -* Indent - String to use for each indentation level for Dump functions. - It is a single space by default. A popular alternative is "\t". - -* MaxDepth - Maximum number of levels to descend into nested data structures. - There is no limit by default. - -* DisableMethods - Disables invocation of error and Stringer interface methods. - Method invocation is enabled by default. - -* DisablePointerMethods - Disables invocation of error and Stringer interface methods on types - which only accept pointer receivers from non-pointer variables. This option - relies on access to the unsafe package, so it will not have any effect when - running in environments without access to the unsafe package such as Google - App Engine or with the "safe" build tag specified. - Pointer method invocation is enabled by default. - -* DisablePointerAddresses - DisablePointerAddresses specifies whether to disable the printing of - pointer addresses. This is useful when diffing data structures in tests. - -* DisableCapacities - DisableCapacities specifies whether to disable the printing of capacities - for arrays, slices, maps and channels. This is useful when diffing data - structures in tests. - -* ContinueOnMethod - Enables recursion into types after invoking error and Stringer interface - methods. Recursion after method invocation is disabled by default. - -* SortKeys - Specifies map keys should be sorted before being printed. Use - this to have a more deterministic, diffable output. Note that - only native types (bool, int, uint, floats, uintptr and string) - and types which implement error or Stringer interfaces are supported, - with other types sorted according to the reflect.Value.String() output - which guarantees display stability. Natural map order is used by - default. - -* SpewKeys - SpewKeys specifies that, as a last resort attempt, map keys should be - spewed to strings and sorted by those strings. This is only considered - if SortKeys is true. - -``` - -## Unsafe Package Dependency - -This package relies on the unsafe package to perform some of the more advanced -features, however it also supports a "limited" mode which allows it to work in -environments where the unsafe package is not available. By default, it will -operate in this mode on Google App Engine and when compiled with GopherJS. The -"safe" build tag may also be specified to force the package to build without -using the unsafe package. - -## License - -Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/vendor/github.com/davecgh/go-spew/cov_report.sh b/vendor/github.com/davecgh/go-spew/cov_report.sh deleted file mode 100644 index 9579497..0000000 --- a/vendor/github.com/davecgh/go-spew/cov_report.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# This script uses gocov to generate a test coverage report. -# The gocov tool my be obtained with the following command: -# go get github.com/axw/gocov/gocov -# -# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH. - -# Check for gocov. -if ! type gocov >/dev/null 2>&1; then - echo >&2 "This script requires the gocov tool." - echo >&2 "You may obtain it with the following command:" - echo >&2 "go get github.com/axw/gocov/gocov" - exit 1 -fi - -# Only run the cgo tests if gcc is installed. -if type gcc >/dev/null 2>&1; then - (cd spew && gocov test -tags testcgo | gocov report) -else - (cd spew && gocov test | gocov report) -fi diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go deleted file mode 100644 index 7929947..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/bypass.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) 2015-2016 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when the code is not running on Google App Engine, compiled by GopherJS, and -// "-tags safe" is not added to the go build command line. The "disableunsafe" -// tag is deprecated and thus should not be used. -// Go versions prior to 1.4 are disabled because they use a different layout -// for interfaces which make the implementation of unsafeReflectValue more complex. -// +build !js,!appengine,!safe,!disableunsafe,go1.4 - -package spew - -import ( - "reflect" - "unsafe" -) - -const ( - // UnsafeDisabled is a build-time constant which specifies whether or - // not access to the unsafe package is available. - UnsafeDisabled = false - - // ptrSize is the size of a pointer on the current arch. - ptrSize = unsafe.Sizeof((*byte)(nil)) -) - -type flag uintptr - -var ( - // flagRO indicates whether the value field of a reflect.Value - // is read-only. - flagRO flag - - // flagAddr indicates whether the address of the reflect.Value's - // value may be taken. - flagAddr flag -) - -// flagKindMask holds the bits that make up the kind -// part of the flags field. In all the supported versions, -// it is in the lower 5 bits. -const flagKindMask = flag(0x1f) - -// Different versions of Go have used different -// bit layouts for the flags type. This table -// records the known combinations. -var okFlags = []struct { - ro, addr flag -}{{ - // From Go 1.4 to 1.5 - ro: 1 << 5, - addr: 1 << 7, -}, { - // Up to Go tip. - ro: 1<<5 | 1<<6, - addr: 1 << 8, -}} - -var flagValOffset = func() uintptr { - field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") - if !ok { - panic("reflect.Value has no flag field") - } - return field.Offset -}() - -// flagField returns a pointer to the flag field of a reflect.Value. -func flagField(v *reflect.Value) *flag { - return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) -} - -// unsafeReflectValue converts the passed reflect.Value into a one that bypasses -// the typical safety restrictions preventing access to unaddressable and -// unexported data. It works by digging the raw pointer to the underlying -// value out of the protected value and generating a new unprotected (unsafe) -// reflect.Value to it. -// -// This allows us to check for implementations of the Stringer and error -// interfaces to be used for pretty printing ordinarily unaddressable and -// inaccessible values such as unexported struct fields. -func unsafeReflectValue(v reflect.Value) reflect.Value { - if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { - return v - } - flagFieldPtr := flagField(&v) - *flagFieldPtr &^= flagRO - *flagFieldPtr |= flagAddr - return v -} - -// Sanity checks against future reflect package changes -// to the type or semantics of the Value.flag field. -func init() { - field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") - if !ok { - panic("reflect.Value has no flag field") - } - if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { - panic("reflect.Value flag field has changed kind") - } - type t0 int - var t struct { - A t0 - // t0 will have flagEmbedRO set. - t0 - // a will have flagStickyRO set - a t0 - } - vA := reflect.ValueOf(t).FieldByName("A") - va := reflect.ValueOf(t).FieldByName("a") - vt0 := reflect.ValueOf(t).FieldByName("t0") - - // Infer flagRO from the difference between the flags - // for the (otherwise identical) fields in t. - flagPublic := *flagField(&vA) - flagWithRO := *flagField(&va) | *flagField(&vt0) - flagRO = flagPublic ^ flagWithRO - - // Infer flagAddr from the difference between a value - // taken from a pointer and not. - vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") - flagNoPtr := *flagField(&vA) - flagPtr := *flagField(&vPtrA) - flagAddr = flagNoPtr ^ flagPtr - - // Check that the inferred flags tally with one of the known versions. - for _, f := range okFlags { - if flagRO == f.ro && flagAddr == f.addr { - return - } - } - panic("reflect.Value read-only flag has changed semantics") -} diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go deleted file mode 100644 index 205c28d..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2015-2016 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when the code is running on Google App Engine, compiled by GopherJS, or -// "-tags safe" is added to the go build command line. The "disableunsafe" -// tag is deprecated and thus should not be used. -// +build js appengine safe disableunsafe !go1.4 - -package spew - -import "reflect" - -const ( - // UnsafeDisabled is a build-time constant which specifies whether or - // not access to the unsafe package is available. - UnsafeDisabled = true -) - -// unsafeReflectValue typically converts the passed reflect.Value into a one -// that bypasses the typical safety restrictions preventing access to -// unaddressable and unexported data. However, doing this relies on access to -// the unsafe package. This is a stub version which simply returns the passed -// reflect.Value when the unsafe package is not available. -func unsafeReflectValue(v reflect.Value) reflect.Value { - return v -} diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go deleted file mode 100644 index 1be8ce9..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/common.go +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "io" - "reflect" - "sort" - "strconv" -) - -// Some constants in the form of bytes to avoid string overhead. This mirrors -// the technique used in the fmt package. -var ( - panicBytes = []byte("(PANIC=") - plusBytes = []byte("+") - iBytes = []byte("i") - trueBytes = []byte("true") - falseBytes = []byte("false") - interfaceBytes = []byte("(interface {})") - commaNewlineBytes = []byte(",\n") - newlineBytes = []byte("\n") - openBraceBytes = []byte("{") - openBraceNewlineBytes = []byte("{\n") - closeBraceBytes = []byte("}") - asteriskBytes = []byte("*") - colonBytes = []byte(":") - colonSpaceBytes = []byte(": ") - openParenBytes = []byte("(") - closeParenBytes = []byte(")") - spaceBytes = []byte(" ") - pointerChainBytes = []byte("->") - nilAngleBytes = []byte("") - maxNewlineBytes = []byte("\n") - maxShortBytes = []byte("") - circularBytes = []byte("") - circularShortBytes = []byte("") - invalidAngleBytes = []byte("") - openBracketBytes = []byte("[") - closeBracketBytes = []byte("]") - percentBytes = []byte("%") - precisionBytes = []byte(".") - openAngleBytes = []byte("<") - closeAngleBytes = []byte(">") - openMapBytes = []byte("map[") - closeMapBytes = []byte("]") - lenEqualsBytes = []byte("len=") - capEqualsBytes = []byte("cap=") -) - -// hexDigits is used to map a decimal value to a hex digit. -var hexDigits = "0123456789abcdef" - -// catchPanic handles any panics that might occur during the handleMethods -// calls. -func catchPanic(w io.Writer, v reflect.Value) { - if err := recover(); err != nil { - w.Write(panicBytes) - fmt.Fprintf(w, "%v", err) - w.Write(closeParenBytes) - } -} - -// handleMethods attempts to call the Error and String methods on the underlying -// type the passed reflect.Value represents and outputes the result to Writer w. -// -// It handles panics in any called methods by catching and displaying the error -// as the formatted value. -func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { - // We need an interface to check if the type implements the error or - // Stringer interface. However, the reflect package won't give us an - // interface on certain things like unexported struct fields in order - // to enforce visibility rules. We use unsafe, when it's available, - // to bypass these restrictions since this package does not mutate the - // values. - if !v.CanInterface() { - if UnsafeDisabled { - return false - } - - v = unsafeReflectValue(v) - } - - // Choose whether or not to do error and Stringer interface lookups against - // the base type or a pointer to the base type depending on settings. - // Technically calling one of these methods with a pointer receiver can - // mutate the value, however, types which choose to satisify an error or - // Stringer interface with a pointer receiver should not be mutating their - // state inside these interface methods. - if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { - v = unsafeReflectValue(v) - } - if v.CanAddr() { - v = v.Addr() - } - - // Is it an error or Stringer? - switch iface := v.Interface().(type) { - case error: - defer catchPanic(w, v) - if cs.ContinueOnMethod { - w.Write(openParenBytes) - w.Write([]byte(iface.Error())) - w.Write(closeParenBytes) - w.Write(spaceBytes) - return false - } - - w.Write([]byte(iface.Error())) - return true - - case fmt.Stringer: - defer catchPanic(w, v) - if cs.ContinueOnMethod { - w.Write(openParenBytes) - w.Write([]byte(iface.String())) - w.Write(closeParenBytes) - w.Write(spaceBytes) - return false - } - w.Write([]byte(iface.String())) - return true - } - return false -} - -// printBool outputs a boolean value as true or false to Writer w. -func printBool(w io.Writer, val bool) { - if val { - w.Write(trueBytes) - } else { - w.Write(falseBytes) - } -} - -// printInt outputs a signed integer value to Writer w. -func printInt(w io.Writer, val int64, base int) { - w.Write([]byte(strconv.FormatInt(val, base))) -} - -// printUint outputs an unsigned integer value to Writer w. -func printUint(w io.Writer, val uint64, base int) { - w.Write([]byte(strconv.FormatUint(val, base))) -} - -// printFloat outputs a floating point value using the specified precision, -// which is expected to be 32 or 64bit, to Writer w. -func printFloat(w io.Writer, val float64, precision int) { - w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) -} - -// printComplex outputs a complex value using the specified float precision -// for the real and imaginary parts to Writer w. -func printComplex(w io.Writer, c complex128, floatPrecision int) { - r := real(c) - w.Write(openParenBytes) - w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) - i := imag(c) - if i >= 0 { - w.Write(plusBytes) - } - w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) - w.Write(iBytes) - w.Write(closeParenBytes) -} - -// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' -// prefix to Writer w. -func printHexPtr(w io.Writer, p uintptr) { - // Null pointer. - num := uint64(p) - if num == 0 { - w.Write(nilAngleBytes) - return - } - - // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix - buf := make([]byte, 18) - - // It's simpler to construct the hex string right to left. - base := uint64(16) - i := len(buf) - 1 - for num >= base { - buf[i] = hexDigits[num%base] - num /= base - i-- - } - buf[i] = hexDigits[num] - - // Add '0x' prefix. - i-- - buf[i] = 'x' - i-- - buf[i] = '0' - - // Strip unused leading bytes. - buf = buf[i:] - w.Write(buf) -} - -// valuesSorter implements sort.Interface to allow a slice of reflect.Value -// elements to be sorted. -type valuesSorter struct { - values []reflect.Value - strings []string // either nil or same len and values - cs *ConfigState -} - -// newValuesSorter initializes a valuesSorter instance, which holds a set of -// surrogate keys on which the data should be sorted. It uses flags in -// ConfigState to decide if and how to populate those surrogate keys. -func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { - vs := &valuesSorter{values: values, cs: cs} - if canSortSimply(vs.values[0].Kind()) { - return vs - } - if !cs.DisableMethods { - vs.strings = make([]string, len(values)) - for i := range vs.values { - b := bytes.Buffer{} - if !handleMethods(cs, &b, vs.values[i]) { - vs.strings = nil - break - } - vs.strings[i] = b.String() - } - } - if vs.strings == nil && cs.SpewKeys { - vs.strings = make([]string, len(values)) - for i := range vs.values { - vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) - } - } - return vs -} - -// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted -// directly, or whether it should be considered for sorting by surrogate keys -// (if the ConfigState allows it). -func canSortSimply(kind reflect.Kind) bool { - // This switch parallels valueSortLess, except for the default case. - switch kind { - case reflect.Bool: - return true - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - return true - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - return true - case reflect.Float32, reflect.Float64: - return true - case reflect.String: - return true - case reflect.Uintptr: - return true - case reflect.Array: - return true - } - return false -} - -// Len returns the number of values in the slice. It is part of the -// sort.Interface implementation. -func (s *valuesSorter) Len() int { - return len(s.values) -} - -// Swap swaps the values at the passed indices. It is part of the -// sort.Interface implementation. -func (s *valuesSorter) Swap(i, j int) { - s.values[i], s.values[j] = s.values[j], s.values[i] - if s.strings != nil { - s.strings[i], s.strings[j] = s.strings[j], s.strings[i] - } -} - -// valueSortLess returns whether the first value should sort before the second -// value. It is used by valueSorter.Less as part of the sort.Interface -// implementation. -func valueSortLess(a, b reflect.Value) bool { - switch a.Kind() { - case reflect.Bool: - return !a.Bool() && b.Bool() - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - return a.Int() < b.Int() - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - return a.Uint() < b.Uint() - case reflect.Float32, reflect.Float64: - return a.Float() < b.Float() - case reflect.String: - return a.String() < b.String() - case reflect.Uintptr: - return a.Uint() < b.Uint() - case reflect.Array: - // Compare the contents of both arrays. - l := a.Len() - for i := 0; i < l; i++ { - av := a.Index(i) - bv := b.Index(i) - if av.Interface() == bv.Interface() { - continue - } - return valueSortLess(av, bv) - } - } - return a.String() < b.String() -} - -// Less returns whether the value at index i should sort before the -// value at index j. It is part of the sort.Interface implementation. -func (s *valuesSorter) Less(i, j int) bool { - if s.strings == nil { - return valueSortLess(s.values[i], s.values[j]) - } - return s.strings[i] < s.strings[j] -} - -// sortValues is a sort function that handles both native types and any type that -// can be converted to error or Stringer. Other inputs are sorted according to -// their Value.String() value to ensure display stability. -func sortValues(values []reflect.Value, cs *ConfigState) { - if len(values) == 0 { - return - } - sort.Sort(newValuesSorter(values, cs)) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go deleted file mode 100644 index 0f5ce47..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/common_test.go +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "fmt" - "reflect" - "testing" - - "github.com/davecgh/go-spew/spew" -) - -// custom type to test Stinger interface on non-pointer receiver. -type stringer string - -// String implements the Stringer interface for testing invocation of custom -// stringers on types with non-pointer receivers. -func (s stringer) String() string { - return "stringer " + string(s) -} - -// custom type to test Stinger interface on pointer receiver. -type pstringer string - -// String implements the Stringer interface for testing invocation of custom -// stringers on types with only pointer receivers. -func (s *pstringer) String() string { - return "stringer " + string(*s) -} - -// xref1 and xref2 are cross referencing structs for testing circular reference -// detection. -type xref1 struct { - ps2 *xref2 -} -type xref2 struct { - ps1 *xref1 -} - -// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular -// reference for testing detection. -type indirCir1 struct { - ps2 *indirCir2 -} -type indirCir2 struct { - ps3 *indirCir3 -} -type indirCir3 struct { - ps1 *indirCir1 -} - -// embed is used to test embedded structures. -type embed struct { - a string -} - -// embedwrap is used to test embedded structures. -type embedwrap struct { - *embed - e *embed -} - -// panicer is used to intentionally cause a panic for testing spew properly -// handles them -type panicer int - -func (p panicer) String() string { - panic("test panic") -} - -// customError is used to test custom error interface invocation. -type customError int - -func (e customError) Error() string { - return fmt.Sprintf("error: %d", int(e)) -} - -// stringizeWants converts a slice of wanted test output into a format suitable -// for a test error message. -func stringizeWants(wants []string) string { - s := "" - for i, want := range wants { - if i > 0 { - s += fmt.Sprintf("want%d: %s", i+1, want) - } else { - s += "want: " + want - } - } - return s -} - -// testFailed returns whether or not a test failed by checking if the result -// of the test is in the slice of wanted strings. -func testFailed(result string, wants []string) bool { - for _, want := range wants { - if result == want { - return false - } - } - return true -} - -type sortableStruct struct { - x int -} - -func (ss sortableStruct) String() string { - return fmt.Sprintf("ss.%d", ss.x) -} - -type unsortableStruct struct { - x int -} - -type sortTestCase struct { - input []reflect.Value - expected []reflect.Value -} - -func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) { - getInterfaces := func(values []reflect.Value) []interface{} { - interfaces := []interface{}{} - for _, v := range values { - interfaces = append(interfaces, v.Interface()) - } - return interfaces - } - - for _, test := range tests { - spew.SortValues(test.input, cs) - // reflect.DeepEqual cannot really make sense of reflect.Value, - // probably because of all the pointer tricks. For instance, - // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{} - // instead. - input := getInterfaces(test.input) - expected := getInterfaces(test.expected) - if !reflect.DeepEqual(input, expected) { - t.Errorf("Sort mismatch:\n %v != %v", input, expected) - } - } -} - -// TestSortValues ensures the sort functionality for relect.Value based sorting -// works as intended. -func TestSortValues(t *testing.T) { - v := reflect.ValueOf - - a := v("a") - b := v("b") - c := v("c") - embedA := v(embed{"a"}) - embedB := v(embed{"b"}) - embedC := v(embed{"c"}) - tests := []sortTestCase{ - // No values. - { - []reflect.Value{}, - []reflect.Value{}, - }, - // Bools. - { - []reflect.Value{v(false), v(true), v(false)}, - []reflect.Value{v(false), v(false), v(true)}, - }, - // Ints. - { - []reflect.Value{v(2), v(1), v(3)}, - []reflect.Value{v(1), v(2), v(3)}, - }, - // Uints. - { - []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))}, - []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))}, - }, - // Floats. - { - []reflect.Value{v(2.0), v(1.0), v(3.0)}, - []reflect.Value{v(1.0), v(2.0), v(3.0)}, - }, - // Strings. - { - []reflect.Value{b, a, c}, - []reflect.Value{a, b, c}, - }, - // Array - { - []reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})}, - []reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})}, - }, - // Uintptrs. - { - []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))}, - []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))}, - }, - // SortableStructs. - { - // Note: not sorted - DisableMethods is set. - []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, - []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, - }, - // UnsortableStructs. - { - // Note: not sorted - SpewKeys is false. - []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, - []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, - }, - // Invalid. - { - []reflect.Value{embedB, embedA, embedC}, - []reflect.Value{embedB, embedA, embedC}, - }, - } - cs := spew.ConfigState{DisableMethods: true, SpewKeys: false} - helpTestSortValues(tests, &cs, t) -} - -// TestSortValuesWithMethods ensures the sort functionality for relect.Value -// based sorting works as intended when using string methods. -func TestSortValuesWithMethods(t *testing.T) { - v := reflect.ValueOf - - a := v("a") - b := v("b") - c := v("c") - tests := []sortTestCase{ - // Ints. - { - []reflect.Value{v(2), v(1), v(3)}, - []reflect.Value{v(1), v(2), v(3)}, - }, - // Strings. - { - []reflect.Value{b, a, c}, - []reflect.Value{a, b, c}, - }, - // SortableStructs. - { - []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, - []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, - }, - // UnsortableStructs. - { - // Note: not sorted - SpewKeys is false. - []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, - []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, - }, - } - cs := spew.ConfigState{DisableMethods: false, SpewKeys: false} - helpTestSortValues(tests, &cs, t) -} - -// TestSortValuesWithSpew ensures the sort functionality for relect.Value -// based sorting works as intended when using spew to stringify keys. -func TestSortValuesWithSpew(t *testing.T) { - v := reflect.ValueOf - - a := v("a") - b := v("b") - c := v("c") - tests := []sortTestCase{ - // Ints. - { - []reflect.Value{v(2), v(1), v(3)}, - []reflect.Value{v(1), v(2), v(3)}, - }, - // Strings. - { - []reflect.Value{b, a, c}, - []reflect.Value{a, b, c}, - }, - // SortableStructs. - { - []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, - []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, - }, - // UnsortableStructs. - { - []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, - []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})}, - }, - } - cs := spew.ConfigState{DisableMethods: true, SpewKeys: true} - helpTestSortValues(tests, &cs, t) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go deleted file mode 100644 index 2e3d22f..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/config.go +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "io" - "os" -) - -// ConfigState houses the configuration options used by spew to format and -// display values. There is a global instance, Config, that is used to control -// all top-level Formatter and Dump functionality. Each ConfigState instance -// provides methods equivalent to the top-level functions. -// -// The zero value for ConfigState provides no indentation. You would typically -// want to set it to a space or a tab. -// -// Alternatively, you can use NewDefaultConfig to get a ConfigState instance -// with default settings. See the documentation of NewDefaultConfig for default -// values. -type ConfigState struct { - // Indent specifies the string to use for each indentation level. The - // global config instance that all top-level functions use set this to a - // single space by default. If you would like more indentation, you might - // set this to a tab with "\t" or perhaps two spaces with " ". - Indent string - - // MaxDepth controls the maximum number of levels to descend into nested - // data structures. The default, 0, means there is no limit. - // - // NOTE: Circular data structures are properly detected, so it is not - // necessary to set this value unless you specifically want to limit deeply - // nested data structures. - MaxDepth int - - // DisableMethods specifies whether or not error and Stringer interfaces are - // invoked for types that implement them. - DisableMethods bool - - // DisablePointerMethods specifies whether or not to check for and invoke - // error and Stringer interfaces on types which only accept a pointer - // receiver when the current type is not a pointer. - // - // NOTE: This might be an unsafe action since calling one of these methods - // with a pointer receiver could technically mutate the value, however, - // in practice, types which choose to satisify an error or Stringer - // interface with a pointer receiver should not be mutating their state - // inside these interface methods. As a result, this option relies on - // access to the unsafe package, so it will not have any effect when - // running in environments without access to the unsafe package such as - // Google App Engine or with the "safe" build tag specified. - DisablePointerMethods bool - - // DisablePointerAddresses specifies whether to disable the printing of - // pointer addresses. This is useful when diffing data structures in tests. - DisablePointerAddresses bool - - // DisableCapacities specifies whether to disable the printing of capacities - // for arrays, slices, maps and channels. This is useful when diffing - // data structures in tests. - DisableCapacities bool - - // ContinueOnMethod specifies whether or not recursion should continue once - // a custom error or Stringer interface is invoked. The default, false, - // means it will print the results of invoking the custom error or Stringer - // interface and return immediately instead of continuing to recurse into - // the internals of the data type. - // - // NOTE: This flag does not have any effect if method invocation is disabled - // via the DisableMethods or DisablePointerMethods options. - ContinueOnMethod bool - - // SortKeys specifies map keys should be sorted before being printed. Use - // this to have a more deterministic, diffable output. Note that only - // native types (bool, int, uint, floats, uintptr and string) and types - // that support the error or Stringer interfaces (if methods are - // enabled) are supported, with other types sorted according to the - // reflect.Value.String() output which guarantees display stability. - SortKeys bool - - // SpewKeys specifies that, as a last resort attempt, map keys should - // be spewed to strings and sorted by those strings. This is only - // considered if SortKeys is true. - SpewKeys bool -} - -// Config is the active configuration of the top-level functions. -// The configuration can be changed by modifying the contents of spew.Config. -var Config = ConfigState{Indent: " "} - -// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the formatted string as a value that satisfies error. See NewFormatter -// for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { - return fmt.Errorf(format, c.convertArgs(a)...) -} - -// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprint(w, c.convertArgs(a)...) -} - -// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { - return fmt.Fprintf(w, format, c.convertArgs(a)...) -} - -// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it -// passed with a Formatter interface returned by c.NewFormatter. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprintln(w, c.convertArgs(a)...) -} - -// Print is a wrapper for fmt.Print that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Print(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Print(a ...interface{}) (n int, err error) { - return fmt.Print(c.convertArgs(a)...) -} - -// Printf is a wrapper for fmt.Printf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { - return fmt.Printf(format, c.convertArgs(a)...) -} - -// Println is a wrapper for fmt.Println that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Println(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Println(a ...interface{}) (n int, err error) { - return fmt.Println(c.convertArgs(a)...) -} - -// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprint(a ...interface{}) string { - return fmt.Sprint(c.convertArgs(a)...) -} - -// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were -// passed with a Formatter interface returned by c.NewFormatter. It returns -// the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprintf(format string, a ...interface{}) string { - return fmt.Sprintf(format, c.convertArgs(a)...) -} - -// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it -// were passed with a Formatter interface returned by c.NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b)) -func (c *ConfigState) Sprintln(a ...interface{}) string { - return fmt.Sprintln(c.convertArgs(a)...) -} - -/* -NewFormatter returns a custom formatter that satisfies the fmt.Formatter -interface. As a result, it integrates cleanly with standard fmt package -printing functions. The formatter is useful for inline printing of smaller data -types similar to the standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Typically this function shouldn't be called directly. It is much easier to make -use of the custom formatter by calling one of the convenience functions such as -c.Printf, c.Println, or c.Printf. -*/ -func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { - return newFormatter(c, v) -} - -// Fdump formats and displays the passed arguments to io.Writer w. It formats -// exactly the same as Dump. -func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { - fdump(c, w, a...) -} - -/* -Dump displays the passed parameters to standard out with newlines, customizable -indentation, and additional debug information such as complete types and all -pointer addresses used to indirect to the final value. It provides the -following features over the built-in printing facilities provided by the fmt -package: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output - -The configuration options are controlled by modifying the public members -of c. See ConfigState for options documentation. - -See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to -get the formatted result as a string. -*/ -func (c *ConfigState) Dump(a ...interface{}) { - fdump(c, os.Stdout, a...) -} - -// Sdump returns a string with the passed arguments formatted exactly the same -// as Dump. -func (c *ConfigState) Sdump(a ...interface{}) string { - var buf bytes.Buffer - fdump(c, &buf, a...) - return buf.String() -} - -// convertArgs accepts a slice of arguments and returns a slice of the same -// length with each argument converted to a spew Formatter interface using -// the ConfigState associated with s. -func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { - formatters = make([]interface{}, len(args)) - for index, arg := range args { - formatters[index] = newFormatter(c, arg) - } - return formatters -} - -// NewDefaultConfig returns a ConfigState with the following default settings. -// -// Indent: " " -// MaxDepth: 0 -// DisableMethods: false -// DisablePointerMethods: false -// ContinueOnMethod: false -// SortKeys: false -func NewDefaultConfig() *ConfigState { - return &ConfigState{Indent: " "} -} diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go deleted file mode 100644 index aacaac6..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/doc.go +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Package spew implements a deep pretty printer for Go data structures to aid in -debugging. - -A quick overview of the additional features spew provides over the built-in -printing facilities for Go data types are as follows: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output (only when using - Dump style) - -There are two different approaches spew allows for dumping Go data structures: - - * Dump style which prints with newlines, customizable indentation, - and additional debug information such as types and all pointer addresses - used to indirect to the final value - * A custom Formatter interface that integrates cleanly with the standard fmt - package and replaces %v, %+v, %#v, and %#+v to provide inline printing - similar to the default %v while providing the additional functionality - outlined above and passing unsupported format verbs such as %x and %q - along to fmt - -Quick Start - -This section demonstrates how to quickly get started with spew. See the -sections below for further details on formatting and configuration options. - -To dump a variable with full newlines, indentation, type, and pointer -information use Dump, Fdump, or Sdump: - spew.Dump(myVar1, myVar2, ...) - spew.Fdump(someWriter, myVar1, myVar2, ...) - str := spew.Sdump(myVar1, myVar2, ...) - -Alternatively, if you would prefer to use format strings with a compacted inline -printing style, use the convenience wrappers Printf, Fprintf, etc with -%v (most compact), %+v (adds pointer addresses), %#v (adds types), or -%#+v (adds types and pointer addresses): - spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - -Configuration Options - -Configuration of spew is handled by fields in the ConfigState type. For -convenience, all of the top-level functions use a global state available -via the spew.Config global. - -It is also possible to create a ConfigState instance that provides methods -equivalent to the top-level functions. This allows concurrent configuration -options. See the ConfigState documentation for more details. - -The following configuration options are available: - * Indent - String to use for each indentation level for Dump functions. - It is a single space by default. A popular alternative is "\t". - - * MaxDepth - Maximum number of levels to descend into nested data structures. - There is no limit by default. - - * DisableMethods - Disables invocation of error and Stringer interface methods. - Method invocation is enabled by default. - - * DisablePointerMethods - Disables invocation of error and Stringer interface methods on types - which only accept pointer receivers from non-pointer variables. - Pointer method invocation is enabled by default. - - * DisablePointerAddresses - DisablePointerAddresses specifies whether to disable the printing of - pointer addresses. This is useful when diffing data structures in tests. - - * DisableCapacities - DisableCapacities specifies whether to disable the printing of - capacities for arrays, slices, maps and channels. This is useful when - diffing data structures in tests. - - * ContinueOnMethod - Enables recursion into types after invoking error and Stringer interface - methods. Recursion after method invocation is disabled by default. - - * SortKeys - Specifies map keys should be sorted before being printed. Use - this to have a more deterministic, diffable output. Note that - only native types (bool, int, uint, floats, uintptr and string) - and types which implement error or Stringer interfaces are - supported with other types sorted according to the - reflect.Value.String() output which guarantees display - stability. Natural map order is used by default. - - * SpewKeys - Specifies that, as a last resort attempt, map keys should be - spewed to strings and sorted by those strings. This is only - considered if SortKeys is true. - -Dump Usage - -Simply call spew.Dump with a list of variables you want to dump: - - spew.Dump(myVar1, myVar2, ...) - -You may also call spew.Fdump if you would prefer to output to an arbitrary -io.Writer. For example, to dump to standard error: - - spew.Fdump(os.Stderr, myVar1, myVar2, ...) - -A third option is to call spew.Sdump to get the formatted output as a string: - - str := spew.Sdump(myVar1, myVar2, ...) - -Sample Dump Output - -See the Dump example for details on the setup of the types and variables being -shown here. - - (main.Foo) { - unexportedField: (*main.Bar)(0xf84002e210)({ - flag: (main.Flag) flagTwo, - data: (uintptr) - }), - ExportedField: (map[interface {}]interface {}) (len=1) { - (string) (len=3) "one": (bool) true - } - } - -Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C -command as shown. - ([]uint8) (len=32 cap=32) { - 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | - 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| - 00000020 31 32 |12| - } - -Custom Formatter - -Spew provides a custom formatter that implements the fmt.Formatter interface -so that it integrates cleanly with standard fmt package printing functions. The -formatter is useful for inline printing of smaller data types similar to the -standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Custom Formatter Usage - -The simplest way to make use of the spew custom formatter is to call one of the -convenience functions such as spew.Printf, spew.Println, or spew.Printf. The -functions have syntax you are most likely already familiar with: - - spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - spew.Println(myVar, myVar2) - spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) - spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) - -See the Index for the full list convenience functions. - -Sample Formatter Output - -Double pointer to a uint8: - %v: <**>5 - %+v: <**>(0xf8400420d0->0xf8400420c8)5 - %#v: (**uint8)5 - %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 - -Pointer to circular struct with a uint8 field and a pointer to itself: - %v: <*>{1 <*>} - %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} - %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} - %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} - -See the Printf example for details on the setup of variables being shown -here. - -Errors - -Since it is possible for custom Stringer/error interfaces to panic, spew -detects them and handles them internally by printing the panic information -inline with the output. Since spew is intended to provide deep pretty printing -capabilities on structures, it intentionally does not return any errors. -*/ -package spew diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go deleted file mode 100644 index f78d89f..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/dump.go +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "encoding/hex" - "fmt" - "io" - "os" - "reflect" - "regexp" - "strconv" - "strings" -) - -var ( - // uint8Type is a reflect.Type representing a uint8. It is used to - // convert cgo types to uint8 slices for hexdumping. - uint8Type = reflect.TypeOf(uint8(0)) - - // cCharRE is a regular expression that matches a cgo char. - // It is used to detect character arrays to hexdump them. - cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`) - - // cUnsignedCharRE is a regular expression that matches a cgo unsigned - // char. It is used to detect unsigned character arrays to hexdump - // them. - cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`) - - // cUint8tCharRE is a regular expression that matches a cgo uint8_t. - // It is used to detect uint8_t arrays to hexdump them. - cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`) -) - -// dumpState contains information about the state of a dump operation. -type dumpState struct { - w io.Writer - depth int - pointers map[uintptr]int - ignoreNextType bool - ignoreNextIndent bool - cs *ConfigState -} - -// indent performs indentation according to the depth level and cs.Indent -// option. -func (d *dumpState) indent() { - if d.ignoreNextIndent { - d.ignoreNextIndent = false - return - } - d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) -} - -// unpackValue returns values inside of non-nil interfaces when possible. -// This is useful for data types like structs, arrays, slices, and maps which -// can contain varying types packed inside an interface. -func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Interface && !v.IsNil() { - v = v.Elem() - } - return v -} - -// dumpPtr handles formatting of pointers by indirecting them as necessary. -func (d *dumpState) dumpPtr(v reflect.Value) { - // Remove pointers at or below the current depth from map used to detect - // circular refs. - for k, depth := range d.pointers { - if depth >= d.depth { - delete(d.pointers, k) - } - } - - // Keep list of all dereferenced pointers to show later. - pointerChain := make([]uintptr, 0) - - // Figure out how many levels of indirection there are by dereferencing - // pointers and unpacking interfaces down the chain while detecting circular - // references. - nilFound := false - cycleFound := false - indirects := 0 - ve := v - for ve.Kind() == reflect.Ptr { - if ve.IsNil() { - nilFound = true - break - } - indirects++ - addr := ve.Pointer() - pointerChain = append(pointerChain, addr) - if pd, ok := d.pointers[addr]; ok && pd < d.depth { - cycleFound = true - indirects-- - break - } - d.pointers[addr] = d.depth - - ve = ve.Elem() - if ve.Kind() == reflect.Interface { - if ve.IsNil() { - nilFound = true - break - } - ve = ve.Elem() - } - } - - // Display type information. - d.w.Write(openParenBytes) - d.w.Write(bytes.Repeat(asteriskBytes, indirects)) - d.w.Write([]byte(ve.Type().String())) - d.w.Write(closeParenBytes) - - // Display pointer information. - if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { - d.w.Write(openParenBytes) - for i, addr := range pointerChain { - if i > 0 { - d.w.Write(pointerChainBytes) - } - printHexPtr(d.w, addr) - } - d.w.Write(closeParenBytes) - } - - // Display dereferenced value. - d.w.Write(openParenBytes) - switch { - case nilFound: - d.w.Write(nilAngleBytes) - - case cycleFound: - d.w.Write(circularBytes) - - default: - d.ignoreNextType = true - d.dump(ve) - } - d.w.Write(closeParenBytes) -} - -// dumpSlice handles formatting of arrays and slices. Byte (uint8 under -// reflection) arrays and slices are dumped in hexdump -C fashion. -func (d *dumpState) dumpSlice(v reflect.Value) { - // Determine whether this type should be hex dumped or not. Also, - // for types which should be hexdumped, try to use the underlying data - // first, then fall back to trying to convert them to a uint8 slice. - var buf []uint8 - doConvert := false - doHexDump := false - numEntries := v.Len() - if numEntries > 0 { - vt := v.Index(0).Type() - vts := vt.String() - switch { - // C types that need to be converted. - case cCharRE.MatchString(vts): - fallthrough - case cUnsignedCharRE.MatchString(vts): - fallthrough - case cUint8tCharRE.MatchString(vts): - doConvert = true - - // Try to use existing uint8 slices and fall back to converting - // and copying if that fails. - case vt.Kind() == reflect.Uint8: - // We need an addressable interface to convert the type - // to a byte slice. However, the reflect package won't - // give us an interface on certain things like - // unexported struct fields in order to enforce - // visibility rules. We use unsafe, when available, to - // bypass these restrictions since this package does not - // mutate the values. - vs := v - if !vs.CanInterface() || !vs.CanAddr() { - vs = unsafeReflectValue(vs) - } - if !UnsafeDisabled { - vs = vs.Slice(0, numEntries) - - // Use the existing uint8 slice if it can be - // type asserted. - iface := vs.Interface() - if slice, ok := iface.([]uint8); ok { - buf = slice - doHexDump = true - break - } - } - - // The underlying data needs to be converted if it can't - // be type asserted to a uint8 slice. - doConvert = true - } - - // Copy and convert the underlying type if needed. - if doConvert && vt.ConvertibleTo(uint8Type) { - // Convert and copy each element into a uint8 byte - // slice. - buf = make([]uint8, numEntries) - for i := 0; i < numEntries; i++ { - vv := v.Index(i) - buf[i] = uint8(vv.Convert(uint8Type).Uint()) - } - doHexDump = true - } - } - - // Hexdump the entire slice as needed. - if doHexDump { - indent := strings.Repeat(d.cs.Indent, d.depth) - str := indent + hex.Dump(buf) - str = strings.Replace(str, "\n", "\n"+indent, -1) - str = strings.TrimRight(str, d.cs.Indent) - d.w.Write([]byte(str)) - return - } - - // Recursively call dump for each item. - for i := 0; i < numEntries; i++ { - d.dump(d.unpackValue(v.Index(i))) - if i < (numEntries - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } -} - -// dump is the main workhorse for dumping a value. It uses the passed reflect -// value to figure out what kind of object we are dealing with and formats it -// appropriately. It is a recursive function, however circular data structures -// are detected and handled properly. -func (d *dumpState) dump(v reflect.Value) { - // Handle invalid reflect values immediately. - kind := v.Kind() - if kind == reflect.Invalid { - d.w.Write(invalidAngleBytes) - return - } - - // Handle pointers specially. - if kind == reflect.Ptr { - d.indent() - d.dumpPtr(v) - return - } - - // Print type information unless already handled elsewhere. - if !d.ignoreNextType { - d.indent() - d.w.Write(openParenBytes) - d.w.Write([]byte(v.Type().String())) - d.w.Write(closeParenBytes) - d.w.Write(spaceBytes) - } - d.ignoreNextType = false - - // Display length and capacity if the built-in len and cap functions - // work with the value's kind and the len/cap itself is non-zero. - valueLen, valueCap := 0, 0 - switch v.Kind() { - case reflect.Array, reflect.Slice, reflect.Chan: - valueLen, valueCap = v.Len(), v.Cap() - case reflect.Map, reflect.String: - valueLen = v.Len() - } - if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { - d.w.Write(openParenBytes) - if valueLen != 0 { - d.w.Write(lenEqualsBytes) - printInt(d.w, int64(valueLen), 10) - } - if !d.cs.DisableCapacities && valueCap != 0 { - if valueLen != 0 { - d.w.Write(spaceBytes) - } - d.w.Write(capEqualsBytes) - printInt(d.w, int64(valueCap), 10) - } - d.w.Write(closeParenBytes) - d.w.Write(spaceBytes) - } - - // Call Stringer/error interfaces if they exist and the handle methods flag - // is enabled - if !d.cs.DisableMethods { - if (kind != reflect.Invalid) && (kind != reflect.Interface) { - if handled := handleMethods(d.cs, d.w, v); handled { - return - } - } - } - - switch kind { - case reflect.Invalid: - // Do nothing. We should never get here since invalid has already - // been handled above. - - case reflect.Bool: - printBool(d.w, v.Bool()) - - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - printInt(d.w, v.Int(), 10) - - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - printUint(d.w, v.Uint(), 10) - - case reflect.Float32: - printFloat(d.w, v.Float(), 32) - - case reflect.Float64: - printFloat(d.w, v.Float(), 64) - - case reflect.Complex64: - printComplex(d.w, v.Complex(), 32) - - case reflect.Complex128: - printComplex(d.w, v.Complex(), 64) - - case reflect.Slice: - if v.IsNil() { - d.w.Write(nilAngleBytes) - break - } - fallthrough - - case reflect.Array: - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - d.dumpSlice(v) - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.String: - d.w.Write([]byte(strconv.Quote(v.String()))) - - case reflect.Interface: - // The only time we should get here is for nil interfaces due to - // unpackValue calls. - if v.IsNil() { - d.w.Write(nilAngleBytes) - } - - case reflect.Ptr: - // Do nothing. We should never get here since pointers have already - // been handled above. - - case reflect.Map: - // nil maps should be indicated as different than empty maps - if v.IsNil() { - d.w.Write(nilAngleBytes) - break - } - - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - numEntries := v.Len() - keys := v.MapKeys() - if d.cs.SortKeys { - sortValues(keys, d.cs) - } - for i, key := range keys { - d.dump(d.unpackValue(key)) - d.w.Write(colonSpaceBytes) - d.ignoreNextIndent = true - d.dump(d.unpackValue(v.MapIndex(key))) - if i < (numEntries - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.Struct: - d.w.Write(openBraceNewlineBytes) - d.depth++ - if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { - d.indent() - d.w.Write(maxNewlineBytes) - } else { - vt := v.Type() - numFields := v.NumField() - for i := 0; i < numFields; i++ { - d.indent() - vtf := vt.Field(i) - d.w.Write([]byte(vtf.Name)) - d.w.Write(colonSpaceBytes) - d.ignoreNextIndent = true - d.dump(d.unpackValue(v.Field(i))) - if i < (numFields - 1) { - d.w.Write(commaNewlineBytes) - } else { - d.w.Write(newlineBytes) - } - } - } - d.depth-- - d.indent() - d.w.Write(closeBraceBytes) - - case reflect.Uintptr: - printHexPtr(d.w, uintptr(v.Uint())) - - case reflect.UnsafePointer, reflect.Chan, reflect.Func: - printHexPtr(d.w, v.Pointer()) - - // There were not any other types at the time this code was written, but - // fall back to letting the default fmt package handle it in case any new - // types are added. - default: - if v.CanInterface() { - fmt.Fprintf(d.w, "%v", v.Interface()) - } else { - fmt.Fprintf(d.w, "%v", v.String()) - } - } -} - -// fdump is a helper function to consolidate the logic from the various public -// methods which take varying writers and config states. -func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { - for _, arg := range a { - if arg == nil { - w.Write(interfaceBytes) - w.Write(spaceBytes) - w.Write(nilAngleBytes) - w.Write(newlineBytes) - continue - } - - d := dumpState{w: w, cs: cs} - d.pointers = make(map[uintptr]int) - d.dump(reflect.ValueOf(arg)) - d.w.Write(newlineBytes) - } -} - -// Fdump formats and displays the passed arguments to io.Writer w. It formats -// exactly the same as Dump. -func Fdump(w io.Writer, a ...interface{}) { - fdump(&Config, w, a...) -} - -// Sdump returns a string with the passed arguments formatted exactly the same -// as Dump. -func Sdump(a ...interface{}) string { - var buf bytes.Buffer - fdump(&Config, &buf, a...) - return buf.String() -} - -/* -Dump displays the passed parameters to standard out with newlines, customizable -indentation, and additional debug information such as complete types and all -pointer addresses used to indirect to the final value. It provides the -following features over the built-in printing facilities provided by the fmt -package: - - * Pointers are dereferenced and followed - * Circular data structures are detected and handled properly - * Custom Stringer/error interfaces are optionally invoked, including - on unexported types - * Custom types which only implement the Stringer/error interfaces via - a pointer receiver are optionally invoked when passing non-pointer - variables - * Byte arrays and slices are dumped like the hexdump -C command which - includes offsets, byte values in hex, and ASCII output - -The configuration options are controlled by an exported package global, -spew.Config. See ConfigState for options documentation. - -See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to -get the formatted result as a string. -*/ -func Dump(a ...interface{}) { - fdump(&Config, os.Stdout, a...) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dump_test.go b/vendor/github.com/davecgh/go-spew/spew/dump_test.go deleted file mode 100644 index 4a31a2e..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/dump_test.go +++ /dev/null @@ -1,1042 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Test Summary: -NOTE: For each test, a nil pointer, a single pointer and double pointer to the -base test element are also tested to ensure proper indirection across all types. - -- Max int8, int16, int32, int64, int -- Max uint8, uint16, uint32, uint64, uint -- Boolean true and false -- Standard complex64 and complex128 -- Array containing standard ints -- Array containing type with custom formatter on pointer receiver only -- Array containing interfaces -- Array containing bytes -- Slice containing standard float32 values -- Slice containing type with custom formatter on pointer receiver only -- Slice containing interfaces -- Slice containing bytes -- Nil slice -- Standard string -- Nil interface -- Sub-interface -- Map with string keys and int vals -- Map with custom formatter type on pointer receiver only keys and vals -- Map with interface keys and values -- Map with nil interface value -- Struct with primitives -- Struct that contains another struct -- Struct that contains custom type with Stringer pointer interface via both - exported and unexported fields -- Struct that contains embedded struct and field to same struct -- Uintptr to 0 (null pointer) -- Uintptr address of real variable -- Unsafe.Pointer to 0 (null pointer) -- Unsafe.Pointer to address of real variable -- Nil channel -- Standard int channel -- Function with no params and no returns -- Function with param and no returns -- Function with multiple params and multiple returns -- Struct that is circular through self referencing -- Structs that are circular through cross referencing -- Structs that are indirectly circular -- Type that panics in its Stringer interface -*/ - -package spew_test - -import ( - "bytes" - "fmt" - "testing" - "unsafe" - - "github.com/davecgh/go-spew/spew" -) - -// dumpTest is used to describe a test to be performed against the Dump method. -type dumpTest struct { - in interface{} - wants []string -} - -// dumpTests houses all of the tests to be performed against the Dump method. -var dumpTests = make([]dumpTest, 0) - -// addDumpTest is a helper method to append the passed input and desired result -// to dumpTests -func addDumpTest(in interface{}, wants ...string) { - test := dumpTest{in, wants} - dumpTests = append(dumpTests, test) -} - -func addIntDumpTests() { - // Max int8. - v := int8(127) - nv := (*int8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int8" - vs := "127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Max int16. - v2 := int16(32767) - nv2 := (*int16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "int16" - v2s := "32767" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Max int32. - v3 := int32(2147483647) - nv3 := (*int32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "int32" - v3s := "2147483647" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Max int64. - v4 := int64(9223372036854775807) - nv4 := (*int64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "int64" - v4s := "9223372036854775807" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Max int. - v5 := int(2147483647) - nv5 := (*int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "int" - v5s := "2147483647" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addUintDumpTests() { - // Max uint8. - v := uint8(255) - nv := (*uint8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uint8" - vs := "255" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Max uint16. - v2 := uint16(65535) - nv2 := (*uint16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Max uint32. - v3 := uint32(4294967295) - nv3 := (*uint32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "uint32" - v3s := "4294967295" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Max uint64. - v4 := uint64(18446744073709551615) - nv4 := (*uint64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "uint64" - v4s := "18446744073709551615" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Max uint. - v5 := uint(4294967295) - nv5 := (*uint)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "uint" - v5s := "4294967295" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addBoolDumpTests() { - // Boolean true. - v := bool(true) - nv := (*bool)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "bool" - vs := "true" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Boolean false. - v2 := bool(false) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "bool" - v2s := "false" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addFloatDumpTests() { - // Standard float32. - v := float32(3.1415) - nv := (*float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "3.1415" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Standard float64. - v2 := float64(3.1415926) - nv2 := (*float64)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "float64" - v2s := "3.1415926" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addComplexDumpTests() { - // Standard complex64. - v := complex(float32(6), -2) - nv := (*complex64)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "complex64" - vs := "(6-2i)" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Standard complex128. - v2 := complex(float64(-6), 2) - nv2 := (*complex128)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "complex128" - v2s := "(-6+2i)" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addArrayDumpTests() { - // Array containing standard ints. - v := [3]int{1, 2, 3} - vLen := fmt.Sprintf("%d", len(v)) - vCap := fmt.Sprintf("%d", cap(v)) - nv := (*[3]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int" - vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 1,\n (" + - vt + ") 2,\n (" + vt + ") 3\n}" - addDumpTest(v, "([3]"+vt+") "+vs+"\n") - addDumpTest(pv, "(*[3]"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**[3]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*[3]"+vt+")()\n") - - // Array containing type with custom formatter on pointer receiver only. - v2i0 := pstringer("1") - v2i1 := pstringer("2") - v2i2 := pstringer("3") - v2 := [3]pstringer{v2i0, v2i1, v2i2} - v2i0Len := fmt.Sprintf("%d", len(v2i0)) - v2i1Len := fmt.Sprintf("%d", len(v2i1)) - v2i2Len := fmt.Sprintf("%d", len(v2i2)) - v2Len := fmt.Sprintf("%d", len(v2)) - v2Cap := fmt.Sprintf("%d", cap(v2)) - nv2 := (*[3]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.pstringer" - v2sp := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + - ") (len=" + v2i0Len + ") stringer 1,\n (" + v2t + - ") (len=" + v2i1Len + ") stringer 2,\n (" + v2t + - ") (len=" + v2i2Len + ") " + "stringer 3\n}" - v2s := v2sp - if spew.UnsafeDisabled { - v2s = "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + - ") (len=" + v2i0Len + ") \"1\",\n (" + v2t + ") (len=" + - v2i1Len + ") \"2\",\n (" + v2t + ") (len=" + v2i2Len + - ") " + "\"3\"\n}" - } - addDumpTest(v2, "([3]"+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*[3]"+v2t+")("+v2Addr+")("+v2sp+")\n") - addDumpTest(&pv2, "(**[3]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2sp+")\n") - addDumpTest(nv2, "(*[3]"+v2t+")()\n") - - // Array containing interfaces. - v3i0 := "one" - v3 := [3]interface{}{v3i0, int(2), uint(3)} - v3i0Len := fmt.Sprintf("%d", len(v3i0)) - v3Len := fmt.Sprintf("%d", len(v3)) - v3Cap := fmt.Sprintf("%d", cap(v3)) - nv3 := (*[3]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[3]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + - "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + - v3t4 + ") 3\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Array containing bytes. - v4 := [34]byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - v4Len := fmt.Sprintf("%d", len(v4)) - v4Cap := fmt.Sprintf("%d", cap(v4)) - nv4 := (*[34]byte)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[34]uint8" - v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + - "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + - " |............... |\n" + - " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + - " |!\"#$%&'()*+,-./0|\n" + - " 00000020 31 32 " + - " |12|\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") -} - -func addSliceDumpTests() { - // Slice containing standard float32 values. - v := []float32{3.14, 6.28, 12.56} - vLen := fmt.Sprintf("%d", len(v)) - vCap := fmt.Sprintf("%d", cap(v)) - nv := (*[]float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 3.14,\n (" + - vt + ") 6.28,\n (" + vt + ") 12.56\n}" - addDumpTest(v, "([]"+vt+") "+vs+"\n") - addDumpTest(pv, "(*[]"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**[]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*[]"+vt+")()\n") - - // Slice containing type with custom formatter on pointer receiver only. - v2i0 := pstringer("1") - v2i1 := pstringer("2") - v2i2 := pstringer("3") - v2 := []pstringer{v2i0, v2i1, v2i2} - v2i0Len := fmt.Sprintf("%d", len(v2i0)) - v2i1Len := fmt.Sprintf("%d", len(v2i1)) - v2i2Len := fmt.Sprintf("%d", len(v2i2)) - v2Len := fmt.Sprintf("%d", len(v2)) - v2Cap := fmt.Sprintf("%d", cap(v2)) - nv2 := (*[]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.pstringer" - v2s := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + ") (len=" + - v2i0Len + ") stringer 1,\n (" + v2t + ") (len=" + v2i1Len + - ") stringer 2,\n (" + v2t + ") (len=" + v2i2Len + ") " + - "stringer 3\n}" - addDumpTest(v2, "([]"+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*[]"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**[]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*[]"+v2t+")()\n") - - // Slice containing interfaces. - v3i0 := "one" - v3 := []interface{}{v3i0, int(2), uint(3), nil} - v3i0Len := fmt.Sprintf("%d", len(v3i0)) - v3Len := fmt.Sprintf("%d", len(v3)) - v3Cap := fmt.Sprintf("%d", cap(v3)) - nv3 := (*[]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3t5 := "interface {}" - v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + - "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + - v3t4 + ") 3,\n (" + v3t5 + ") \n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Slice containing bytes. - v4 := []byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - v4Len := fmt.Sprintf("%d", len(v4)) - v4Cap := fmt.Sprintf("%d", cap(v4)) - nv4 := (*[]byte)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[]uint8" - v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + - "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + - " |............... |\n" + - " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + - " |!\"#$%&'()*+,-./0|\n" + - " 00000020 31 32 " + - " |12|\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") - - // Nil slice. - v5 := []int(nil) - nv5 := (*[]int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "[]int" - v5s := "" - addDumpTest(v5, "("+v5t+") "+v5s+"\n") - addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") - addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") - addDumpTest(nv5, "(*"+v5t+")()\n") -} - -func addStringDumpTests() { - // Standard string. - v := "test" - vLen := fmt.Sprintf("%d", len(v)) - nv := (*string)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "string" - vs := "(len=" + vLen + ") \"test\"" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addInterfaceDumpTests() { - // Nil interface. - var v interface{} - nv := (*interface{})(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "interface {}" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Sub-interface. - v2 := interface{}(uint16(65535)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addMapDumpTests() { - // Map with string keys and int vals. - k := "one" - kk := "two" - m := map[string]int{k: 1, kk: 2} - klen := fmt.Sprintf("%d", len(k)) // not kLen to shut golint up - kkLen := fmt.Sprintf("%d", len(kk)) - mLen := fmt.Sprintf("%d", len(m)) - nilMap := map[string]int(nil) - nm := (*map[string]int)(nil) - pm := &m - mAddr := fmt.Sprintf("%p", pm) - pmAddr := fmt.Sprintf("%p", &pm) - mt := "map[string]int" - mt1 := "string" - mt2 := "int" - ms := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + klen + ") " + - "\"one\": (" + mt2 + ") 1,\n (" + mt1 + ") (len=" + kkLen + - ") \"two\": (" + mt2 + ") 2\n}" - ms2 := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + kkLen + ") " + - "\"two\": (" + mt2 + ") 2,\n (" + mt1 + ") (len=" + klen + - ") \"one\": (" + mt2 + ") 1\n}" - addDumpTest(m, "("+mt+") "+ms+"\n", "("+mt+") "+ms2+"\n") - addDumpTest(pm, "(*"+mt+")("+mAddr+")("+ms+")\n", - "(*"+mt+")("+mAddr+")("+ms2+")\n") - addDumpTest(&pm, "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms+")\n", - "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms2+")\n") - addDumpTest(nm, "(*"+mt+")()\n") - addDumpTest(nilMap, "("+mt+") \n") - - // Map with custom formatter type on pointer receiver only keys and vals. - k2 := pstringer("one") - v2 := pstringer("1") - m2 := map[pstringer]pstringer{k2: v2} - k2Len := fmt.Sprintf("%d", len(k2)) - v2Len := fmt.Sprintf("%d", len(v2)) - m2Len := fmt.Sprintf("%d", len(m2)) - nilMap2 := map[pstringer]pstringer(nil) - nm2 := (*map[pstringer]pstringer)(nil) - pm2 := &m2 - m2Addr := fmt.Sprintf("%p", pm2) - pm2Addr := fmt.Sprintf("%p", &pm2) - m2t := "map[spew_test.pstringer]spew_test.pstringer" - m2t1 := "spew_test.pstringer" - m2t2 := "spew_test.pstringer" - m2s := "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + ") " + - "stringer one: (" + m2t2 + ") (len=" + v2Len + ") stringer 1\n}" - if spew.UnsafeDisabled { - m2s = "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + - ") " + "\"one\": (" + m2t2 + ") (len=" + v2Len + - ") \"1\"\n}" - } - addDumpTest(m2, "("+m2t+") "+m2s+"\n") - addDumpTest(pm2, "(*"+m2t+")("+m2Addr+")("+m2s+")\n") - addDumpTest(&pm2, "(**"+m2t+")("+pm2Addr+"->"+m2Addr+")("+m2s+")\n") - addDumpTest(nm2, "(*"+m2t+")()\n") - addDumpTest(nilMap2, "("+m2t+") \n") - - // Map with interface keys and values. - k3 := "one" - k3Len := fmt.Sprintf("%d", len(k3)) - m3 := map[interface{}]interface{}{k3: 1} - m3Len := fmt.Sprintf("%d", len(m3)) - nilMap3 := map[interface{}]interface{}(nil) - nm3 := (*map[interface{}]interface{})(nil) - pm3 := &m3 - m3Addr := fmt.Sprintf("%p", pm3) - pm3Addr := fmt.Sprintf("%p", &pm3) - m3t := "map[interface {}]interface {}" - m3t1 := "string" - m3t2 := "int" - m3s := "(len=" + m3Len + ") {\n (" + m3t1 + ") (len=" + k3Len + ") " + - "\"one\": (" + m3t2 + ") 1\n}" - addDumpTest(m3, "("+m3t+") "+m3s+"\n") - addDumpTest(pm3, "(*"+m3t+")("+m3Addr+")("+m3s+")\n") - addDumpTest(&pm3, "(**"+m3t+")("+pm3Addr+"->"+m3Addr+")("+m3s+")\n") - addDumpTest(nm3, "(*"+m3t+")()\n") - addDumpTest(nilMap3, "("+m3t+") \n") - - // Map with nil interface value. - k4 := "nil" - k4Len := fmt.Sprintf("%d", len(k4)) - m4 := map[string]interface{}{k4: nil} - m4Len := fmt.Sprintf("%d", len(m4)) - nilMap4 := map[string]interface{}(nil) - nm4 := (*map[string]interface{})(nil) - pm4 := &m4 - m4Addr := fmt.Sprintf("%p", pm4) - pm4Addr := fmt.Sprintf("%p", &pm4) - m4t := "map[string]interface {}" - m4t1 := "string" - m4t2 := "interface {}" - m4s := "(len=" + m4Len + ") {\n (" + m4t1 + ") (len=" + k4Len + ")" + - " \"nil\": (" + m4t2 + ") \n}" - addDumpTest(m4, "("+m4t+") "+m4s+"\n") - addDumpTest(pm4, "(*"+m4t+")("+m4Addr+")("+m4s+")\n") - addDumpTest(&pm4, "(**"+m4t+")("+pm4Addr+"->"+m4Addr+")("+m4s+")\n") - addDumpTest(nm4, "(*"+m4t+")()\n") - addDumpTest(nilMap4, "("+m4t+") \n") -} - -func addStructDumpTests() { - // Struct with primitives. - type s1 struct { - a int8 - b uint8 - } - v := s1{127, 255} - nv := (*s1)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.s1" - vt2 := "int8" - vt3 := "uint8" - vs := "{\n a: (" + vt2 + ") 127,\n b: (" + vt3 + ") 255\n}" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Struct that contains another struct. - type s2 struct { - s1 s1 - b bool - } - v2 := s2{s1{127, 255}, true} - nv2 := (*s2)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.s2" - v2t2 := "spew_test.s1" - v2t3 := "int8" - v2t4 := "uint8" - v2t5 := "bool" - v2s := "{\n s1: (" + v2t2 + ") {\n a: (" + v2t3 + ") 127,\n b: (" + - v2t4 + ") 255\n },\n b: (" + v2t5 + ") true\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Struct that contains custom type with Stringer pointer interface via both - // exported and unexported fields. - type s3 struct { - s pstringer - S pstringer - } - v3 := s3{"test", "test2"} - nv3 := (*s3)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.s3" - v3t2 := "spew_test.pstringer" - v3s := "{\n s: (" + v3t2 + ") (len=4) stringer test,\n S: (" + v3t2 + - ") (len=5) stringer test2\n}" - v3sp := v3s - if spew.UnsafeDisabled { - v3s = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + - v3t2 + ") (len=5) \"test2\"\n}" - v3sp = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + - v3t2 + ") (len=5) stringer test2\n}" - } - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3sp+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3sp+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") - - // Struct that contains embedded struct and field to same struct. - e := embed{"embedstr"} - eLen := fmt.Sprintf("%d", len("embedstr")) - v4 := embedwrap{embed: &e, e: &e} - nv4 := (*embedwrap)(nil) - pv4 := &v4 - eAddr := fmt.Sprintf("%p", &e) - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "spew_test.embedwrap" - v4t2 := "spew_test.embed" - v4t3 := "string" - v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 + - ") (len=" + eLen + ") \"embedstr\"\n }),\n e: (*" + v4t2 + - ")(" + eAddr + ")({\n a: (" + v4t3 + ") (len=" + eLen + ")" + - " \"embedstr\"\n })\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") - addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") - addDumpTest(nv4, "(*"+v4t+")()\n") -} - -func addUintptrDumpTests() { - // Null pointer. - v := uintptr(0) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uintptr" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - - // Address of real variable. - i := 1 - v2 := uintptr(unsafe.Pointer(&i)) - nv2 := (*uintptr)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uintptr" - v2s := fmt.Sprintf("%p", &i) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") -} - -func addUnsafePointerDumpTests() { - // Null pointer. - v := unsafe.Pointer(nil) - nv := (*unsafe.Pointer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "unsafe.Pointer" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Address of real variable. - i := 1 - v2 := unsafe.Pointer(&i) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "unsafe.Pointer" - v2s := fmt.Sprintf("%p", &i) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addChanDumpTests() { - // Nil channel. - var v chan int - pv := &v - nv := (*chan int)(nil) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "chan int" - vs := "" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Real channel. - v2 := make(chan int) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "chan int" - v2s := fmt.Sprintf("%p", v2) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") -} - -func addFuncDumpTests() { - // Function with no params and no returns. - v := addIntDumpTests - nv := (*func())(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "func()" - vs := fmt.Sprintf("%p", v) - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") - - // Function with param and no returns. - v2 := TestDump - nv2 := (*func(*testing.T))(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "func(*testing.T)" - v2s := fmt.Sprintf("%p", v2) - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") - addDumpTest(nv2, "(*"+v2t+")()\n") - - // Function with multiple params and multiple returns. - var v3 = func(i int, s string) (b bool, err error) { - return true, nil - } - nv3 := (*func(int, string) (bool, error))(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "func(int, string) (bool, error)" - v3s := fmt.Sprintf("%p", v3) - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") - addDumpTest(nv3, "(*"+v3t+")()\n") -} - -func addCircularDumpTests() { - // Struct that is circular through self referencing. - type circular struct { - c *circular - } - v := circular{nil} - v.c = &v - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.circular" - vs := "{\n c: (*" + vt + ")(" + vAddr + ")({\n c: (*" + vt + ")(" + - vAddr + ")()\n })\n}" - vs2 := "{\n c: (*" + vt + ")(" + vAddr + ")()\n}" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs2+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n") - - // Structs that are circular through cross referencing. - v2 := xref1{nil} - ts2 := xref2{&v2} - v2.ps2 = &ts2 - pv2 := &v2 - ts2Addr := fmt.Sprintf("%p", &ts2) - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.xref1" - v2t2 := "spew_test.xref2" - v2s := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + - ")(" + v2Addr + ")({\n ps2: (*" + v2t2 + ")(" + ts2Addr + - ")()\n })\n })\n}" - v2s2 := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + - ")(" + v2Addr + ")()\n })\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s2+")\n") - addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s2+")\n") - - // Structs that are indirectly circular. - v3 := indirCir1{nil} - tic2 := indirCir2{nil} - tic3 := indirCir3{&v3} - tic2.ps3 = &tic3 - v3.ps2 = &tic2 - pv3 := &v3 - tic2Addr := fmt.Sprintf("%p", &tic2) - tic3Addr := fmt.Sprintf("%p", &tic3) - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.indirCir1" - v3t2 := "spew_test.indirCir2" - v3t3 := "spew_test.indirCir3" - v3s := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + - ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + - ")({\n ps2: (*" + v3t2 + ")(" + tic2Addr + - ")()\n })\n })\n })\n}" - v3s2 := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + - ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + - ")()\n })\n })\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n") - addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s2+")\n") - addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n") -} - -func addPanicDumpTests() { - // Type that panics in its Stringer interface. - v := panicer(127) - nv := (*panicer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.panicer" - vs := "(PANIC=test panic)127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -func addErrorDumpTests() { - // Type that has a custom Error interface. - v := customError(127) - nv := (*customError)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.customError" - vs := "error: 127" - addDumpTest(v, "("+vt+") "+vs+"\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") - addDumpTest(nv, "(*"+vt+")()\n") -} - -// TestDump executes all of the tests described by dumpTests. -func TestDump(t *testing.T) { - // Setup tests. - addIntDumpTests() - addUintDumpTests() - addBoolDumpTests() - addFloatDumpTests() - addComplexDumpTests() - addArrayDumpTests() - addSliceDumpTests() - addStringDumpTests() - addInterfaceDumpTests() - addMapDumpTests() - addStructDumpTests() - addUintptrDumpTests() - addUnsafePointerDumpTests() - addChanDumpTests() - addFuncDumpTests() - addCircularDumpTests() - addPanicDumpTests() - addErrorDumpTests() - addCgoDumpTests() - - t.Logf("Running %d tests", len(dumpTests)) - for i, test := range dumpTests { - buf := new(bytes.Buffer) - spew.Fdump(buf, test.in) - s := buf.String() - if testFailed(s, test.wants) { - t.Errorf("Dump #%d\n got: %s %s", i, s, stringizeWants(test.wants)) - continue - } - } -} - -func TestDumpSortedKeys(t *testing.T) { - cfg := spew.ConfigState{SortKeys: true} - s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"}) - expected := "(map[int]string) (len=3) {\n(int) 1: (string) (len=1) " + - "\"1\",\n(int) 2: (string) (len=1) \"2\",\n(int) 3: (string) " + - "(len=1) \"3\"\n" + - "}\n" - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } - - s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2}) - expected = "(map[spew_test.stringer]int) (len=3) {\n" + - "(spew_test.stringer) (len=1) stringer 1: (int) 1,\n" + - "(spew_test.stringer) (len=1) stringer 2: (int) 2,\n" + - "(spew_test.stringer) (len=1) stringer 3: (int) 3\n" + - "}\n" - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } - - s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) - expected = "(map[spew_test.pstringer]int) (len=3) {\n" + - "(spew_test.pstringer) (len=1) stringer 1: (int) 1,\n" + - "(spew_test.pstringer) (len=1) stringer 2: (int) 2,\n" + - "(spew_test.pstringer) (len=1) stringer 3: (int) 3\n" + - "}\n" - if spew.UnsafeDisabled { - expected = "(map[spew_test.pstringer]int) (len=3) {\n" + - "(spew_test.pstringer) (len=1) \"1\": (int) 1,\n" + - "(spew_test.pstringer) (len=1) \"2\": (int) 2,\n" + - "(spew_test.pstringer) (len=1) \"3\": (int) 3\n" + - "}\n" - } - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } - - s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) - expected = "(map[spew_test.customError]int) (len=3) {\n" + - "(spew_test.customError) error: 1: (int) 1,\n" + - "(spew_test.customError) error: 2: (int) 2,\n" + - "(spew_test.customError) error: 3: (int) 3\n" + - "}\n" - if s != expected { - t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) - } - -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go deleted file mode 100644 index 108baa5..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2013-2016 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when both cgo is supported and "-tags testcgo" is added to the go test -// command line. This means the cgo tests are only added (and hence run) when -// specifially requested. This configuration is used because spew itself -// does not require cgo to run even though it does handle certain cgo types -// specially. Rather than forcing all clients to require cgo and an external -// C compiler just to run the tests, this scheme makes them optional. -// +build cgo,testcgo - -package spew_test - -import ( - "fmt" - - "github.com/davecgh/go-spew/spew/testdata" -) - -func addCgoDumpTests() { - // C char pointer. - v := testdata.GetCgoCharPointer() - nv := testdata.GetCgoNullCharPointer() - pv := &v - vcAddr := fmt.Sprintf("%p", v) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "*testdata._Ctype_char" - vs := "116" - addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n") - addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n") - addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n") - addDumpTest(nv, "("+vt+")()\n") - - // C char array. - v2, v2l, v2c := testdata.GetCgoCharArray() - v2Len := fmt.Sprintf("%d", v2l) - v2Cap := fmt.Sprintf("%d", v2c) - v2t := "[6]testdata._Ctype_char" - v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " + - "{\n 00000000 74 65 73 74 32 00 " + - " |test2.|\n}" - addDumpTest(v2, "("+v2t+") "+v2s+"\n") - - // C unsigned char array. - v3, v3l, v3c := testdata.GetCgoUnsignedCharArray() - v3Len := fmt.Sprintf("%d", v3l) - v3Cap := fmt.Sprintf("%d", v3c) - v3t := "[6]testdata._Ctype_unsignedchar" - v3t2 := "[6]testdata._Ctype_uchar" - v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " + - "{\n 00000000 74 65 73 74 33 00 " + - " |test3.|\n}" - addDumpTest(v3, "("+v3t+") "+v3s+"\n", "("+v3t2+") "+v3s+"\n") - - // C signed char array. - v4, v4l, v4c := testdata.GetCgoSignedCharArray() - v4Len := fmt.Sprintf("%d", v4l) - v4Cap := fmt.Sprintf("%d", v4c) - v4t := "[6]testdata._Ctype_schar" - v4t2 := "testdata._Ctype_schar" - v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + - "{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 + - ") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 + - ") 0\n}" - addDumpTest(v4, "("+v4t+") "+v4s+"\n") - - // C uint8_t array. - v5, v5l, v5c := testdata.GetCgoUint8tArray() - v5Len := fmt.Sprintf("%d", v5l) - v5Cap := fmt.Sprintf("%d", v5c) - v5t := "[6]testdata._Ctype_uint8_t" - v5t2 := "[6]testdata._Ctype_uchar" - v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " + - "{\n 00000000 74 65 73 74 35 00 " + - " |test5.|\n}" - addDumpTest(v5, "("+v5t+") "+v5s+"\n", "("+v5t2+") "+v5s+"\n") - - // C typedefed unsigned char array. - v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray() - v6Len := fmt.Sprintf("%d", v6l) - v6Cap := fmt.Sprintf("%d", v6c) - v6t := "[6]testdata._Ctype_custom_uchar_t" - v6t2 := "[6]testdata._Ctype_uchar" - v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " + - "{\n 00000000 74 65 73 74 36 00 " + - " |test6.|\n}" - addDumpTest(v6, "("+v6t+") "+v6s+"\n", "("+v6t2+") "+v6s+"\n") -} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go deleted file mode 100644 index 52a0971..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2013 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when either cgo is not supported or "-tags testcgo" is not added to the go -// test command line. This file intentionally does not setup any cgo tests in -// this scenario. -// +build !cgo !testcgo - -package spew_test - -func addCgoDumpTests() { - // Don't add any tests for cgo since this file is only compiled when - // there should not be any cgo tests. -} diff --git a/vendor/github.com/davecgh/go-spew/spew/example_test.go b/vendor/github.com/davecgh/go-spew/spew/example_test.go deleted file mode 100644 index c6ec8c6..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/example_test.go +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "fmt" - - "github.com/davecgh/go-spew/spew" -) - -type Flag int - -const ( - flagOne Flag = iota - flagTwo -) - -var flagStrings = map[Flag]string{ - flagOne: "flagOne", - flagTwo: "flagTwo", -} - -func (f Flag) String() string { - if s, ok := flagStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown flag (%d)", int(f)) -} - -type Bar struct { - data uintptr -} - -type Foo struct { - unexportedField Bar - ExportedField map[interface{}]interface{} -} - -// This example demonstrates how to use Dump to dump variables to stdout. -func ExampleDump() { - // The following package level declarations are assumed for this example: - /* - type Flag int - - const ( - flagOne Flag = iota - flagTwo - ) - - var flagStrings = map[Flag]string{ - flagOne: "flagOne", - flagTwo: "flagTwo", - } - - func (f Flag) String() string { - if s, ok := flagStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown flag (%d)", int(f)) - } - - type Bar struct { - data uintptr - } - - type Foo struct { - unexportedField Bar - ExportedField map[interface{}]interface{} - } - */ - - // Setup some sample data structures for the example. - bar := Bar{uintptr(0)} - s1 := Foo{bar, map[interface{}]interface{}{"one": true}} - f := Flag(5) - b := []byte{ - 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, - } - - // Dump! - spew.Dump(s1, f, b) - - // Output: - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) (len=1) { - // (string) (len=3) "one": (bool) true - // } - // } - // (spew_test.Flag) Unknown flag (5) - // ([]uint8) (len=34 cap=34) { - // 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | - // 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| - // 00000020 31 32 |12| - // } - // -} - -// This example demonstrates how to use Printf to display a variable with a -// format string and inline formatting. -func ExamplePrintf() { - // Create a double pointer to a uint 8. - ui8 := uint8(5) - pui8 := &ui8 - ppui8 := &pui8 - - // Create a circular data type. - type circular struct { - ui8 uint8 - c *circular - } - c := circular{ui8: 1} - c.c = &c - - // Print! - spew.Printf("ppui8: %v\n", ppui8) - spew.Printf("circular: %v\n", c) - - // Output: - // ppui8: <**>5 - // circular: {1 <*>{1 <*>}} -} - -// This example demonstrates how to use a ConfigState. -func ExampleConfigState() { - // Modify the indent level of the ConfigState only. The global - // configuration is not modified. - scs := spew.ConfigState{Indent: "\t"} - - // Output using the ConfigState instance. - v := map[string]int{"one": 1} - scs.Printf("v: %v\n", v) - scs.Dump(v) - - // Output: - // v: map[one:1] - // (map[string]int) (len=1) { - // (string) (len=3) "one": (int) 1 - // } -} - -// This example demonstrates how to use ConfigState.Dump to dump variables to -// stdout -func ExampleConfigState_Dump() { - // See the top-level Dump example for details on the types used in this - // example. - - // Create two ConfigState instances with different indentation. - scs := spew.ConfigState{Indent: "\t"} - scs2 := spew.ConfigState{Indent: " "} - - // Setup some sample data structures for the example. - bar := Bar{uintptr(0)} - s1 := Foo{bar, map[interface{}]interface{}{"one": true}} - - // Dump using the ConfigState instances. - scs.Dump(s1) - scs2.Dump(s1) - - // Output: - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) (len=1) { - // (string) (len=3) "one": (bool) true - // } - // } - // (spew_test.Foo) { - // unexportedField: (spew_test.Bar) { - // data: (uintptr) - // }, - // ExportedField: (map[interface {}]interface {}) (len=1) { - // (string) (len=3) "one": (bool) true - // } - // } - // -} - -// This example demonstrates how to use ConfigState.Printf to display a variable -// with a format string and inline formatting. -func ExampleConfigState_Printf() { - // See the top-level Dump example for details on the types used in this - // example. - - // Create two ConfigState instances and modify the method handling of the - // first ConfigState only. - scs := spew.NewDefaultConfig() - scs2 := spew.NewDefaultConfig() - scs.DisableMethods = true - - // Alternatively - // scs := spew.ConfigState{Indent: " ", DisableMethods: true} - // scs2 := spew.ConfigState{Indent: " "} - - // This is of type Flag which implements a Stringer and has raw value 1. - f := flagTwo - - // Dump using the ConfigState instances. - scs.Printf("f: %v\n", f) - scs2.Printf("f: %v\n", f) - - // Output: - // f: 1 - // f: flagTwo -} diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go deleted file mode 100644 index b04edb7..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/format.go +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "bytes" - "fmt" - "reflect" - "strconv" - "strings" -) - -// supportedFlags is a list of all the character flags supported by fmt package. -const supportedFlags = "0-+# " - -// formatState implements the fmt.Formatter interface and contains information -// about the state of a formatting operation. The NewFormatter function can -// be used to get a new Formatter which can be used directly as arguments -// in standard fmt package printing calls. -type formatState struct { - value interface{} - fs fmt.State - depth int - pointers map[uintptr]int - ignoreNextType bool - cs *ConfigState -} - -// buildDefaultFormat recreates the original format string without precision -// and width information to pass in to fmt.Sprintf in the case of an -// unrecognized type. Unless new types are added to the language, this -// function won't ever be called. -func (f *formatState) buildDefaultFormat() (format string) { - buf := bytes.NewBuffer(percentBytes) - - for _, flag := range supportedFlags { - if f.fs.Flag(int(flag)) { - buf.WriteRune(flag) - } - } - - buf.WriteRune('v') - - format = buf.String() - return format -} - -// constructOrigFormat recreates the original format string including precision -// and width information to pass along to the standard fmt package. This allows -// automatic deferral of all format strings this package doesn't support. -func (f *formatState) constructOrigFormat(verb rune) (format string) { - buf := bytes.NewBuffer(percentBytes) - - for _, flag := range supportedFlags { - if f.fs.Flag(int(flag)) { - buf.WriteRune(flag) - } - } - - if width, ok := f.fs.Width(); ok { - buf.WriteString(strconv.Itoa(width)) - } - - if precision, ok := f.fs.Precision(); ok { - buf.Write(precisionBytes) - buf.WriteString(strconv.Itoa(precision)) - } - - buf.WriteRune(verb) - - format = buf.String() - return format -} - -// unpackValue returns values inside of non-nil interfaces when possible and -// ensures that types for values which have been unpacked from an interface -// are displayed when the show types flag is also set. -// This is useful for data types like structs, arrays, slices, and maps which -// can contain varying types packed inside an interface. -func (f *formatState) unpackValue(v reflect.Value) reflect.Value { - if v.Kind() == reflect.Interface { - f.ignoreNextType = false - if !v.IsNil() { - v = v.Elem() - } - } - return v -} - -// formatPtr handles formatting of pointers by indirecting them as necessary. -func (f *formatState) formatPtr(v reflect.Value) { - // Display nil if top level pointer is nil. - showTypes := f.fs.Flag('#') - if v.IsNil() && (!showTypes || f.ignoreNextType) { - f.fs.Write(nilAngleBytes) - return - } - - // Remove pointers at or below the current depth from map used to detect - // circular refs. - for k, depth := range f.pointers { - if depth >= f.depth { - delete(f.pointers, k) - } - } - - // Keep list of all dereferenced pointers to possibly show later. - pointerChain := make([]uintptr, 0) - - // Figure out how many levels of indirection there are by derferencing - // pointers and unpacking interfaces down the chain while detecting circular - // references. - nilFound := false - cycleFound := false - indirects := 0 - ve := v - for ve.Kind() == reflect.Ptr { - if ve.IsNil() { - nilFound = true - break - } - indirects++ - addr := ve.Pointer() - pointerChain = append(pointerChain, addr) - if pd, ok := f.pointers[addr]; ok && pd < f.depth { - cycleFound = true - indirects-- - break - } - f.pointers[addr] = f.depth - - ve = ve.Elem() - if ve.Kind() == reflect.Interface { - if ve.IsNil() { - nilFound = true - break - } - ve = ve.Elem() - } - } - - // Display type or indirection level depending on flags. - if showTypes && !f.ignoreNextType { - f.fs.Write(openParenBytes) - f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) - f.fs.Write([]byte(ve.Type().String())) - f.fs.Write(closeParenBytes) - } else { - if nilFound || cycleFound { - indirects += strings.Count(ve.Type().String(), "*") - } - f.fs.Write(openAngleBytes) - f.fs.Write([]byte(strings.Repeat("*", indirects))) - f.fs.Write(closeAngleBytes) - } - - // Display pointer information depending on flags. - if f.fs.Flag('+') && (len(pointerChain) > 0) { - f.fs.Write(openParenBytes) - for i, addr := range pointerChain { - if i > 0 { - f.fs.Write(pointerChainBytes) - } - printHexPtr(f.fs, addr) - } - f.fs.Write(closeParenBytes) - } - - // Display dereferenced value. - switch { - case nilFound: - f.fs.Write(nilAngleBytes) - - case cycleFound: - f.fs.Write(circularShortBytes) - - default: - f.ignoreNextType = true - f.format(ve) - } -} - -// format is the main workhorse for providing the Formatter interface. It -// uses the passed reflect value to figure out what kind of object we are -// dealing with and formats it appropriately. It is a recursive function, -// however circular data structures are detected and handled properly. -func (f *formatState) format(v reflect.Value) { - // Handle invalid reflect values immediately. - kind := v.Kind() - if kind == reflect.Invalid { - f.fs.Write(invalidAngleBytes) - return - } - - // Handle pointers specially. - if kind == reflect.Ptr { - f.formatPtr(v) - return - } - - // Print type information unless already handled elsewhere. - if !f.ignoreNextType && f.fs.Flag('#') { - f.fs.Write(openParenBytes) - f.fs.Write([]byte(v.Type().String())) - f.fs.Write(closeParenBytes) - } - f.ignoreNextType = false - - // Call Stringer/error interfaces if they exist and the handle methods - // flag is enabled. - if !f.cs.DisableMethods { - if (kind != reflect.Invalid) && (kind != reflect.Interface) { - if handled := handleMethods(f.cs, f.fs, v); handled { - return - } - } - } - - switch kind { - case reflect.Invalid: - // Do nothing. We should never get here since invalid has already - // been handled above. - - case reflect.Bool: - printBool(f.fs, v.Bool()) - - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - printInt(f.fs, v.Int(), 10) - - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: - printUint(f.fs, v.Uint(), 10) - - case reflect.Float32: - printFloat(f.fs, v.Float(), 32) - - case reflect.Float64: - printFloat(f.fs, v.Float(), 64) - - case reflect.Complex64: - printComplex(f.fs, v.Complex(), 32) - - case reflect.Complex128: - printComplex(f.fs, v.Complex(), 64) - - case reflect.Slice: - if v.IsNil() { - f.fs.Write(nilAngleBytes) - break - } - fallthrough - - case reflect.Array: - f.fs.Write(openBracketBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - numEntries := v.Len() - for i := 0; i < numEntries; i++ { - if i > 0 { - f.fs.Write(spaceBytes) - } - f.ignoreNextType = true - f.format(f.unpackValue(v.Index(i))) - } - } - f.depth-- - f.fs.Write(closeBracketBytes) - - case reflect.String: - f.fs.Write([]byte(v.String())) - - case reflect.Interface: - // The only time we should get here is for nil interfaces due to - // unpackValue calls. - if v.IsNil() { - f.fs.Write(nilAngleBytes) - } - - case reflect.Ptr: - // Do nothing. We should never get here since pointers have already - // been handled above. - - case reflect.Map: - // nil maps should be indicated as different than empty maps - if v.IsNil() { - f.fs.Write(nilAngleBytes) - break - } - - f.fs.Write(openMapBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - keys := v.MapKeys() - if f.cs.SortKeys { - sortValues(keys, f.cs) - } - for i, key := range keys { - if i > 0 { - f.fs.Write(spaceBytes) - } - f.ignoreNextType = true - f.format(f.unpackValue(key)) - f.fs.Write(colonBytes) - f.ignoreNextType = true - f.format(f.unpackValue(v.MapIndex(key))) - } - } - f.depth-- - f.fs.Write(closeMapBytes) - - case reflect.Struct: - numFields := v.NumField() - f.fs.Write(openBraceBytes) - f.depth++ - if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { - f.fs.Write(maxShortBytes) - } else { - vt := v.Type() - for i := 0; i < numFields; i++ { - if i > 0 { - f.fs.Write(spaceBytes) - } - vtf := vt.Field(i) - if f.fs.Flag('+') || f.fs.Flag('#') { - f.fs.Write([]byte(vtf.Name)) - f.fs.Write(colonBytes) - } - f.format(f.unpackValue(v.Field(i))) - } - } - f.depth-- - f.fs.Write(closeBraceBytes) - - case reflect.Uintptr: - printHexPtr(f.fs, uintptr(v.Uint())) - - case reflect.UnsafePointer, reflect.Chan, reflect.Func: - printHexPtr(f.fs, v.Pointer()) - - // There were not any other types at the time this code was written, but - // fall back to letting the default fmt package handle it if any get added. - default: - format := f.buildDefaultFormat() - if v.CanInterface() { - fmt.Fprintf(f.fs, format, v.Interface()) - } else { - fmt.Fprintf(f.fs, format, v.String()) - } - } -} - -// Format satisfies the fmt.Formatter interface. See NewFormatter for usage -// details. -func (f *formatState) Format(fs fmt.State, verb rune) { - f.fs = fs - - // Use standard formatting for verbs that are not v. - if verb != 'v' { - format := f.constructOrigFormat(verb) - fmt.Fprintf(fs, format, f.value) - return - } - - if f.value == nil { - if fs.Flag('#') { - fs.Write(interfaceBytes) - } - fs.Write(nilAngleBytes) - return - } - - f.format(reflect.ValueOf(f.value)) -} - -// newFormatter is a helper function to consolidate the logic from the various -// public methods which take varying config states. -func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { - fs := &formatState{value: v, cs: cs} - fs.pointers = make(map[uintptr]int) - return fs -} - -/* -NewFormatter returns a custom formatter that satisfies the fmt.Formatter -interface. As a result, it integrates cleanly with standard fmt package -printing functions. The formatter is useful for inline printing of smaller data -types similar to the standard %v format specifier. - -The custom formatter only responds to the %v (most compact), %+v (adds pointer -addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb -combinations. Any other verbs such as %x and %q will be sent to the the -standard fmt package for formatting. In addition, the custom formatter ignores -the width and precision arguments (however they will still work on the format -specifiers not handled by the custom formatter). - -Typically this function shouldn't be called directly. It is much easier to make -use of the custom formatter by calling one of the convenience functions such as -Printf, Println, or Fprintf. -*/ -func NewFormatter(v interface{}) fmt.Formatter { - return newFormatter(&Config, v) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/format_test.go b/vendor/github.com/davecgh/go-spew/spew/format_test.go deleted file mode 100644 index 87ee965..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/format_test.go +++ /dev/null @@ -1,1558 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -Test Summary: -NOTE: For each test, a nil pointer, a single pointer and double pointer to the -base test element are also tested to ensure proper indirection across all types. - -- Max int8, int16, int32, int64, int -- Max uint8, uint16, uint32, uint64, uint -- Boolean true and false -- Standard complex64 and complex128 -- Array containing standard ints -- Array containing type with custom formatter on pointer receiver only -- Array containing interfaces -- Slice containing standard float32 values -- Slice containing type with custom formatter on pointer receiver only -- Slice containing interfaces -- Nil slice -- Standard string -- Nil interface -- Sub-interface -- Map with string keys and int vals -- Map with custom formatter type on pointer receiver only keys and vals -- Map with interface keys and values -- Map with nil interface value -- Struct with primitives -- Struct that contains another struct -- Struct that contains custom type with Stringer pointer interface via both - exported and unexported fields -- Struct that contains embedded struct and field to same struct -- Uintptr to 0 (null pointer) -- Uintptr address of real variable -- Unsafe.Pointer to 0 (null pointer) -- Unsafe.Pointer to address of real variable -- Nil channel -- Standard int channel -- Function with no params and no returns -- Function with param and no returns -- Function with multiple params and multiple returns -- Struct that is circular through self referencing -- Structs that are circular through cross referencing -- Structs that are indirectly circular -- Type that panics in its Stringer interface -- Type that has a custom Error interface -- %x passthrough with uint -- %#x passthrough with uint -- %f passthrough with precision -- %f passthrough with width and precision -- %d passthrough with width -- %q passthrough with string -*/ - -package spew_test - -import ( - "bytes" - "fmt" - "testing" - "unsafe" - - "github.com/davecgh/go-spew/spew" -) - -// formatterTest is used to describe a test to be performed against NewFormatter. -type formatterTest struct { - format string - in interface{} - wants []string -} - -// formatterTests houses all of the tests to be performed against NewFormatter. -var formatterTests = make([]formatterTest, 0) - -// addFormatterTest is a helper method to append the passed input and desired -// result to formatterTests. -func addFormatterTest(format string, in interface{}, wants ...string) { - test := formatterTest{format, in, wants} - formatterTests = append(formatterTests, test) -} - -func addIntFormatterTests() { - // Max int8. - v := int8(127) - nv := (*int8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "int8" - vs := "127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Max int16. - v2 := int16(32767) - nv2 := (*int16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "int16" - v2s := "32767" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Max int32. - v3 := int32(2147483647) - nv3 := (*int32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "int32" - v3s := "2147483647" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - - // Max int64. - v4 := int64(9223372036854775807) - nv4 := (*int64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "int64" - v4s := "9223372036854775807" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") - - // Max int. - v5 := int(2147483647) - nv5 := (*int)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "int" - v5s := "2147483647" - addFormatterTest("%v", v5, v5s) - addFormatterTest("%v", pv5, "<*>"+v5s) - addFormatterTest("%v", &pv5, "<**>"+v5s) - addFormatterTest("%v", nv5, "") - addFormatterTest("%+v", v5, v5s) - addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) - addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%+v", nv5, "") - addFormatterTest("%#v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) - addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") - addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) - addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%#+v", nv5, "(*"+v5t+")"+"") -} - -func addUintFormatterTests() { - // Max uint8. - v := uint8(255) - nv := (*uint8)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uint8" - vs := "255" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Max uint16. - v2 := uint16(65535) - nv2 := (*uint16)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Max uint32. - v3 := uint32(4294967295) - nv3 := (*uint32)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "uint32" - v3s := "4294967295" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - - // Max uint64. - v4 := uint64(18446744073709551615) - nv4 := (*uint64)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "uint64" - v4s := "18446744073709551615" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") - - // Max uint. - v5 := uint(4294967295) - nv5 := (*uint)(nil) - pv5 := &v5 - v5Addr := fmt.Sprintf("%p", pv5) - pv5Addr := fmt.Sprintf("%p", &pv5) - v5t := "uint" - v5s := "4294967295" - addFormatterTest("%v", v5, v5s) - addFormatterTest("%v", pv5, "<*>"+v5s) - addFormatterTest("%v", &pv5, "<**>"+v5s) - addFormatterTest("%v", nv5, "") - addFormatterTest("%+v", v5, v5s) - addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) - addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%+v", nv5, "") - addFormatterTest("%#v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) - addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") - addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) - addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) - addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) - addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") -} - -func addBoolFormatterTests() { - // Boolean true. - v := bool(true) - nv := (*bool)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "bool" - vs := "true" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Boolean false. - v2 := bool(false) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "bool" - v2s := "false" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addFloatFormatterTests() { - // Standard float32. - v := float32(3.1415) - nv := (*float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "float32" - vs := "3.1415" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Standard float64. - v2 := float64(3.1415926) - nv2 := (*float64)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "float64" - v2s := "3.1415926" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") -} - -func addComplexFormatterTests() { - // Standard complex64. - v := complex(float32(6), -2) - nv := (*complex64)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "complex64" - vs := "(6-2i)" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Standard complex128. - v2 := complex(float64(-6), 2) - nv2 := (*complex128)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "complex128" - v2s := "(-6+2i)" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") -} - -func addArrayFormatterTests() { - // Array containing standard ints. - v := [3]int{1, 2, 3} - nv := (*[3]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "[3]int" - vs := "[1 2 3]" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Array containing type with custom formatter on pointer receiver only. - v2 := [3]pstringer{"1", "2", "3"} - nv2 := (*[3]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "[3]spew_test.pstringer" - v2sp := "[stringer 1 stringer 2 stringer 3]" - v2s := v2sp - if spew.UnsafeDisabled { - v2s = "[1 2 3]" - } - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2sp) - addFormatterTest("%v", &pv2, "<**>"+v2sp) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2sp) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2sp) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2sp) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2sp) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2sp) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2sp) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Array containing interfaces. - v3 := [3]interface{}{"one", int(2), uint(3)} - nv3 := (*[3]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[3]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3s := "[one 2 3]" - v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") -} - -func addSliceFormatterTests() { - // Slice containing standard float32 values. - v := []float32{3.14, 6.28, 12.56} - nv := (*[]float32)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "[]float32" - vs := "[3.14 6.28 12.56]" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Slice containing type with custom formatter on pointer receiver only. - v2 := []pstringer{"1", "2", "3"} - nv2 := (*[]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "[]spew_test.pstringer" - v2s := "[stringer 1 stringer 2 stringer 3]" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Slice containing interfaces. - v3 := []interface{}{"one", int(2), uint(3), nil} - nv3 := (*[]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "[]interface {}" - v3t2 := "string" - v3t3 := "int" - v3t4 := "uint" - v3t5 := "interface {}" - v3s := "[one 2 3 ]" - v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3 (" + v3t5 + - ")]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Nil slice. - var v4 []int - nv4 := (*[]int)(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "[]int" - v4s := "" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addStringFormatterTests() { - // Standard string. - v := "test" - nv := (*string)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "string" - vs := "test" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addInterfaceFormatterTests() { - // Nil interface. - var v interface{} - nv := (*interface{})(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "interface {}" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Sub-interface. - v2 := interface{}(uint16(65535)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uint16" - v2s := "65535" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addMapFormatterTests() { - // Map with string keys and int vals. - v := map[string]int{"one": 1, "two": 2} - nilMap := map[string]int(nil) - nv := (*map[string]int)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "map[string]int" - vs := "map[one:1 two:2]" - vs2 := "map[two:2 one:1]" - addFormatterTest("%v", v, vs, vs2) - addFormatterTest("%v", pv, "<*>"+vs, "<*>"+vs2) - addFormatterTest("%v", &pv, "<**>"+vs, "<**>"+vs2) - addFormatterTest("%+v", nilMap, "") - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs, vs2) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs, "<*>("+vAddr+")"+vs2) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs, - "<**>("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%+v", nilMap, "") - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs, "("+vt+")"+vs2) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs, "(*"+vt+")"+vs2) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs, "(**"+vt+")"+vs2) - addFormatterTest("%#v", nilMap, "("+vt+")"+"") - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs, "("+vt+")"+vs2) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs, - "(*"+vt+")("+vAddr+")"+vs2) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs, - "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%#+v", nilMap, "("+vt+")"+"") - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Map with custom formatter type on pointer receiver only keys and vals. - v2 := map[pstringer]pstringer{"one": "1"} - nv2 := (*map[pstringer]pstringer)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "map[spew_test.pstringer]spew_test.pstringer" - v2s := "map[stringer one:stringer 1]" - if spew.UnsafeDisabled { - v2s = "map[one:1]" - } - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Map with interface keys and values. - v3 := map[interface{}]interface{}{"one": 1} - nv3 := (*map[interface{}]interface{})(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "map[interface {}]interface {}" - v3t1 := "string" - v3t2 := "int" - v3s := "map[one:1]" - v3s2 := "map[(" + v3t1 + ")one:(" + v3t2 + ")1]" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Map with nil interface value - v4 := map[string]interface{}{"nil": nil} - nv4 := (*map[string]interface{})(nil) - pv4 := &v4 - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "map[string]interface {}" - v4t1 := "interface {}" - v4s := "map[nil:]" - v4s2 := "map[nil:(" + v4t1 + ")]" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s2) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s2) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s2) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s2) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s2) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s2) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addStructFormatterTests() { - // Struct with primitives. - type s1 struct { - a int8 - b uint8 - } - v := s1{127, 255} - nv := (*s1)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.s1" - vt2 := "int8" - vt3 := "uint8" - vs := "{127 255}" - vs2 := "{a:127 b:255}" - vs3 := "{a:(" + vt2 + ")127 b:(" + vt3 + ")255}" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs2) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs2) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs2) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs3) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs3) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs3) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs3) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs3) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs3) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Struct that contains another struct. - type s2 struct { - s1 s1 - b bool - } - v2 := s2{s1{127, 255}, true} - nv2 := (*s2)(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.s2" - v2t2 := "spew_test.s1" - v2t3 := "int8" - v2t4 := "uint8" - v2t5 := "bool" - v2s := "{{127 255} true}" - v2s2 := "{s1:{a:127 b:255} b:true}" - v2s3 := "{s1:(" + v2t2 + "){a:(" + v2t3 + ")127 b:(" + v2t4 + ")255} b:(" + - v2t5 + ")true}" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s2) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s2) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s2) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s3) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s3) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s3) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s3) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s3) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s3) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Struct that contains custom type with Stringer pointer interface via both - // exported and unexported fields. - type s3 struct { - s pstringer - S pstringer - } - v3 := s3{"test", "test2"} - nv3 := (*s3)(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.s3" - v3t2 := "spew_test.pstringer" - v3s := "{stringer test stringer test2}" - v3sp := v3s - v3s2 := "{s:stringer test S:stringer test2}" - v3s2p := v3s2 - v3s3 := "{s:(" + v3t2 + ")stringer test S:(" + v3t2 + ")stringer test2}" - v3s3p := v3s3 - if spew.UnsafeDisabled { - v3s = "{test test2}" - v3sp = "{test stringer test2}" - v3s2 = "{s:test S:test2}" - v3s2p = "{s:test S:stringer test2}" - v3s3 = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")test2}" - v3s3p = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")stringer test2}" - } - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3sp) - addFormatterTest("%v", &pv3, "<**>"+v3sp) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s2) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s2p) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s2p) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s3) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s3p) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s3p) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s3) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s3p) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s3p) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") - - // Struct that contains embedded struct and field to same struct. - e := embed{"embedstr"} - v4 := embedwrap{embed: &e, e: &e} - nv4 := (*embedwrap)(nil) - pv4 := &v4 - eAddr := fmt.Sprintf("%p", &e) - v4Addr := fmt.Sprintf("%p", pv4) - pv4Addr := fmt.Sprintf("%p", &pv4) - v4t := "spew_test.embedwrap" - v4t2 := "spew_test.embed" - v4t3 := "string" - v4s := "{<*>{embedstr} <*>{embedstr}}" - v4s2 := "{embed:<*>(" + eAddr + "){a:embedstr} e:<*>(" + eAddr + - "){a:embedstr}}" - v4s3 := "{embed:(*" + v4t2 + "){a:(" + v4t3 + ")embedstr} e:(*" + v4t2 + - "){a:(" + v4t3 + ")embedstr}}" - v4s4 := "{embed:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + - ")embedstr} e:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + ")embedstr}}" - addFormatterTest("%v", v4, v4s) - addFormatterTest("%v", pv4, "<*>"+v4s) - addFormatterTest("%v", &pv4, "<**>"+v4s) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%+v", v4, v4s2) - addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s2) - addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s2) - addFormatterTest("%+v", nv4, "") - addFormatterTest("%#v", v4, "("+v4t+")"+v4s3) - addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s3) - addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s3) - addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") - addFormatterTest("%#+v", v4, "("+v4t+")"+v4s4) - addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s4) - addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s4) - addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") -} - -func addUintptrFormatterTests() { - // Null pointer. - v := uintptr(0) - nv := (*uintptr)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "uintptr" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Address of real variable. - i := 1 - v2 := uintptr(unsafe.Pointer(&i)) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "uintptr" - v2s := fmt.Sprintf("%p", &i) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addUnsafePointerFormatterTests() { - // Null pointer. - v := unsafe.Pointer(nil) - nv := (*unsafe.Pointer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "unsafe.Pointer" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Address of real variable. - i := 1 - v2 := unsafe.Pointer(&i) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "unsafe.Pointer" - v2s := fmt.Sprintf("%p", &i) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addChanFormatterTests() { - // Nil channel. - var v chan int - pv := &v - nv := (*chan int)(nil) - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "chan int" - vs := "" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Real channel. - v2 := make(chan int) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "chan int" - v2s := fmt.Sprintf("%p", v2) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) -} - -func addFuncFormatterTests() { - // Function with no params and no returns. - v := addIntFormatterTests - nv := (*func())(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "func()" - vs := fmt.Sprintf("%p", v) - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") - - // Function with param and no returns. - v2 := TestFormatter - nv2 := (*func(*testing.T))(nil) - pv2 := &v2 - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "func(*testing.T)" - v2s := fmt.Sprintf("%p", v2) - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s) - addFormatterTest("%v", &pv2, "<**>"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%+v", v2, v2s) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%+v", nv2, "") - addFormatterTest("%#v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) - addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) - addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") - - // Function with multiple params and multiple returns. - var v3 = func(i int, s string) (b bool, err error) { - return true, nil - } - nv3 := (*func(int, string) (bool, error))(nil) - pv3 := &v3 - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "func(int, string) (bool, error)" - v3s := fmt.Sprintf("%p", v3) - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s) - addFormatterTest("%v", &pv3, "<**>"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%+v", v3, v3s) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%+v", nv3, "") - addFormatterTest("%#v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) - addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) - addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") -} - -func addCircularFormatterTests() { - // Struct that is circular through self referencing. - type circular struct { - c *circular - } - v := circular{nil} - v.c = &v - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.circular" - vs := "{<*>{<*>}}" - vs2 := "{<*>}" - vs3 := "{c:<*>(" + vAddr + "){c:<*>(" + vAddr + ")}}" - vs4 := "{c:<*>(" + vAddr + ")}" - vs5 := "{c:(*" + vt + "){c:(*" + vt + ")}}" - vs6 := "{c:(*" + vt + ")}" - vs7 := "{c:(*" + vt + ")(" + vAddr + "){c:(*" + vt + ")(" + vAddr + - ")}}" - vs8 := "{c:(*" + vt + ")(" + vAddr + ")}" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs2) - addFormatterTest("%v", &pv, "<**>"+vs2) - addFormatterTest("%+v", v, vs3) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs4) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs4) - addFormatterTest("%#v", v, "("+vt+")"+vs5) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs6) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs6) - addFormatterTest("%#+v", v, "("+vt+")"+vs7) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs8) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs8) - - // Structs that are circular through cross referencing. - v2 := xref1{nil} - ts2 := xref2{&v2} - v2.ps2 = &ts2 - pv2 := &v2 - ts2Addr := fmt.Sprintf("%p", &ts2) - v2Addr := fmt.Sprintf("%p", pv2) - pv2Addr := fmt.Sprintf("%p", &pv2) - v2t := "spew_test.xref1" - v2t2 := "spew_test.xref2" - v2s := "{<*>{<*>{<*>}}}" - v2s2 := "{<*>{<*>}}" - v2s3 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + "){ps2:<*>(" + - ts2Addr + ")}}}" - v2s4 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + ")}}" - v2s5 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + "){ps2:(*" + v2t2 + - ")}}}" - v2s6 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + ")}}" - v2s7 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + - ")(" + v2Addr + "){ps2:(*" + v2t2 + ")(" + ts2Addr + - ")}}}" - v2s8 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + - ")(" + v2Addr + ")}}" - addFormatterTest("%v", v2, v2s) - addFormatterTest("%v", pv2, "<*>"+v2s2) - addFormatterTest("%v", &pv2, "<**>"+v2s2) - addFormatterTest("%+v", v2, v2s3) - addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s4) - addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s4) - addFormatterTest("%#v", v2, "("+v2t+")"+v2s5) - addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s6) - addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s6) - addFormatterTest("%#+v", v2, "("+v2t+")"+v2s7) - addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s8) - addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s8) - - // Structs that are indirectly circular. - v3 := indirCir1{nil} - tic2 := indirCir2{nil} - tic3 := indirCir3{&v3} - tic2.ps3 = &tic3 - v3.ps2 = &tic2 - pv3 := &v3 - tic2Addr := fmt.Sprintf("%p", &tic2) - tic3Addr := fmt.Sprintf("%p", &tic3) - v3Addr := fmt.Sprintf("%p", pv3) - pv3Addr := fmt.Sprintf("%p", &pv3) - v3t := "spew_test.indirCir1" - v3t2 := "spew_test.indirCir2" - v3t3 := "spew_test.indirCir3" - v3s := "{<*>{<*>{<*>{<*>}}}}" - v3s2 := "{<*>{<*>{<*>}}}" - v3s3 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + - v3Addr + "){ps2:<*>(" + tic2Addr + ")}}}}" - v3s4 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + - v3Addr + ")}}}" - v3s5 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + - "){ps2:(*" + v3t2 + ")}}}}" - v3s6 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + - ")}}}" - v3s7 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + - tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + "){ps2:(*" + v3t2 + - ")(" + tic2Addr + ")}}}}" - v3s8 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + - tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + ")}}}" - addFormatterTest("%v", v3, v3s) - addFormatterTest("%v", pv3, "<*>"+v3s2) - addFormatterTest("%v", &pv3, "<**>"+v3s2) - addFormatterTest("%+v", v3, v3s3) - addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s4) - addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s4) - addFormatterTest("%#v", v3, "("+v3t+")"+v3s5) - addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s6) - addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s6) - addFormatterTest("%#+v", v3, "("+v3t+")"+v3s7) - addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s8) - addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s8) -} - -func addPanicFormatterTests() { - // Type that panics in its Stringer interface. - v := panicer(127) - nv := (*panicer)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.panicer" - vs := "(PANIC=test panic)127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addErrorFormatterTests() { - // Type that has a custom Error interface. - v := customError(127) - nv := (*customError)(nil) - pv := &v - vAddr := fmt.Sprintf("%p", pv) - pvAddr := fmt.Sprintf("%p", &pv) - vt := "spew_test.customError" - vs := "error: 127" - addFormatterTest("%v", v, vs) - addFormatterTest("%v", pv, "<*>"+vs) - addFormatterTest("%v", &pv, "<**>"+vs) - addFormatterTest("%v", nv, "") - addFormatterTest("%+v", v, vs) - addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) - addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%+v", nv, "") - addFormatterTest("%#v", v, "("+vt+")"+vs) - addFormatterTest("%#v", pv, "(*"+vt+")"+vs) - addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) - addFormatterTest("%#v", nv, "(*"+vt+")"+"") - addFormatterTest("%#+v", v, "("+vt+")"+vs) - addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) - addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) - addFormatterTest("%#+v", nv, "(*"+vt+")"+"") -} - -func addPassthroughFormatterTests() { - // %x passthrough with uint. - v := uint(4294967295) - pv := &v - vAddr := fmt.Sprintf("%x", pv) - pvAddr := fmt.Sprintf("%x", &pv) - vs := "ffffffff" - addFormatterTest("%x", v, vs) - addFormatterTest("%x", pv, vAddr) - addFormatterTest("%x", &pv, pvAddr) - - // %#x passthrough with uint. - v2 := int(2147483647) - pv2 := &v2 - v2Addr := fmt.Sprintf("%#x", pv2) - pv2Addr := fmt.Sprintf("%#x", &pv2) - v2s := "0x7fffffff" - addFormatterTest("%#x", v2, v2s) - addFormatterTest("%#x", pv2, v2Addr) - addFormatterTest("%#x", &pv2, pv2Addr) - - // %f passthrough with precision. - addFormatterTest("%.2f", 3.1415, "3.14") - addFormatterTest("%.3f", 3.1415, "3.142") - addFormatterTest("%.4f", 3.1415, "3.1415") - - // %f passthrough with width and precision. - addFormatterTest("%5.2f", 3.1415, " 3.14") - addFormatterTest("%6.3f", 3.1415, " 3.142") - addFormatterTest("%7.4f", 3.1415, " 3.1415") - - // %d passthrough with width. - addFormatterTest("%3d", 127, "127") - addFormatterTest("%4d", 127, " 127") - addFormatterTest("%5d", 127, " 127") - - // %q passthrough with string. - addFormatterTest("%q", "test", "\"test\"") -} - -// TestFormatter executes all of the tests described by formatterTests. -func TestFormatter(t *testing.T) { - // Setup tests. - addIntFormatterTests() - addUintFormatterTests() - addBoolFormatterTests() - addFloatFormatterTests() - addComplexFormatterTests() - addArrayFormatterTests() - addSliceFormatterTests() - addStringFormatterTests() - addInterfaceFormatterTests() - addMapFormatterTests() - addStructFormatterTests() - addUintptrFormatterTests() - addUnsafePointerFormatterTests() - addChanFormatterTests() - addFuncFormatterTests() - addCircularFormatterTests() - addPanicFormatterTests() - addErrorFormatterTests() - addPassthroughFormatterTests() - - t.Logf("Running %d tests", len(formatterTests)) - for i, test := range formatterTests { - buf := new(bytes.Buffer) - spew.Fprintf(buf, test.format, test.in) - s := buf.String() - if testFailed(s, test.wants) { - t.Errorf("Formatter #%d format: %s got: %s %s", i, test.format, s, - stringizeWants(test.wants)) - continue - } - } -} - -type testStruct struct { - x int -} - -func (ts testStruct) String() string { - return fmt.Sprintf("ts.%d", ts.x) -} - -type testStructP struct { - x int -} - -func (ts *testStructP) String() string { - return fmt.Sprintf("ts.%d", ts.x) -} - -func TestPrintSortedKeys(t *testing.T) { - cfg := spew.ConfigState{SortKeys: true} - s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"}) - expected := "map[1:1 2:2 3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch 1:\n %v %v", s, expected) - } - - s = cfg.Sprint(map[stringer]int{"1": 1, "3": 3, "2": 2}) - expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch 2:\n %v %v", s, expected) - } - - s = cfg.Sprint(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) - expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" - if spew.UnsafeDisabled { - expected = "map[1:1 2:2 3:3]" - } - if s != expected { - t.Errorf("Sorted keys mismatch 3:\n %v %v", s, expected) - } - - s = cfg.Sprint(map[testStruct]int{{1}: 1, {3}: 3, {2}: 2}) - expected = "map[ts.1:1 ts.2:2 ts.3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch 4:\n %v %v", s, expected) - } - - if !spew.UnsafeDisabled { - s = cfg.Sprint(map[testStructP]int{{1}: 1, {3}: 3, {2}: 2}) - expected = "map[ts.1:1 ts.2:2 ts.3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch 5:\n %v %v", s, expected) - } - } - - s = cfg.Sprint(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) - expected = "map[error: 1:1 error: 2:2 error: 3:3]" - if s != expected { - t.Errorf("Sorted keys mismatch 6:\n %v %v", s, expected) - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/internal_test.go b/vendor/github.com/davecgh/go-spew/spew/internal_test.go deleted file mode 100644 index e312b4f..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/internal_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* -This test file is part of the spew package rather than than the spew_test -package because it needs access to internals to properly test certain cases -which are not possible via the public interface since they should never happen. -*/ - -package spew - -import ( - "bytes" - "reflect" - "testing" -) - -// dummyFmtState implements a fake fmt.State to use for testing invalid -// reflect.Value handling. This is necessary because the fmt package catches -// invalid values before invoking the formatter on them. -type dummyFmtState struct { - bytes.Buffer -} - -func (dfs *dummyFmtState) Flag(f int) bool { - return f == int('+') -} - -func (dfs *dummyFmtState) Precision() (int, bool) { - return 0, false -} - -func (dfs *dummyFmtState) Width() (int, bool) { - return 0, false -} - -// TestInvalidReflectValue ensures the dump and formatter code handles an -// invalid reflect value properly. This needs access to internal state since it -// should never happen in real code and therefore can't be tested via the public -// API. -func TestInvalidReflectValue(t *testing.T) { - i := 1 - - // Dump invalid reflect value. - v := new(reflect.Value) - buf := new(bytes.Buffer) - d := dumpState{w: buf, cs: &Config} - d.dump(*v) - s := buf.String() - want := "" - if s != want { - t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want) - } - i++ - - // Formatter invalid reflect value. - buf2 := new(dummyFmtState) - f := formatState{value: *v, cs: &Config, fs: buf2} - f.format(*v) - s = buf2.String() - want = "" - if s != want { - t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want) - } -} - -// SortValues makes the internal sortValues function available to the test -// package. -func SortValues(values []reflect.Value, cs *ConfigState) { - sortValues(values, cs) -} diff --git a/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go b/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go deleted file mode 100644 index 80dc221..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2013-2016 Dave Collins - -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. - -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when the code is not running on Google App Engine, compiled by GopherJS, and -// "-tags safe" is not added to the go build command line. The "disableunsafe" -// tag is deprecated and thus should not be used. -// +build !js,!appengine,!safe,!disableunsafe,go1.4 - -/* -This test file is part of the spew package rather than than the spew_test -package because it needs access to internals to properly test certain cases -which are not possible via the public interface since they should never happen. -*/ - -package spew - -import ( - "bytes" - "reflect" - "testing" -) - -// changeKind uses unsafe to intentionally change the kind of a reflect.Value to -// the maximum kind value which does not exist. This is needed to test the -// fallback code which punts to the standard fmt library for new types that -// might get added to the language. -func changeKind(v *reflect.Value, readOnly bool) { - flags := flagField(v) - if readOnly { - *flags |= flagRO - } else { - *flags &^= flagRO - } - *flags |= flagKindMask -} - -// TestAddedReflectValue tests functionaly of the dump and formatter code which -// falls back to the standard fmt library for new types that might get added to -// the language. -func TestAddedReflectValue(t *testing.T) { - i := 1 - - // Dump using a reflect.Value that is exported. - v := reflect.ValueOf(int8(5)) - changeKind(&v, false) - buf := new(bytes.Buffer) - d := dumpState{w: buf, cs: &Config} - d.dump(v) - s := buf.String() - want := "(int8) 5" - if s != want { - t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want) - } - i++ - - // Dump using a reflect.Value that is not exported. - changeKind(&v, true) - buf.Reset() - d.dump(v) - s = buf.String() - want = "(int8) " - if s != want { - t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want) - } - i++ - - // Formatter using a reflect.Value that is exported. - changeKind(&v, false) - buf2 := new(dummyFmtState) - f := formatState{value: v, cs: &Config, fs: buf2} - f.format(v) - s = buf2.String() - want = "5" - if s != want { - t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want) - } - i++ - - // Formatter using a reflect.Value that is not exported. - changeKind(&v, true) - buf2.Reset() - f = formatState{value: v, cs: &Config, fs: buf2} - f.format(v) - s = buf2.String() - want = "" - if s != want { - t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want) - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew.go b/vendor/github.com/davecgh/go-spew/spew/spew.go deleted file mode 100644 index 32c0e33..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/spew.go +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew - -import ( - "fmt" - "io" -) - -// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the formatted string as a value that satisfies error. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Errorf(format string, a ...interface{}) (err error) { - return fmt.Errorf(format, convertArgs(a)...) -} - -// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprint(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprint(w, convertArgs(a)...) -} - -// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { - return fmt.Fprintf(w, format, convertArgs(a)...) -} - -// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it -// passed with a default Formatter interface returned by NewFormatter. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) -func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { - return fmt.Fprintln(w, convertArgs(a)...) -} - -// Print is a wrapper for fmt.Print that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) -func Print(a ...interface{}) (n int, err error) { - return fmt.Print(convertArgs(a)...) -} - -// Printf is a wrapper for fmt.Printf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Printf(format string, a ...interface{}) (n int, err error) { - return fmt.Printf(format, convertArgs(a)...) -} - -// Println is a wrapper for fmt.Println that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the number of bytes written and any write error encountered. See -// NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) -func Println(a ...interface{}) (n int, err error) { - return fmt.Println(convertArgs(a)...) -} - -// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprint(a ...interface{}) string { - return fmt.Sprint(convertArgs(a)...) -} - -// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were -// passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprintf(format string, a ...interface{}) string { - return fmt.Sprintf(format, convertArgs(a)...) -} - -// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it -// were passed with a default Formatter interface returned by NewFormatter. It -// returns the resulting string. See NewFormatter for formatting details. -// -// This function is shorthand for the following syntax: -// -// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) -func Sprintln(a ...interface{}) string { - return fmt.Sprintln(convertArgs(a)...) -} - -// convertArgs accepts a slice of arguments and returns a slice of the same -// length with each argument converted to a default spew Formatter interface. -func convertArgs(args []interface{}) (formatters []interface{}) { - formatters = make([]interface{}, len(args)) - for index, arg := range args { - formatters[index] = NewFormatter(arg) - } - return formatters -} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew_test.go b/vendor/github.com/davecgh/go-spew/spew/spew_test.go deleted file mode 100644 index b70466c..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/spew_test.go +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (c) 2013-2016 Dave Collins - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package spew_test - -import ( - "bytes" - "fmt" - "io/ioutil" - "os" - "testing" - - "github.com/davecgh/go-spew/spew" -) - -// spewFunc is used to identify which public function of the spew package or -// ConfigState a test applies to. -type spewFunc int - -const ( - fCSFdump spewFunc = iota - fCSFprint - fCSFprintf - fCSFprintln - fCSPrint - fCSPrintln - fCSSdump - fCSSprint - fCSSprintf - fCSSprintln - fCSErrorf - fCSNewFormatter - fErrorf - fFprint - fFprintln - fPrint - fPrintln - fSdump - fSprint - fSprintf - fSprintln -) - -// Map of spewFunc values to names for pretty printing. -var spewFuncStrings = map[spewFunc]string{ - fCSFdump: "ConfigState.Fdump", - fCSFprint: "ConfigState.Fprint", - fCSFprintf: "ConfigState.Fprintf", - fCSFprintln: "ConfigState.Fprintln", - fCSSdump: "ConfigState.Sdump", - fCSPrint: "ConfigState.Print", - fCSPrintln: "ConfigState.Println", - fCSSprint: "ConfigState.Sprint", - fCSSprintf: "ConfigState.Sprintf", - fCSSprintln: "ConfigState.Sprintln", - fCSErrorf: "ConfigState.Errorf", - fCSNewFormatter: "ConfigState.NewFormatter", - fErrorf: "spew.Errorf", - fFprint: "spew.Fprint", - fFprintln: "spew.Fprintln", - fPrint: "spew.Print", - fPrintln: "spew.Println", - fSdump: "spew.Sdump", - fSprint: "spew.Sprint", - fSprintf: "spew.Sprintf", - fSprintln: "spew.Sprintln", -} - -func (f spewFunc) String() string { - if s, ok := spewFuncStrings[f]; ok { - return s - } - return fmt.Sprintf("Unknown spewFunc (%d)", int(f)) -} - -// spewTest is used to describe a test to be performed against the public -// functions of the spew package or ConfigState. -type spewTest struct { - cs *spew.ConfigState - f spewFunc - format string - in interface{} - want string -} - -// spewTests houses the tests to be performed against the public functions of -// the spew package and ConfigState. -// -// These tests are only intended to ensure the public functions are exercised -// and are intentionally not exhaustive of types. The exhaustive type -// tests are handled in the dump and format tests. -var spewTests []spewTest - -// redirStdout is a helper function to return the standard output from f as a -// byte slice. -func redirStdout(f func()) ([]byte, error) { - tempFile, err := ioutil.TempFile("", "ss-test") - if err != nil { - return nil, err - } - fileName := tempFile.Name() - defer os.Remove(fileName) // Ignore error - - origStdout := os.Stdout - os.Stdout = tempFile - f() - os.Stdout = origStdout - tempFile.Close() - - return ioutil.ReadFile(fileName) -} - -func initSpewTests() { - // Config states with various settings. - scsDefault := spew.NewDefaultConfig() - scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true} - scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true} - scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1} - scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} - scsNoPtrAddr := &spew.ConfigState{DisablePointerAddresses: true} - scsNoCap := &spew.ConfigState{DisableCapacities: true} - - // Variables for tests on types which implement Stringer interface with and - // without a pointer receiver. - ts := stringer("test") - tps := pstringer("test") - - type ptrTester struct { - s *struct{} - } - tptr := &ptrTester{s: &struct{}{}} - - // depthTester is used to test max depth handling for structs, array, slices - // and maps. - type depthTester struct { - ic indirCir1 - arr [1]string - slice []string - m map[string]int - } - dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"}, - map[string]int{"one": 1}} - - // Variable for tests on types which implement error interface. - te := customError(10) - - spewTests = []spewTest{ - {scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"}, - {scsDefault, fCSFprint, "", int16(32767), "32767"}, - {scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"}, - {scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"}, - {scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"}, - {scsDefault, fCSPrintln, "", uint8(255), "255\n"}, - {scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"}, - {scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"}, - {scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"}, - {scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"}, - {scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"}, - {scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"}, - {scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"}, - {scsDefault, fFprint, "", float32(3.14), "3.14"}, - {scsDefault, fFprintln, "", float64(6.28), "6.28\n"}, - {scsDefault, fPrint, "", true, "true"}, - {scsDefault, fPrintln, "", false, "false\n"}, - {scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"}, - {scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"}, - {scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"}, - {scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"}, - {scsNoMethods, fCSFprint, "", ts, "test"}, - {scsNoMethods, fCSFprint, "", &ts, "<*>test"}, - {scsNoMethods, fCSFprint, "", tps, "test"}, - {scsNoMethods, fCSFprint, "", &tps, "<*>test"}, - {scsNoPmethods, fCSFprint, "", ts, "stringer test"}, - {scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"}, - {scsNoPmethods, fCSFprint, "", tps, "test"}, - {scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"}, - {scsMaxDepth, fCSFprint, "", dt, "{{} [] [] map[]}"}, - {scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" + - " ic: (spew_test.indirCir1) {\n \n },\n" + - " arr: ([1]string) (len=1 cap=1) {\n \n },\n" + - " slice: ([]string) (len=1 cap=1) {\n \n },\n" + - " m: (map[string]int) (len=1) {\n \n }\n}\n"}, - {scsContinue, fCSFprint, "", ts, "(stringer test) test"}, - {scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " + - "(len=4) (stringer test) \"test\"\n"}, - {scsContinue, fCSFprint, "", te, "(error: 10) 10"}, - {scsContinue, fCSFdump, "", te, "(spew_test.customError) " + - "(error: 10) 10\n"}, - {scsNoPtrAddr, fCSFprint, "", tptr, "<*>{<*>{}}"}, - {scsNoPtrAddr, fCSSdump, "", tptr, "(*spew_test.ptrTester)({\ns: (*struct {})({\n})\n})\n"}, - {scsNoCap, fCSSdump, "", make([]string, 0, 10), "([]string) {\n}\n"}, - {scsNoCap, fCSSdump, "", make([]string, 1, 10), "([]string) (len=1) {\n(string) \"\"\n}\n"}, - } -} - -// TestSpew executes all of the tests described by spewTests. -func TestSpew(t *testing.T) { - initSpewTests() - - t.Logf("Running %d tests", len(spewTests)) - for i, test := range spewTests { - buf := new(bytes.Buffer) - switch test.f { - case fCSFdump: - test.cs.Fdump(buf, test.in) - - case fCSFprint: - test.cs.Fprint(buf, test.in) - - case fCSFprintf: - test.cs.Fprintf(buf, test.format, test.in) - - case fCSFprintln: - test.cs.Fprintln(buf, test.in) - - case fCSPrint: - b, err := redirStdout(func() { test.cs.Print(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fCSPrintln: - b, err := redirStdout(func() { test.cs.Println(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fCSSdump: - str := test.cs.Sdump(test.in) - buf.WriteString(str) - - case fCSSprint: - str := test.cs.Sprint(test.in) - buf.WriteString(str) - - case fCSSprintf: - str := test.cs.Sprintf(test.format, test.in) - buf.WriteString(str) - - case fCSSprintln: - str := test.cs.Sprintln(test.in) - buf.WriteString(str) - - case fCSErrorf: - err := test.cs.Errorf(test.format, test.in) - buf.WriteString(err.Error()) - - case fCSNewFormatter: - fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in)) - - case fErrorf: - err := spew.Errorf(test.format, test.in) - buf.WriteString(err.Error()) - - case fFprint: - spew.Fprint(buf, test.in) - - case fFprintln: - spew.Fprintln(buf, test.in) - - case fPrint: - b, err := redirStdout(func() { spew.Print(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fPrintln: - b, err := redirStdout(func() { spew.Println(test.in) }) - if err != nil { - t.Errorf("%v #%d %v", test.f, i, err) - continue - } - buf.Write(b) - - case fSdump: - str := spew.Sdump(test.in) - buf.WriteString(str) - - case fSprint: - str := spew.Sprint(test.in) - buf.WriteString(str) - - case fSprintf: - str := spew.Sprintf(test.format, test.in) - buf.WriteString(str) - - case fSprintln: - str := spew.Sprintln(test.in) - buf.WriteString(str) - - default: - t.Errorf("%v #%d unrecognized function", test.f, i) - continue - } - s := buf.String() - if test.want != s { - t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want) - continue - } - } -} diff --git a/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go b/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go deleted file mode 100644 index 5c87dd4..0000000 --- a/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2013 Dave Collins -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -// NOTE: Due to the following build constraints, this file will only be compiled -// when both cgo is supported and "-tags testcgo" is added to the go test -// command line. This code should really only be in the dumpcgo_test.go file, -// but unfortunately Go will not allow cgo in test files, so this is a -// workaround to allow cgo types to be tested. This configuration is used -// because spew itself does not require cgo to run even though it does handle -// certain cgo types specially. Rather than forcing all clients to require cgo -// and an external C compiler just to run the tests, this scheme makes them -// optional. -// +build cgo,testcgo - -package testdata - -/* -#include -typedef unsigned char custom_uchar_t; - -char *ncp = 0; -char *cp = "test"; -char ca[6] = {'t', 'e', 's', 't', '2', '\0'}; -unsigned char uca[6] = {'t', 'e', 's', 't', '3', '\0'}; -signed char sca[6] = {'t', 'e', 's', 't', '4', '\0'}; -uint8_t ui8ta[6] = {'t', 'e', 's', 't', '5', '\0'}; -custom_uchar_t tuca[6] = {'t', 'e', 's', 't', '6', '\0'}; -*/ -import "C" - -// GetCgoNullCharPointer returns a null char pointer via cgo. This is only -// used for tests. -func GetCgoNullCharPointer() interface{} { - return C.ncp -} - -// GetCgoCharPointer returns a char pointer via cgo. This is only used for -// tests. -func GetCgoCharPointer() interface{} { - return C.cp -} - -// GetCgoCharArray returns a char array via cgo and the array's len and cap. -// This is only used for tests. -func GetCgoCharArray() (interface{}, int, int) { - return C.ca, len(C.ca), cap(C.ca) -} - -// GetCgoUnsignedCharArray returns an unsigned char array via cgo and the -// array's len and cap. This is only used for tests. -func GetCgoUnsignedCharArray() (interface{}, int, int) { - return C.uca, len(C.uca), cap(C.uca) -} - -// GetCgoSignedCharArray returns a signed char array via cgo and the array's len -// and cap. This is only used for tests. -func GetCgoSignedCharArray() (interface{}, int, int) { - return C.sca, len(C.sca), cap(C.sca) -} - -// GetCgoUint8tArray returns a uint8_t array via cgo and the array's len and -// cap. This is only used for tests. -func GetCgoUint8tArray() (interface{}, int, int) { - return C.ui8ta, len(C.ui8ta), cap(C.ui8ta) -} - -// GetCgoTypdefedUnsignedCharArray returns a typedefed unsigned char array via -// cgo and the array's len and cap. This is only used for tests. -func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) { - return C.tuca, len(C.tuca), cap(C.tuca) -} diff --git a/vendor/github.com/davecgh/go-spew/test_coverage.txt b/vendor/github.com/davecgh/go-spew/test_coverage.txt deleted file mode 100644 index 2cd087a..0000000 --- a/vendor/github.com/davecgh/go-spew/test_coverage.txt +++ /dev/null @@ -1,61 +0,0 @@ - -github.com/davecgh/go-spew/spew/dump.go dumpState.dump 100.00% (88/88) -github.com/davecgh/go-spew/spew/format.go formatState.format 100.00% (82/82) -github.com/davecgh/go-spew/spew/format.go formatState.formatPtr 100.00% (52/52) -github.com/davecgh/go-spew/spew/dump.go dumpState.dumpPtr 100.00% (44/44) -github.com/davecgh/go-spew/spew/dump.go dumpState.dumpSlice 100.00% (39/39) -github.com/davecgh/go-spew/spew/common.go handleMethods 100.00% (30/30) -github.com/davecgh/go-spew/spew/common.go printHexPtr 100.00% (18/18) -github.com/davecgh/go-spew/spew/common.go unsafeReflectValue 100.00% (13/13) -github.com/davecgh/go-spew/spew/format.go formatState.constructOrigFormat 100.00% (12/12) -github.com/davecgh/go-spew/spew/dump.go fdump 100.00% (11/11) -github.com/davecgh/go-spew/spew/format.go formatState.Format 100.00% (11/11) -github.com/davecgh/go-spew/spew/common.go init 100.00% (10/10) -github.com/davecgh/go-spew/spew/common.go printComplex 100.00% (9/9) -github.com/davecgh/go-spew/spew/common.go valuesSorter.Less 100.00% (8/8) -github.com/davecgh/go-spew/spew/format.go formatState.buildDefaultFormat 100.00% (7/7) -github.com/davecgh/go-spew/spew/format.go formatState.unpackValue 100.00% (5/5) -github.com/davecgh/go-spew/spew/dump.go dumpState.indent 100.00% (4/4) -github.com/davecgh/go-spew/spew/common.go catchPanic 100.00% (4/4) -github.com/davecgh/go-spew/spew/config.go ConfigState.convertArgs 100.00% (4/4) -github.com/davecgh/go-spew/spew/spew.go convertArgs 100.00% (4/4) -github.com/davecgh/go-spew/spew/format.go newFormatter 100.00% (3/3) -github.com/davecgh/go-spew/spew/dump.go Sdump 100.00% (3/3) -github.com/davecgh/go-spew/spew/common.go printBool 100.00% (3/3) -github.com/davecgh/go-spew/spew/common.go sortValues 100.00% (3/3) -github.com/davecgh/go-spew/spew/config.go ConfigState.Sdump 100.00% (3/3) -github.com/davecgh/go-spew/spew/dump.go dumpState.unpackValue 100.00% (3/3) -github.com/davecgh/go-spew/spew/spew.go Printf 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Println 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Sprint 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Sprintf 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Sprintln 100.00% (1/1) -github.com/davecgh/go-spew/spew/common.go printFloat 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go NewDefaultConfig 100.00% (1/1) -github.com/davecgh/go-spew/spew/common.go printInt 100.00% (1/1) -github.com/davecgh/go-spew/spew/common.go printUint 100.00% (1/1) -github.com/davecgh/go-spew/spew/common.go valuesSorter.Len 100.00% (1/1) -github.com/davecgh/go-spew/spew/common.go valuesSorter.Swap 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Errorf 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Fprint 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintf 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintln 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Print 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Printf 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Println 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Sprint 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintf 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintln 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.NewFormatter 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Fdump 100.00% (1/1) -github.com/davecgh/go-spew/spew/config.go ConfigState.Dump 100.00% (1/1) -github.com/davecgh/go-spew/spew/dump.go Fdump 100.00% (1/1) -github.com/davecgh/go-spew/spew/dump.go Dump 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Fprintln 100.00% (1/1) -github.com/davecgh/go-spew/spew/format.go NewFormatter 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Errorf 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Fprint 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Fprintf 100.00% (1/1) -github.com/davecgh/go-spew/spew/spew.go Print 100.00% (1/1) -github.com/davecgh/go-spew/spew ------------------------------- 100.00% (505/505) - diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/vendor/github.com/pkg/errors/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml deleted file mode 100644 index 7ca408d..0000000 --- a/vendor/github.com/pkg/errors/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go -go_import_path: github.com/pkg/errors -go: - - 1.4.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - tip - -script: - - go test -v ./... diff --git a/vendor/github.com/pkg/errors/LICENSE b/vendor/github.com/pkg/errors/LICENSE deleted file mode 100644 index 835ba3e..0000000 --- a/vendor/github.com/pkg/errors/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2015, Dave Cheney -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md deleted file mode 100644 index 6483ba2..0000000 --- a/vendor/github.com/pkg/errors/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) - -Package errors provides simple error handling primitives. - -`go get github.com/pkg/errors` - -The traditional error handling idiom in Go is roughly akin to -```go -if err != nil { - return err -} -``` -which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. - -## Adding context to an error - -The errors.Wrap function returns a new error that adds context to the original error. For example -```go -_, err := ioutil.ReadAll(r) -if err != nil { - return errors.Wrap(err, "read failed") -} -``` -## Retrieving the cause of an error - -Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. -```go -type causer interface { - Cause() error -} -``` -`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: -```go -switch err := errors.Cause(err).(type) { -case *MyError: - // handle specifically -default: - // unknown error -} -``` - -[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). - -## Contributing - -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. - -Before proposing a change, please discuss your change by raising an issue. - -## License - -BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/appveyor.yml b/vendor/github.com/pkg/errors/appveyor.yml deleted file mode 100644 index a932ead..0000000 --- a/vendor/github.com/pkg/errors/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\pkg\errors -shallow_clone: true # for startup speed - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -# http://www.appveyor.com/docs/installed-software -install: - # some helpful output for debugging builds - - go version - - go env - # pre-installed MinGW at C:\MinGW is 32bit only - # but MSYS2 at C:\msys64 has mingw64 - - set PATH=C:\msys64\mingw64\bin;%PATH% - - gcc --version - - g++ --version - -build_script: - - go install -v ./... - -test_script: - - set PATH=C:\gopath\bin;%PATH% - - go test -v ./... - -#artifacts: -# - path: '%GOPATH%\bin\*.exe' -deploy: off diff --git a/vendor/github.com/pkg/errors/bench_test.go b/vendor/github.com/pkg/errors/bench_test.go deleted file mode 100644 index 903b5f2..0000000 --- a/vendor/github.com/pkg/errors/bench_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// +build go1.7 - -package errors - -import ( - "fmt" - "testing" - - stderrors "errors" -) - -func noErrors(at, depth int) error { - if at >= depth { - return stderrors.New("no error") - } - return noErrors(at+1, depth) -} - -func yesErrors(at, depth int) error { - if at >= depth { - return New("ye error") - } - return yesErrors(at+1, depth) -} - -// GlobalE is an exported global to store the result of benchmark results, -// preventing the compiler from optimising the benchmark functions away. -var GlobalE error - -func BenchmarkErrors(b *testing.B) { - type run struct { - stack int - std bool - } - runs := []run{ - {10, false}, - {10, true}, - {100, false}, - {100, true}, - {1000, false}, - {1000, true}, - } - for _, r := range runs { - part := "pkg/errors" - if r.std { - part = "errors" - } - name := fmt.Sprintf("%s-stack-%d", part, r.stack) - b.Run(name, func(b *testing.B) { - var err error - f := yesErrors - if r.std { - f = noErrors - } - b.ReportAllocs() - for i := 0; i < b.N; i++ { - err = f(0, r.stack) - } - b.StopTimer() - GlobalE = err - }) - } -} diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go deleted file mode 100644 index 842ee80..0000000 --- a/vendor/github.com/pkg/errors/errors.go +++ /dev/null @@ -1,269 +0,0 @@ -// Package errors provides simple error handling primitives. -// -// The traditional error handling idiom in Go is roughly akin to -// -// if err != nil { -// return err -// } -// -// which applied recursively up the call stack results in error reports -// without context or debugging information. The errors package allows -// programmers to add context to the failure path in their code in a way -// that does not destroy the original value of the error. -// -// Adding context to an error -// -// The errors.Wrap function returns a new error that adds context to the -// original error by recording a stack trace at the point Wrap is called, -// and the supplied message. For example -// -// _, err := ioutil.ReadAll(r) -// if err != nil { -// return errors.Wrap(err, "read failed") -// } -// -// If additional control is required the errors.WithStack and errors.WithMessage -// functions destructure errors.Wrap into its component operations of annotating -// an error with a stack trace and an a message, respectively. -// -// Retrieving the cause of an error -// -// Using errors.Wrap constructs a stack of errors, adding context to the -// preceding error. Depending on the nature of the error it may be necessary -// to reverse the operation of errors.Wrap to retrieve the original error -// for inspection. Any error value which implements this interface -// -// type causer interface { -// Cause() error -// } -// -// can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error which does not implement causer, which is assumed to be -// the original cause. For example: -// -// switch err := errors.Cause(err).(type) { -// case *MyError: -// // handle specifically -// default: -// // unknown error -// } -// -// causer interface is not exported by this package, but is considered a part -// of stable public API. -// -// Formatted printing of errors -// -// All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported -// -// %s print the error. If the error has a Cause it will be -// printed recursively -// %v see %s -// %+v extended format. Each Frame of the error's StackTrace will -// be printed in detail. -// -// Retrieving the stack trace of an error or wrapper -// -// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface. -// -// type stackTracer interface { -// StackTrace() errors.StackTrace -// } -// -// Where errors.StackTrace is defined as -// -// type StackTrace []Frame -// -// The Frame type represents a call site in the stack trace. Frame supports -// the fmt.Formatter interface that can be used for printing information about -// the stack trace of this error. For example: -// -// if err, ok := err.(stackTracer); ok { -// for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d", f) -// } -// } -// -// stackTracer interface is not exported by this package, but is considered a part -// of stable public API. -// -// See the documentation for Frame.Format for more details. -package errors - -import ( - "fmt" - "io" -) - -// New returns an error with the supplied message. -// New also records the stack trace at the point it was called. -func New(message string) error { - return &fundamental{ - msg: message, - stack: callers(), - } -} - -// Errorf formats according to a format specifier and returns the string -// as a value that satisfies error. -// Errorf also records the stack trace at the point it was called. -func Errorf(format string, args ...interface{}) error { - return &fundamental{ - msg: fmt.Sprintf(format, args...), - stack: callers(), - } -} - -// fundamental is an error that has a message and a stack, but no caller. -type fundamental struct { - msg string - *stack -} - -func (f *fundamental) Error() string { return f.msg } - -func (f *fundamental) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, f.msg) - f.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, f.msg) - case 'q': - fmt.Fprintf(s, "%q", f.msg) - } -} - -// WithStack annotates err with a stack trace at the point WithStack was called. -// If err is nil, WithStack returns nil. -func WithStack(err error) error { - if err == nil { - return nil - } - return &withStack{ - err, - callers(), - } -} - -type withStack struct { - error - *stack -} - -func (w *withStack) Cause() error { return w.error } - -func (w *withStack) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v", w.Cause()) - w.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, w.Error()) - case 'q': - fmt.Fprintf(s, "%q", w.Error()) - } -} - -// Wrap returns an error annotating err with a stack trace -// at the point Wrap is called, and the supplied message. -// If err is nil, Wrap returns nil. -func Wrap(err error, message string) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: message, - } - return &withStack{ - err, - callers(), - } -} - -// Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is call, and the format specifier. -// If err is nil, Wrapf returns nil. -func Wrapf(err error, format string, args ...interface{}) error { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } - return &withStack{ - err, - callers(), - } -} - -// WithMessage annotates err with a new message. -// If err is nil, WithMessage returns nil. -func WithMessage(err error, message string) error { - if err == nil { - return nil - } - return &withMessage{ - cause: err, - msg: message, - } -} - -type withMessage struct { - cause error - msg string -} - -func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } -func (w *withMessage) Cause() error { return w.cause } - -func (w *withMessage) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - return - } - fallthrough - case 's', 'q': - io.WriteString(s, w.Error()) - } -} - -// Cause returns the underlying cause of the error, if possible. -// An error value has a cause if it implements the following -// interface: -// -// type causer interface { -// Cause() error -// } -// -// If the error does not implement Cause, the original error will -// be returned. If the error is nil, nil will be returned without further -// investigation. -func Cause(err error) error { - type causer interface { - Cause() error - } - - for err != nil { - cause, ok := err.(causer) - if !ok { - break - } - err = cause.Cause() - } - return err -} diff --git a/vendor/github.com/pkg/errors/errors_test.go b/vendor/github.com/pkg/errors/errors_test.go deleted file mode 100644 index c4e6eef..0000000 --- a/vendor/github.com/pkg/errors/errors_test.go +++ /dev/null @@ -1,225 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "io" - "reflect" - "testing" -) - -func TestNew(t *testing.T) { - tests := []struct { - err string - want error - }{ - {"", fmt.Errorf("")}, - {"foo", fmt.Errorf("foo")}, - {"foo", New("foo")}, - {"string with format specifiers: %v", errors.New("string with format specifiers: %v")}, - } - - for _, tt := range tests { - got := New(tt.err) - if got.Error() != tt.want.Error() { - t.Errorf("New.Error(): got: %q, want %q", got, tt.want) - } - } -} - -func TestWrapNil(t *testing.T) { - got := Wrap(nil, "no error") - if got != nil { - t.Errorf("Wrap(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWrap(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {Wrap(io.EOF, "read error"), "client error", "client error: read error: EOF"}, - } - - for _, tt := range tests { - got := Wrap(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("Wrap(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) - } - } -} - -type nilError struct{} - -func (nilError) Error() string { return "nil error" } - -func TestCause(t *testing.T) { - x := New("error") - tests := []struct { - err error - want error - }{{ - // nil error is nil - err: nil, - want: nil, - }, { - // explicit nil error is nil - err: (error)(nil), - want: nil, - }, { - // typed nil is nil - err: (*nilError)(nil), - want: (*nilError)(nil), - }, { - // uncaused error is unaffected - err: io.EOF, - want: io.EOF, - }, { - // caused error returns cause - err: Wrap(io.EOF, "ignored"), - want: io.EOF, - }, { - err: x, // return from errors.New - want: x, - }, { - WithMessage(nil, "whoops"), - nil, - }, { - WithMessage(io.EOF, "whoops"), - io.EOF, - }, { - WithStack(nil), - nil, - }, { - WithStack(io.EOF), - io.EOF, - }} - - for i, tt := range tests { - got := Cause(tt.err) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("test %d: got %#v, want %#v", i+1, got, tt.want) - } - } -} - -func TestWrapfNil(t *testing.T) { - got := Wrapf(nil, "no error") - if got != nil { - t.Errorf("Wrapf(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWrapf(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {Wrapf(io.EOF, "read error without format specifiers"), "client error", "client error: read error without format specifiers: EOF"}, - {Wrapf(io.EOF, "read error with %d format specifier", 1), "client error", "client error: read error with 1 format specifier: EOF"}, - } - - for _, tt := range tests { - got := Wrapf(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("Wrapf(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) - } - } -} - -func TestErrorf(t *testing.T) { - tests := []struct { - err error - want string - }{ - {Errorf("read error without format specifiers"), "read error without format specifiers"}, - {Errorf("read error with %d format specifier", 1), "read error with 1 format specifier"}, - } - - for _, tt := range tests { - got := tt.err.Error() - if got != tt.want { - t.Errorf("Errorf(%v): got: %q, want %q", tt.err, got, tt.want) - } - } -} - -func TestWithStackNil(t *testing.T) { - got := WithStack(nil) - if got != nil { - t.Errorf("WithStack(nil): got %#v, expected nil", got) - } -} - -func TestWithStack(t *testing.T) { - tests := []struct { - err error - want string - }{ - {io.EOF, "EOF"}, - {WithStack(io.EOF), "EOF"}, - } - - for _, tt := range tests { - got := WithStack(tt.err).Error() - if got != tt.want { - t.Errorf("WithStack(%v): got: %v, want %v", tt.err, got, tt.want) - } - } -} - -func TestWithMessageNil(t *testing.T) { - got := WithMessage(nil, "no error") - if got != nil { - t.Errorf("WithMessage(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWithMessage(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {WithMessage(io.EOF, "read error"), "client error", "client error: read error: EOF"}, - } - - for _, tt := range tests { - got := WithMessage(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("WithMessage(%v, %q): got: %q, want %q", tt.err, tt.message, got, tt.want) - } - } -} - -// errors.New, etc values are not expected to be compared by value -// but the change in errors#27 made them incomparable. Assert that -// various kinds of errors have a functional equality operator, even -// if the result of that equality is always false. -func TestErrorEquality(t *testing.T) { - vals := []error{ - nil, - io.EOF, - errors.New("EOF"), - New("EOF"), - Errorf("EOF"), - Wrap(io.EOF, "EOF"), - Wrapf(io.EOF, "EOF%d", 2), - WithMessage(nil, "whoops"), - WithMessage(io.EOF, "whoops"), - WithStack(io.EOF), - WithStack(nil), - } - - for i := range vals { - for j := range vals { - _ = vals[i] == vals[j] // mustn't panic - } - } -} diff --git a/vendor/github.com/pkg/errors/example_test.go b/vendor/github.com/pkg/errors/example_test.go deleted file mode 100644 index c1fc13e..0000000 --- a/vendor/github.com/pkg/errors/example_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package errors_test - -import ( - "fmt" - - "github.com/pkg/errors" -) - -func ExampleNew() { - err := errors.New("whoops") - fmt.Println(err) - - // Output: whoops -} - -func ExampleNew_printf() { - err := errors.New("whoops") - fmt.Printf("%+v", err) - - // Example output: - // whoops - // github.com/pkg/errors_test.ExampleNew_printf - // /home/dfc/src/github.com/pkg/errors/example_test.go:17 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 -} - -func ExampleWithMessage() { - cause := errors.New("whoops") - err := errors.WithMessage(cause, "oh noes") - fmt.Println(err) - - // Output: oh noes: whoops -} - -func ExampleWithStack() { - cause := errors.New("whoops") - err := errors.WithStack(cause) - fmt.Println(err) - - // Output: whoops -} - -func ExampleWithStack_printf() { - cause := errors.New("whoops") - err := errors.WithStack(cause) - fmt.Printf("%+v", err) - - // Example Output: - // whoops - // github.com/pkg/errors_test.ExampleWithStack_printf - // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:55 - // testing.runExample - // /usr/lib/go/src/testing/example.go:114 - // testing.RunExamples - // /usr/lib/go/src/testing/example.go:38 - // testing.(*M).Run - // /usr/lib/go/src/testing/testing.go:744 - // main.main - // github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /usr/lib/go/src/runtime/proc.go:183 - // runtime.goexit - // /usr/lib/go/src/runtime/asm_amd64.s:2086 - // github.com/pkg/errors_test.ExampleWithStack_printf - // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:56 - // testing.runExample - // /usr/lib/go/src/testing/example.go:114 - // testing.RunExamples - // /usr/lib/go/src/testing/example.go:38 - // testing.(*M).Run - // /usr/lib/go/src/testing/testing.go:744 - // main.main - // github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /usr/lib/go/src/runtime/proc.go:183 - // runtime.goexit - // /usr/lib/go/src/runtime/asm_amd64.s:2086 -} - -func ExampleWrap() { - cause := errors.New("whoops") - err := errors.Wrap(cause, "oh noes") - fmt.Println(err) - - // Output: oh noes: whoops -} - -func fn() error { - e1 := errors.New("error") - e2 := errors.Wrap(e1, "inner") - e3 := errors.Wrap(e2, "middle") - return errors.Wrap(e3, "outer") -} - -func ExampleCause() { - err := fn() - fmt.Println(err) - fmt.Println(errors.Cause(err)) - - // Output: outer: middle: inner: error - // error -} - -func ExampleWrap_extended() { - err := fn() - fmt.Printf("%+v\n", err) - - // Example output: - // error - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:47 - // github.com/pkg/errors_test.ExampleCause_printf - // /home/dfc/src/github.com/pkg/errors/example_test.go:63 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:104 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:48: inner - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:49: middle - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:50: outer -} - -func ExampleWrapf() { - cause := errors.New("whoops") - err := errors.Wrapf(cause, "oh noes #%d", 2) - fmt.Println(err) - - // Output: oh noes #2: whoops -} - -func ExampleErrorf_extended() { - err := errors.Errorf("whoops: %s", "foo") - fmt.Printf("%+v", err) - - // Example output: - // whoops: foo - // github.com/pkg/errors_test.ExampleErrorf - // /home/dfc/src/github.com/pkg/errors/example_test.go:101 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:102 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 -} - -func Example_stackTrace() { - type stackTracer interface { - StackTrace() errors.StackTrace - } - - err, ok := errors.Cause(fn()).(stackTracer) - if !ok { - panic("oops, err does not implement stackTracer") - } - - st := err.StackTrace() - fmt.Printf("%+v", st[0:2]) // top two frames - - // Example output: - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:47 - // github.com/pkg/errors_test.Example_stackTrace - // /home/dfc/src/github.com/pkg/errors/example_test.go:127 -} - -func ExampleCause_printf() { - err := errors.Wrap(func() error { - return func() error { - return errors.Errorf("hello %s", fmt.Sprintf("world")) - }() - }(), "failed") - - fmt.Printf("%v", err) - - // Output: failed: hello world -} diff --git a/vendor/github.com/pkg/errors/format_test.go b/vendor/github.com/pkg/errors/format_test.go deleted file mode 100644 index c2eef5f..0000000 --- a/vendor/github.com/pkg/errors/format_test.go +++ /dev/null @@ -1,535 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "io" - "regexp" - "strings" - "testing" -) - -func TestFormatNew(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - New("error"), - "%s", - "error", - }, { - New("error"), - "%v", - "error", - }, { - New("error"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatNew\n" + - "\t.+/github.com/pkg/errors/format_test.go:26", - }, { - New("error"), - "%q", - `"error"`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatErrorf(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Errorf("%s", "error"), - "%s", - "error", - }, { - Errorf("%s", "error"), - "%v", - "error", - }, { - Errorf("%s", "error"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatErrorf\n" + - "\t.+/github.com/pkg/errors/format_test.go:56", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWrap(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Wrap(New("error"), "error2"), - "%s", - "error2: error", - }, { - Wrap(New("error"), "error2"), - "%v", - "error2: error", - }, { - Wrap(New("error"), "error2"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:82", - }, { - Wrap(io.EOF, "error"), - "%s", - "error: EOF", - }, { - Wrap(io.EOF, "error"), - "%v", - "error: EOF", - }, { - Wrap(io.EOF, "error"), - "%+v", - "EOF\n" + - "error\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:96", - }, { - Wrap(Wrap(io.EOF, "error1"), "error2"), - "%+v", - "EOF\n" + - "error1\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:103\n", - }, { - Wrap(New("error with space"), "context"), - "%q", - `"context: error with space"`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWrapf(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Wrapf(io.EOF, "error%d", 2), - "%s", - "error2: EOF", - }, { - Wrapf(io.EOF, "error%d", 2), - "%v", - "error2: EOF", - }, { - Wrapf(io.EOF, "error%d", 2), - "%+v", - "EOF\n" + - "error2\n" + - "github.com/pkg/errors.TestFormatWrapf\n" + - "\t.+/github.com/pkg/errors/format_test.go:134", - }, { - Wrapf(New("error"), "error%d", 2), - "%s", - "error2: error", - }, { - Wrapf(New("error"), "error%d", 2), - "%v", - "error2: error", - }, { - Wrapf(New("error"), "error%d", 2), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatWrapf\n" + - "\t.+/github.com/pkg/errors/format_test.go:149", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWithStack(t *testing.T) { - tests := []struct { - error - format string - want []string - }{{ - WithStack(io.EOF), - "%s", - []string{"EOF"}, - }, { - WithStack(io.EOF), - "%v", - []string{"EOF"}, - }, { - WithStack(io.EOF), - "%+v", - []string{"EOF", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:175"}, - }, { - WithStack(New("error")), - "%s", - []string{"error"}, - }, { - WithStack(New("error")), - "%v", - []string{"error"}, - }, { - WithStack(New("error")), - "%+v", - []string{"error", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:189", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:189"}, - }, { - WithStack(WithStack(io.EOF)), - "%+v", - []string{"EOF", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:197", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:197"}, - }, { - WithStack(WithStack(Wrapf(io.EOF, "message"))), - "%+v", - []string{"EOF", - "message", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205"}, - }, { - WithStack(Errorf("error%d", 1)), - "%+v", - []string{"error1", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:216", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:216"}, - }} - - for i, tt := range tests { - testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) - } -} - -func TestFormatWithMessage(t *testing.T) { - tests := []struct { - error - format string - want []string - }{{ - WithMessage(New("error"), "error2"), - "%s", - []string{"error2: error"}, - }, { - WithMessage(New("error"), "error2"), - "%v", - []string{"error2: error"}, - }, { - WithMessage(New("error"), "error2"), - "%+v", - []string{ - "error", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:244", - "error2"}, - }, { - WithMessage(io.EOF, "addition1"), - "%s", - []string{"addition1: EOF"}, - }, { - WithMessage(io.EOF, "addition1"), - "%v", - []string{"addition1: EOF"}, - }, { - WithMessage(io.EOF, "addition1"), - "%+v", - []string{"EOF", "addition1"}, - }, { - WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), - "%v", - []string{"addition2: addition1: EOF"}, - }, { - WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), - "%+v", - []string{"EOF", "addition1", "addition2"}, - }, { - Wrap(WithMessage(io.EOF, "error1"), "error2"), - "%+v", - []string{"EOF", "error1", "error2", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:272"}, - }, { - WithMessage(Errorf("error%d", 1), "error2"), - "%+v", - []string{"error1", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:278", - "error2"}, - }, { - WithMessage(WithStack(io.EOF), "error"), - "%+v", - []string{ - "EOF", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:285", - "error"}, - }, { - WithMessage(Wrap(WithStack(io.EOF), "inside-error"), "outside-error"), - "%+v", - []string{ - "EOF", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:293", - "inside-error", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:293", - "outside-error"}, - }} - - for i, tt := range tests { - testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) - } -} - -func TestFormatGeneric(t *testing.T) { - starts := []struct { - err error - want []string - }{ - {New("new-error"), []string{ - "new-error", - "github.com/pkg/errors.TestFormatGeneric\n" + - "\t.+/github.com/pkg/errors/format_test.go:315"}, - }, {Errorf("errorf-error"), []string{ - "errorf-error", - "github.com/pkg/errors.TestFormatGeneric\n" + - "\t.+/github.com/pkg/errors/format_test.go:319"}, - }, {errors.New("errors-new-error"), []string{ - "errors-new-error"}, - }, - } - - wrappers := []wrapper{ - { - func(err error) error { return WithMessage(err, "with-message") }, - []string{"with-message"}, - }, { - func(err error) error { return WithStack(err) }, - []string{ - "github.com/pkg/errors.(func·002|TestFormatGeneric.func2)\n\t" + - ".+/github.com/pkg/errors/format_test.go:333", - }, - }, { - func(err error) error { return Wrap(err, "wrap-error") }, - []string{ - "wrap-error", - "github.com/pkg/errors.(func·003|TestFormatGeneric.func3)\n\t" + - ".+/github.com/pkg/errors/format_test.go:339", - }, - }, { - func(err error) error { return Wrapf(err, "wrapf-error%d", 1) }, - []string{ - "wrapf-error1", - "github.com/pkg/errors.(func·004|TestFormatGeneric.func4)\n\t" + - ".+/github.com/pkg/errors/format_test.go:346", - }, - }, - } - - for s := range starts { - err := starts[s].err - want := starts[s].want - testFormatCompleteCompare(t, s, err, "%+v", want, false) - testGenericRecursive(t, err, want, wrappers, 3) - } -} - -func testFormatRegexp(t *testing.T, n int, arg interface{}, format, want string) { - got := fmt.Sprintf(format, arg) - gotLines := strings.SplitN(got, "\n", -1) - wantLines := strings.SplitN(want, "\n", -1) - - if len(wantLines) > len(gotLines) { - t.Errorf("test %d: wantLines(%d) > gotLines(%d):\n got: %q\nwant: %q", n+1, len(wantLines), len(gotLines), got, want) - return - } - - for i, w := range wantLines { - match, err := regexp.MatchString(w, gotLines[i]) - if err != nil { - t.Fatal(err) - } - if !match { - t.Errorf("test %d: line %d: fmt.Sprintf(%q, err):\n got: %q\nwant: %q", n+1, i+1, format, got, want) - } - } -} - -var stackLineR = regexp.MustCompile(`\.`) - -// parseBlocks parses input into a slice, where: -// - incase entry contains a newline, its a stacktrace -// - incase entry contains no newline, its a solo line. -// -// Detecting stack boundaries only works incase the WithStack-calls are -// to be found on the same line, thats why it is optionally here. -// -// Example use: -// -// for _, e := range blocks { -// if strings.ContainsAny(e, "\n") { -// // Match as stack -// } else { -// // Match as line -// } -// } -// -func parseBlocks(input string, detectStackboundaries bool) ([]string, error) { - var blocks []string - - stack := "" - wasStack := false - lines := map[string]bool{} // already found lines - - for _, l := range strings.Split(input, "\n") { - isStackLine := stackLineR.MatchString(l) - - switch { - case !isStackLine && wasStack: - blocks = append(blocks, stack, l) - stack = "" - lines = map[string]bool{} - case isStackLine: - if wasStack { - // Detecting two stacks after another, possible cause lines match in - // our tests due to WithStack(WithStack(io.EOF)) on same line. - if detectStackboundaries { - if lines[l] { - if len(stack) == 0 { - return nil, errors.New("len of block must not be zero here") - } - - blocks = append(blocks, stack) - stack = l - lines = map[string]bool{l: true} - continue - } - } - - stack = stack + "\n" + l - } else { - stack = l - } - lines[l] = true - case !isStackLine && !wasStack: - blocks = append(blocks, l) - default: - return nil, errors.New("must not happen") - } - - wasStack = isStackLine - } - - // Use up stack - if stack != "" { - blocks = append(blocks, stack) - } - return blocks, nil -} - -func testFormatCompleteCompare(t *testing.T, n int, arg interface{}, format string, want []string, detectStackBoundaries bool) { - gotStr := fmt.Sprintf(format, arg) - - got, err := parseBlocks(gotStr, detectStackBoundaries) - if err != nil { - t.Fatal(err) - } - - if len(got) != len(want) { - t.Fatalf("test %d: fmt.Sprintf(%s, err) -> wrong number of blocks: got(%d) want(%d)\n got: %s\nwant: %s\ngotStr: %q", - n+1, format, len(got), len(want), prettyBlocks(got), prettyBlocks(want), gotStr) - } - - for i := range got { - if strings.ContainsAny(want[i], "\n") { - // Match as stack - match, err := regexp.MatchString(want[i], got[i]) - if err != nil { - t.Fatal(err) - } - if !match { - t.Fatalf("test %d: block %d: fmt.Sprintf(%q, err):\ngot:\n%q\nwant:\n%q\nall-got:\n%s\nall-want:\n%s\n", - n+1, i+1, format, got[i], want[i], prettyBlocks(got), prettyBlocks(want)) - } - } else { - // Match as message - if got[i] != want[i] { - t.Fatalf("test %d: fmt.Sprintf(%s, err) at block %d got != want:\n got: %q\nwant: %q", n+1, format, i+1, got[i], want[i]) - } - } - } -} - -type wrapper struct { - wrap func(err error) error - want []string -} - -func prettyBlocks(blocks []string) string { - var out []string - - for _, b := range blocks { - out = append(out, fmt.Sprintf("%v", b)) - } - - return " " + strings.Join(out, "\n ") -} - -func testGenericRecursive(t *testing.T, beforeErr error, beforeWant []string, list []wrapper, maxDepth int) { - if len(beforeWant) == 0 { - panic("beforeWant must not be empty") - } - for _, w := range list { - if len(w.want) == 0 { - panic("want must not be empty") - } - - err := w.wrap(beforeErr) - - // Copy required cause append(beforeWant, ..) modified beforeWant subtly. - beforeCopy := make([]string, len(beforeWant)) - copy(beforeCopy, beforeWant) - - beforeWant := beforeCopy - last := len(beforeWant) - 1 - var want []string - - // Merge two stacks behind each other. - if strings.ContainsAny(beforeWant[last], "\n") && strings.ContainsAny(w.want[0], "\n") { - want = append(beforeWant[:last], append([]string{beforeWant[last] + "((?s).*)" + w.want[0]}, w.want[1:]...)...) - } else { - want = append(beforeWant, w.want...) - } - - testFormatCompleteCompare(t, maxDepth, err, "%+v", want, false) - if maxDepth > 0 { - testGenericRecursive(t, err, want, list, maxDepth-1) - } - } -} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go deleted file mode 100644 index b485761..0000000 --- a/vendor/github.com/pkg/errors/stack.go +++ /dev/null @@ -1,187 +0,0 @@ -package errors - -import ( - "fmt" - "io" - "path" - "runtime" - "strings" -) - -// Frame represents a program counter inside a stack frame. -type Frame uintptr - -// pc returns the program counter for this frame; -// multiple frames may have the same PC value. -func (f Frame) pc() uintptr { return uintptr(f) - 1 } - -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - file, _ := fn.FileLine(f.pc()) - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return 0 - } - _, line := fn.FileLine(f.pc()) - return line -} - -// Format formats the frame according to the fmt.Formatter interface. -// -// %s source file -// %d source line -// %n function name -// %v equivalent to %s:%d -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+s function name and path of source file relative to the compile time -// GOPATH separated by \n\t (\n\t) -// %+v equivalent to %+s:%d -func (f Frame) Format(s fmt.State, verb rune) { - switch verb { - case 's': - switch { - case s.Flag('+'): - pc := f.pc() - fn := runtime.FuncForPC(pc) - if fn == nil { - io.WriteString(s, "unknown") - } else { - file, _ := fn.FileLine(pc) - fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) - } - default: - io.WriteString(s, path.Base(f.file())) - } - case 'd': - fmt.Fprintf(s, "%d", f.line()) - case 'n': - name := runtime.FuncForPC(f.pc()).Name() - io.WriteString(s, funcname(name)) - case 'v': - f.Format(s, 's') - io.WriteString(s, ":") - f.Format(s, 'd') - } -} - -// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). -type StackTrace []Frame - -// Format formats the stack of Frames according to the fmt.Formatter interface. -// -// %s lists source files for each Frame in the stack -// %v lists the source file and line number for each Frame in the stack -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+v Prints filename, function, and line number for each Frame in the stack. -func (st StackTrace) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case s.Flag('+'): - for _, f := range st { - fmt.Fprintf(s, "\n%+v", f) - } - case s.Flag('#'): - fmt.Fprintf(s, "%#v", []Frame(st)) - default: - fmt.Fprintf(s, "%v", []Frame(st)) - } - case 's': - fmt.Fprintf(s, "%s", []Frame(st)) - } -} - -// stack represents a stack of program counters. -type stack []uintptr - -func (s *stack) Format(st fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case st.Flag('+'): - for _, pc := range *s { - f := Frame(pc) - fmt.Fprintf(st, "\n%+v", f) - } - } - } -} - -func (s *stack) StackTrace() StackTrace { - f := make([]Frame, len(*s)) - for i := 0; i < len(f); i++ { - f[i] = Frame((*s)[i]) - } - return f -} - -func callers() *stack { - const depth = 32 - var pcs [depth]uintptr - n := runtime.Callers(3, pcs[:]) - var st stack = pcs[0:n] - return &st -} - -// funcname removes the path prefix component of a function's name reported by func.Name(). -func funcname(name string) string { - i := strings.LastIndex(name, "/") - name = name[i+1:] - i = strings.Index(name, ".") - return name[i+1:] -} - -func trimGOPATH(name, file string) string { - // Here we want to get the source file path relative to the compile time - // GOPATH. As of Go 1.6.x there is no direct way to know the compiled - // GOPATH at runtime, but we can infer the number of path segments in the - // GOPATH. We note that fn.Name() returns the function name qualified by - // the import path, which does not include the GOPATH. Thus we can trim - // segments from the beginning of the file path until the number of path - // separators remaining is one more than the number of path separators in - // the function name. For example, given: - // - // GOPATH /home/user - // file /home/user/src/pkg/sub/file.go - // fn.Name() pkg/sub.Type.Method - // - // We want to produce: - // - // pkg/sub/file.go - // - // From this we can easily see that fn.Name() has one less path separator - // than our desired output. We count separators from the end of the file - // path until it finds two more than in the function name and then move - // one character forward to preserve the initial path segment without a - // leading separator. - const sep = "/" - goal := strings.Count(name, sep) + 2 - i := len(file) - for n := 0; n < goal; n++ { - i = strings.LastIndex(file[:i], sep) - if i == -1 { - // not enough separators found, set i so that the slice expression - // below leaves file unmodified - i = -len(sep) - break - } - } - // get back to 0 or trim the leading separator - file = file[i+len(sep):] - return file -} diff --git a/vendor/github.com/pkg/errors/stack_test.go b/vendor/github.com/pkg/errors/stack_test.go deleted file mode 100644 index 510c27a..0000000 --- a/vendor/github.com/pkg/errors/stack_test.go +++ /dev/null @@ -1,292 +0,0 @@ -package errors - -import ( - "fmt" - "runtime" - "testing" -) - -var initpc, _, _, _ = runtime.Caller(0) - -func TestFrameLine(t *testing.T) { - var tests = []struct { - Frame - want int - }{{ - Frame(initpc), - 9, - }, { - func() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) - }(), - 20, - }, { - func() Frame { - var pc, _, _, _ = runtime.Caller(1) - return Frame(pc) - }(), - 28, - }, { - Frame(0), // invalid PC - 0, - }} - - for _, tt := range tests { - got := tt.Frame.line() - want := tt.want - if want != got { - t.Errorf("Frame(%v): want: %v, got: %v", uintptr(tt.Frame), want, got) - } - } -} - -type X struct{} - -func (x X) val() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) -} - -func (x *X) ptr() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) -} - -func TestFrameFormat(t *testing.T) { - var tests = []struct { - Frame - format string - want string - }{{ - Frame(initpc), - "%s", - "stack_test.go", - }, { - Frame(initpc), - "%+s", - "github.com/pkg/errors.init\n" + - "\t.+/github.com/pkg/errors/stack_test.go", - }, { - Frame(0), - "%s", - "unknown", - }, { - Frame(0), - "%+s", - "unknown", - }, { - Frame(initpc), - "%d", - "9", - }, { - Frame(0), - "%d", - "0", - }, { - Frame(initpc), - "%n", - "init", - }, { - func() Frame { - var x X - return x.ptr() - }(), - "%n", - `\(\*X\).ptr`, - }, { - func() Frame { - var x X - return x.val() - }(), - "%n", - "X.val", - }, { - Frame(0), - "%n", - "", - }, { - Frame(initpc), - "%v", - "stack_test.go:9", - }, { - Frame(initpc), - "%+v", - "github.com/pkg/errors.init\n" + - "\t.+/github.com/pkg/errors/stack_test.go:9", - }, { - Frame(0), - "%v", - "unknown:0", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.Frame, tt.format, tt.want) - } -} - -func TestFuncname(t *testing.T) { - tests := []struct { - name, want string - }{ - {"", ""}, - {"runtime.main", "main"}, - {"github.com/pkg/errors.funcname", "funcname"}, - {"funcname", "funcname"}, - {"io.copyBuffer", "copyBuffer"}, - {"main.(*R).Write", "(*R).Write"}, - } - - for _, tt := range tests { - got := funcname(tt.name) - want := tt.want - if got != want { - t.Errorf("funcname(%q): want: %q, got %q", tt.name, want, got) - } - } -} - -func TestTrimGOPATH(t *testing.T) { - var tests = []struct { - Frame - want string - }{{ - Frame(initpc), - "github.com/pkg/errors/stack_test.go", - }} - - for i, tt := range tests { - pc := tt.Frame.pc() - fn := runtime.FuncForPC(pc) - file, _ := fn.FileLine(pc) - got := trimGOPATH(fn.Name(), file) - testFormatRegexp(t, i, got, "%s", tt.want) - } -} - -func TestStackTrace(t *testing.T) { - tests := []struct { - err error - want []string - }{{ - New("ooh"), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:172", - }, - }, { - Wrap(New("ooh"), "ahh"), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:177", // this is the stack of Wrap, not New - }, - }, { - Cause(Wrap(New("ooh"), "ahh")), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New - }, - }, { - func() error { return New("ooh") }(), []string{ - `github.com/pkg/errors.(func·009|TestStackTrace.func1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller - }, - }, { - Cause(func() error { - return func() error { - return Errorf("hello %s", fmt.Sprintf("world")) - }() - }()), []string{ - `github.com/pkg/errors.(func·010|TestStackTrace.func2.1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf - `github.com/pkg/errors.(func·011|TestStackTrace.func2)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller - }, - }} - for i, tt := range tests { - x, ok := tt.err.(interface { - StackTrace() StackTrace - }) - if !ok { - t.Errorf("expected %#v to implement StackTrace() StackTrace", tt.err) - continue - } - st := x.StackTrace() - for j, want := range tt.want { - testFormatRegexp(t, i, st[j], "%+v", want) - } - } -} - -func stackTrace() StackTrace { - const depth = 8 - var pcs [depth]uintptr - n := runtime.Callers(1, pcs[:]) - var st stack = pcs[0:n] - return st.StackTrace() -} - -func TestStackTraceFormat(t *testing.T) { - tests := []struct { - StackTrace - format string - want string - }{{ - nil, - "%s", - `\[\]`, - }, { - nil, - "%v", - `\[\]`, - }, { - nil, - "%+v", - "", - }, { - nil, - "%#v", - `\[\]errors.Frame\(nil\)`, - }, { - make(StackTrace, 0), - "%s", - `\[\]`, - }, { - make(StackTrace, 0), - "%v", - `\[\]`, - }, { - make(StackTrace, 0), - "%+v", - "", - }, { - make(StackTrace, 0), - "%#v", - `\[\]errors.Frame{}`, - }, { - stackTrace()[:2], - "%s", - `\[stack_test.go stack_test.go\]`, - }, { - stackTrace()[:2], - "%v", - `\[stack_test.go:225 stack_test.go:272\]`, - }, { - stackTrace()[:2], - "%+v", - "\n" + - "github.com/pkg/errors.stackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:225\n" + - "github.com/pkg/errors.TestStackTraceFormat\n" + - "\t.+/github.com/pkg/errors/stack_test.go:276", - }, { - stackTrace()[:2], - "%#v", - `\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.StackTrace, tt.format, tt.want) - } -} diff --git a/vendor/github.com/pmezard/go-difflib/.travis.yml b/vendor/github.com/pmezard/go-difflib/.travis.yml deleted file mode 100644 index 90c9c6f..0000000 --- a/vendor/github.com/pmezard/go-difflib/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: go -go: - - 1.5 - - tip - diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE deleted file mode 100644 index c67dad6..0000000 --- a/vendor/github.com/pmezard/go-difflib/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013, Patrick Mezard -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - The names of its contributors may not be used to endorse or promote -products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pmezard/go-difflib/README.md b/vendor/github.com/pmezard/go-difflib/README.md deleted file mode 100644 index e87f307..0000000 --- a/vendor/github.com/pmezard/go-difflib/README.md +++ /dev/null @@ -1,50 +0,0 @@ -go-difflib -========== - -[![Build Status](https://travis-ci.org/pmezard/go-difflib.png?branch=master)](https://travis-ci.org/pmezard/go-difflib) -[![GoDoc](https://godoc.org/github.com/pmezard/go-difflib/difflib?status.svg)](https://godoc.org/github.com/pmezard/go-difflib/difflib) - -Go-difflib is a partial port of python 3 difflib package. Its main goal -was to make unified and context diff available in pure Go, mostly for -testing purposes. - -The following class and functions (and related tests) have be ported: - -* `SequenceMatcher` -* `unified_diff()` -* `context_diff()` - -## Installation - -```bash -$ go get github.com/pmezard/go-difflib/difflib -``` - -### Quick Start - -Diffs are configured with Unified (or ContextDiff) structures, and can -be output to an io.Writer or returned as a string. - -```Go -diff := UnifiedDiff{ - A: difflib.SplitLines("foo\nbar\n"), - B: difflib.SplitLines("foo\nbaz\n"), - FromFile: "Original", - ToFile: "Current", - Context: 3, -} -text, _ := GetUnifiedDiffString(diff) -fmt.Printf(text) -``` - -would output: - -``` ---- Original -+++ Current -@@ -1,3 +1,3 @@ - foo --bar -+baz -``` - diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go deleted file mode 100644 index 003e99f..0000000 --- a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go +++ /dev/null @@ -1,772 +0,0 @@ -// Package difflib is a partial port of Python difflib module. -// -// It provides tools to compare sequences of strings and generate textual diffs. -// -// The following class and functions have been ported: -// -// - SequenceMatcher -// -// - unified_diff -// -// - context_diff -// -// Getting unified diffs was the main goal of the port. Keep in mind this code -// is mostly suitable to output text differences in a human friendly way, there -// are no guarantees generated diffs are consumable by patch(1). -package difflib - -import ( - "bufio" - "bytes" - "fmt" - "io" - "strings" -) - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -func calculateRatio(matches, length int) float64 { - if length > 0 { - return 2.0 * float64(matches) / float64(length) - } - return 1.0 -} - -type Match struct { - A int - B int - Size int -} - -type OpCode struct { - Tag byte - I1 int - I2 int - J1 int - J2 int -} - -// SequenceMatcher compares sequence of strings. The basic -// algorithm predates, and is a little fancier than, an algorithm -// published in the late 1980's by Ratcliff and Obershelp under the -// hyperbolic name "gestalt pattern matching". The basic idea is to find -// the longest contiguous matching subsequence that contains no "junk" -// elements (R-O doesn't address junk). The same idea is then applied -// recursively to the pieces of the sequences to the left and to the right -// of the matching subsequence. This does not yield minimal edit -// sequences, but does tend to yield matches that "look right" to people. -// -// SequenceMatcher tries to compute a "human-friendly diff" between two -// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the -// longest *contiguous* & junk-free matching subsequence. That's what -// catches peoples' eyes. The Windows(tm) windiff has another interesting -// notion, pairing up elements that appear uniquely in each sequence. -// That, and the method here, appear to yield more intuitive difference -// reports than does diff. This method appears to be the least vulnerable -// to synching up on blocks of "junk lines", though (like blank lines in -// ordinary text files, or maybe "

" lines in HTML files). That may be -// because this is the only method of the 3 that has a *concept* of -// "junk" . -// -// Timing: Basic R-O is cubic time worst case and quadratic time expected -// case. SequenceMatcher is quadratic time for the worst case and has -// expected-case behavior dependent in a complicated way on how many -// elements the sequences have in common; best case time is linear. -type SequenceMatcher struct { - a []string - b []string - b2j map[string][]int - IsJunk func(string) bool - autoJunk bool - bJunk map[string]struct{} - matchingBlocks []Match - fullBCount map[string]int - bPopular map[string]struct{} - opCodes []OpCode -} - -func NewMatcher(a, b []string) *SequenceMatcher { - m := SequenceMatcher{autoJunk: true} - m.SetSeqs(a, b) - return &m -} - -func NewMatcherWithJunk(a, b []string, autoJunk bool, - isJunk func(string) bool) *SequenceMatcher { - - m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk} - m.SetSeqs(a, b) - return &m -} - -// Set two sequences to be compared. -func (m *SequenceMatcher) SetSeqs(a, b []string) { - m.SetSeq1(a) - m.SetSeq2(b) -} - -// Set the first sequence to be compared. The second sequence to be compared is -// not changed. -// -// SequenceMatcher computes and caches detailed information about the second -// sequence, so if you want to compare one sequence S against many sequences, -// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other -// sequences. -// -// See also SetSeqs() and SetSeq2(). -func (m *SequenceMatcher) SetSeq1(a []string) { - if &a == &m.a { - return - } - m.a = a - m.matchingBlocks = nil - m.opCodes = nil -} - -// Set the second sequence to be compared. The first sequence to be compared is -// not changed. -func (m *SequenceMatcher) SetSeq2(b []string) { - if &b == &m.b { - return - } - m.b = b - m.matchingBlocks = nil - m.opCodes = nil - m.fullBCount = nil - m.chainB() -} - -func (m *SequenceMatcher) chainB() { - // Populate line -> index mapping - b2j := map[string][]int{} - for i, s := range m.b { - indices := b2j[s] - indices = append(indices, i) - b2j[s] = indices - } - - // Purge junk elements - m.bJunk = map[string]struct{}{} - if m.IsJunk != nil { - junk := m.bJunk - for s, _ := range b2j { - if m.IsJunk(s) { - junk[s] = struct{}{} - } - } - for s, _ := range junk { - delete(b2j, s) - } - } - - // Purge remaining popular elements - popular := map[string]struct{}{} - n := len(m.b) - if m.autoJunk && n >= 200 { - ntest := n/100 + 1 - for s, indices := range b2j { - if len(indices) > ntest { - popular[s] = struct{}{} - } - } - for s, _ := range popular { - delete(b2j, s) - } - } - m.bPopular = popular - m.b2j = b2j -} - -func (m *SequenceMatcher) isBJunk(s string) bool { - _, ok := m.bJunk[s] - return ok -} - -// Find longest matching block in a[alo:ahi] and b[blo:bhi]. -// -// If IsJunk is not defined: -// -// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where -// alo <= i <= i+k <= ahi -// blo <= j <= j+k <= bhi -// and for all (i',j',k') meeting those conditions, -// k >= k' -// i <= i' -// and if i == i', j <= j' -// -// In other words, of all maximal matching blocks, return one that -// starts earliest in a, and of all those maximal matching blocks that -// start earliest in a, return the one that starts earliest in b. -// -// If IsJunk is defined, first the longest matching block is -// determined as above, but with the additional restriction that no -// junk element appears in the block. Then that block is extended as -// far as possible by matching (only) junk elements on both sides. So -// the resulting block never matches on junk except as identical junk -// happens to be adjacent to an "interesting" match. -// -// If no blocks match, return (alo, blo, 0). -func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { - // CAUTION: stripping common prefix or suffix would be incorrect. - // E.g., - // ab - // acab - // Longest matching block is "ab", but if common prefix is - // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so - // strip, so ends up claiming that ab is changed to acab by - // inserting "ca" in the middle. That's minimal but unintuitive: - // "it's obvious" that someone inserted "ac" at the front. - // Windiff ends up at the same place as diff, but by pairing up - // the unique 'b's and then matching the first two 'a's. - besti, bestj, bestsize := alo, blo, 0 - - // find longest junk-free match - // during an iteration of the loop, j2len[j] = length of longest - // junk-free match ending with a[i-1] and b[j] - j2len := map[int]int{} - for i := alo; i != ahi; i++ { - // look at all instances of a[i] in b; note that because - // b2j has no junk keys, the loop is skipped if a[i] is junk - newj2len := map[int]int{} - for _, j := range m.b2j[m.a[i]] { - // a[i] matches b[j] - if j < blo { - continue - } - if j >= bhi { - break - } - k := j2len[j-1] + 1 - newj2len[j] = k - if k > bestsize { - besti, bestj, bestsize = i-k+1, j-k+1, k - } - } - j2len = newj2len - } - - // Extend the best by non-junk elements on each end. In particular, - // "popular" non-junk elements aren't in b2j, which greatly speeds - // the inner loop above, but also means "the best" match so far - // doesn't contain any junk *or* popular non-junk elements. - for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) && - m.a[besti-1] == m.b[bestj-1] { - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - } - for besti+bestsize < ahi && bestj+bestsize < bhi && - !m.isBJunk(m.b[bestj+bestsize]) && - m.a[besti+bestsize] == m.b[bestj+bestsize] { - bestsize += 1 - } - - // Now that we have a wholly interesting match (albeit possibly - // empty!), we may as well suck up the matching junk on each - // side of it too. Can't think of a good reason not to, and it - // saves post-processing the (possibly considerable) expense of - // figuring out what to do with it. In the case of an empty - // interesting match, this is clearly the right thing to do, - // because no other kind of match is possible in the regions. - for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) && - m.a[besti-1] == m.b[bestj-1] { - besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 - } - for besti+bestsize < ahi && bestj+bestsize < bhi && - m.isBJunk(m.b[bestj+bestsize]) && - m.a[besti+bestsize] == m.b[bestj+bestsize] { - bestsize += 1 - } - - return Match{A: besti, B: bestj, Size: bestsize} -} - -// Return list of triples describing matching subsequences. -// -// Each triple is of the form (i, j, n), and means that -// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in -// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are -// adjacent triples in the list, and the second is not the last triple in the -// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe -// adjacent equal blocks. -// -// The last triple is a dummy, (len(a), len(b), 0), and is the only -// triple with n==0. -func (m *SequenceMatcher) GetMatchingBlocks() []Match { - if m.matchingBlocks != nil { - return m.matchingBlocks - } - - var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match - matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match { - match := m.findLongestMatch(alo, ahi, blo, bhi) - i, j, k := match.A, match.B, match.Size - if match.Size > 0 { - if alo < i && blo < j { - matched = matchBlocks(alo, i, blo, j, matched) - } - matched = append(matched, match) - if i+k < ahi && j+k < bhi { - matched = matchBlocks(i+k, ahi, j+k, bhi, matched) - } - } - return matched - } - matched := matchBlocks(0, len(m.a), 0, len(m.b), nil) - - // It's possible that we have adjacent equal blocks in the - // matching_blocks list now. - nonAdjacent := []Match{} - i1, j1, k1 := 0, 0, 0 - for _, b := range matched { - // Is this block adjacent to i1, j1, k1? - i2, j2, k2 := b.A, b.B, b.Size - if i1+k1 == i2 && j1+k1 == j2 { - // Yes, so collapse them -- this just increases the length of - // the first block by the length of the second, and the first - // block so lengthened remains the block to compare against. - k1 += k2 - } else { - // Not adjacent. Remember the first block (k1==0 means it's - // the dummy we started with), and make the second block the - // new block to compare against. - if k1 > 0 { - nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) - } - i1, j1, k1 = i2, j2, k2 - } - } - if k1 > 0 { - nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) - } - - nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0}) - m.matchingBlocks = nonAdjacent - return m.matchingBlocks -} - -// Return list of 5-tuples describing how to turn a into b. -// -// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple -// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the -// tuple preceding it, and likewise for j1 == the previous j2. -// -// The tags are characters, with these meanings: -// -// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2] -// -// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case. -// -// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case. -// -// 'e' (equal): a[i1:i2] == b[j1:j2] -func (m *SequenceMatcher) GetOpCodes() []OpCode { - if m.opCodes != nil { - return m.opCodes - } - i, j := 0, 0 - matching := m.GetMatchingBlocks() - opCodes := make([]OpCode, 0, len(matching)) - for _, m := range matching { - // invariant: we've pumped out correct diffs to change - // a[:i] into b[:j], and the next matching block is - // a[ai:ai+size] == b[bj:bj+size]. So we need to pump - // out a diff to change a[i:ai] into b[j:bj], pump out - // the matching block, and move (i,j) beyond the match - ai, bj, size := m.A, m.B, m.Size - tag := byte(0) - if i < ai && j < bj { - tag = 'r' - } else if i < ai { - tag = 'd' - } else if j < bj { - tag = 'i' - } - if tag > 0 { - opCodes = append(opCodes, OpCode{tag, i, ai, j, bj}) - } - i, j = ai+size, bj+size - // the list of matching blocks is terminated by a - // sentinel with size 0 - if size > 0 { - opCodes = append(opCodes, OpCode{'e', ai, i, bj, j}) - } - } - m.opCodes = opCodes - return m.opCodes -} - -// Isolate change clusters by eliminating ranges with no changes. -// -// Return a generator of groups with up to n lines of context. -// Each group is in the same format as returned by GetOpCodes(). -func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { - if n < 0 { - n = 3 - } - codes := m.GetOpCodes() - if len(codes) == 0 { - codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} - } - // Fixup leading and trailing groups if they show no changes. - if codes[0].Tag == 'e' { - c := codes[0] - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2} - } - if codes[len(codes)-1].Tag == 'e' { - c := codes[len(codes)-1] - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)} - } - nn := n + n - groups := [][]OpCode{} - group := []OpCode{} - for _, c := range codes { - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - // End the current group and start a new one whenever - // there is a large range with no changes. - if c.Tag == 'e' && i2-i1 > nn { - group = append(group, OpCode{c.Tag, i1, min(i2, i1+n), - j1, min(j2, j1+n)}) - groups = append(groups, group) - group = []OpCode{} - i1, j1 = max(i1, i2-n), max(j1, j2-n) - } - group = append(group, OpCode{c.Tag, i1, i2, j1, j2}) - } - if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') { - groups = append(groups, group) - } - return groups -} - -// Return a measure of the sequences' similarity (float in [0,1]). -// -// Where T is the total number of elements in both sequences, and -// M is the number of matches, this is 2.0*M / T. -// Note that this is 1 if the sequences are identical, and 0 if -// they have nothing in common. -// -// .Ratio() is expensive to compute if you haven't already computed -// .GetMatchingBlocks() or .GetOpCodes(), in which case you may -// want to try .QuickRatio() or .RealQuickRation() first to get an -// upper bound. -func (m *SequenceMatcher) Ratio() float64 { - matches := 0 - for _, m := range m.GetMatchingBlocks() { - matches += m.Size - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() relatively quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute. -func (m *SequenceMatcher) QuickRatio() float64 { - // viewing a and b as multisets, set matches to the cardinality - // of their intersection; this counts the number of matches - // without regard to order, so is clearly an upper bound - if m.fullBCount == nil { - m.fullBCount = map[string]int{} - for _, s := range m.b { - m.fullBCount[s] = m.fullBCount[s] + 1 - } - } - - // avail[x] is the number of times x appears in 'b' less the - // number of times we've seen it in 'a' so far ... kinda - avail := map[string]int{} - matches := 0 - for _, s := range m.a { - n, ok := avail[s] - if !ok { - n = m.fullBCount[s] - } - avail[s] = n - 1 - if n > 0 { - matches += 1 - } - } - return calculateRatio(matches, len(m.a)+len(m.b)) -} - -// Return an upper bound on ratio() very quickly. -// -// This isn't defined beyond that it is an upper bound on .Ratio(), and -// is faster to compute than either .Ratio() or .QuickRatio(). -func (m *SequenceMatcher) RealQuickRatio() float64 { - la, lb := len(m.a), len(m.b) - return calculateRatio(min(la, lb), la+lb) -} - -// Convert range to the "ed" format -func formatRangeUnified(start, stop int) string { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - beginning := start + 1 // lines start numbering with one - length := stop - start - if length == 1 { - return fmt.Sprintf("%d", beginning) - } - if length == 0 { - beginning -= 1 // empty ranges begin at line just before the range - } - return fmt.Sprintf("%d,%d", beginning, length) -} - -// Unified diff parameters -type UnifiedDiff struct { - A []string // First sequence lines - FromFile string // First file name - FromDate string // First file time - B []string // Second sequence lines - ToFile string // Second file name - ToDate string // Second file time - Eol string // Headers end of line, defaults to LF - Context int // Number of context lines -} - -// Compare two sequences of lines; generate the delta as a unified diff. -// -// Unified diffs are a compact way of showing line changes and a few -// lines of context. The number of context lines is set by 'n' which -// defaults to three. -// -// By default, the diff control lines (those with ---, +++, or @@) are -// created with a trailing newline. This is helpful so that inputs -// created from file.readlines() result in diffs that are suitable for -// file.writelines() since both the inputs and outputs have trailing -// newlines. -// -// For inputs that do not have trailing newlines, set the lineterm -// argument to "" so that the output will be uniformly newline free. -// -// The unidiff format normally has a header for filenames and modification -// times. Any or all of these may be specified using strings for -// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. -// The modification times are normally expressed in the ISO 8601 format. -func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error { - buf := bufio.NewWriter(writer) - defer buf.Flush() - wf := func(format string, args ...interface{}) error { - _, err := buf.WriteString(fmt.Sprintf(format, args...)) - return err - } - ws := func(s string) error { - _, err := buf.WriteString(s) - return err - } - - if len(diff.Eol) == 0 { - diff.Eol = "\n" - } - - started := false - m := NewMatcher(diff.A, diff.B) - for _, g := range m.GetGroupedOpCodes(diff.Context) { - if !started { - started = true - fromDate := "" - if len(diff.FromDate) > 0 { - fromDate = "\t" + diff.FromDate - } - toDate := "" - if len(diff.ToDate) > 0 { - toDate = "\t" + diff.ToDate - } - if diff.FromFile != "" || diff.ToFile != "" { - err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol) - if err != nil { - return err - } - err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol) - if err != nil { - return err - } - } - } - first, last := g[0], g[len(g)-1] - range1 := formatRangeUnified(first.I1, last.I2) - range2 := formatRangeUnified(first.J1, last.J2) - if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil { - return err - } - for _, c := range g { - i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 - if c.Tag == 'e' { - for _, line := range diff.A[i1:i2] { - if err := ws(" " + line); err != nil { - return err - } - } - continue - } - if c.Tag == 'r' || c.Tag == 'd' { - for _, line := range diff.A[i1:i2] { - if err := ws("-" + line); err != nil { - return err - } - } - } - if c.Tag == 'r' || c.Tag == 'i' { - for _, line := range diff.B[j1:j2] { - if err := ws("+" + line); err != nil { - return err - } - } - } - } - } - return nil -} - -// Like WriteUnifiedDiff but returns the diff a string. -func GetUnifiedDiffString(diff UnifiedDiff) (string, error) { - w := &bytes.Buffer{} - err := WriteUnifiedDiff(w, diff) - return string(w.Bytes()), err -} - -// Convert range to the "ed" format. -func formatRangeContext(start, stop int) string { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - beginning := start + 1 // lines start numbering with one - length := stop - start - if length == 0 { - beginning -= 1 // empty ranges begin at line just before the range - } - if length <= 1 { - return fmt.Sprintf("%d", beginning) - } - return fmt.Sprintf("%d,%d", beginning, beginning+length-1) -} - -type ContextDiff UnifiedDiff - -// Compare two sequences of lines; generate the delta as a context diff. -// -// Context diffs are a compact way of showing line changes and a few -// lines of context. The number of context lines is set by diff.Context -// which defaults to three. -// -// By default, the diff control lines (those with *** or ---) are -// created with a trailing newline. -// -// For inputs that do not have trailing newlines, set the diff.Eol -// argument to "" so that the output will be uniformly newline free. -// -// The context diff format normally has a header for filenames and -// modification times. Any or all of these may be specified using -// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate. -// The modification times are normally expressed in the ISO 8601 format. -// If not specified, the strings default to blanks. -func WriteContextDiff(writer io.Writer, diff ContextDiff) error { - buf := bufio.NewWriter(writer) - defer buf.Flush() - var diffErr error - wf := func(format string, args ...interface{}) { - _, err := buf.WriteString(fmt.Sprintf(format, args...)) - if diffErr == nil && err != nil { - diffErr = err - } - } - ws := func(s string) { - _, err := buf.WriteString(s) - if diffErr == nil && err != nil { - diffErr = err - } - } - - if len(diff.Eol) == 0 { - diff.Eol = "\n" - } - - prefix := map[byte]string{ - 'i': "+ ", - 'd': "- ", - 'r': "! ", - 'e': " ", - } - - started := false - m := NewMatcher(diff.A, diff.B) - for _, g := range m.GetGroupedOpCodes(diff.Context) { - if !started { - started = true - fromDate := "" - if len(diff.FromDate) > 0 { - fromDate = "\t" + diff.FromDate - } - toDate := "" - if len(diff.ToDate) > 0 { - toDate = "\t" + diff.ToDate - } - if diff.FromFile != "" || diff.ToFile != "" { - wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol) - wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol) - } - } - - first, last := g[0], g[len(g)-1] - ws("***************" + diff.Eol) - - range1 := formatRangeContext(first.I1, last.I2) - wf("*** %s ****%s", range1, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'd' { - for _, cc := range g { - if cc.Tag == 'i' { - continue - } - for _, line := range diff.A[cc.I1:cc.I2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - - range2 := formatRangeContext(first.J1, last.J2) - wf("--- %s ----%s", range2, diff.Eol) - for _, c := range g { - if c.Tag == 'r' || c.Tag == 'i' { - for _, cc := range g { - if cc.Tag == 'd' { - continue - } - for _, line := range diff.B[cc.J1:cc.J2] { - ws(prefix[cc.Tag] + line) - } - } - break - } - } - } - return diffErr -} - -// Like WriteContextDiff but returns the diff a string. -func GetContextDiffString(diff ContextDiff) (string, error) { - w := &bytes.Buffer{} - err := WriteContextDiff(w, diff) - return string(w.Bytes()), err -} - -// Split a string on "\n" while preserving them. The output can be used -// as input for UnifiedDiff and ContextDiff structures. -func SplitLines(s string) []string { - lines := strings.SplitAfter(s, "\n") - lines[len(lines)-1] += "\n" - return lines -} diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go deleted file mode 100644 index d725119..0000000 --- a/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go +++ /dev/null @@ -1,426 +0,0 @@ -package difflib - -import ( - "bytes" - "fmt" - "math" - "reflect" - "strings" - "testing" -) - -func assertAlmostEqual(t *testing.T, a, b float64, places int) { - if math.Abs(a-b) > math.Pow10(-places) { - t.Errorf("%.7f != %.7f", a, b) - } -} - -func assertEqual(t *testing.T, a, b interface{}) { - if !reflect.DeepEqual(a, b) { - t.Errorf("%v != %v", a, b) - } -} - -func splitChars(s string) []string { - chars := make([]string, 0, len(s)) - // Assume ASCII inputs - for i := 0; i != len(s); i++ { - chars = append(chars, string(s[i])) - } - return chars -} - -func TestSequenceMatcherRatio(t *testing.T) { - s := NewMatcher(splitChars("abcd"), splitChars("bcde")) - assertEqual(t, s.Ratio(), 0.75) - assertEqual(t, s.QuickRatio(), 0.75) - assertEqual(t, s.RealQuickRatio(), 1.0) -} - -func TestGetOptCodes(t *testing.T) { - a := "qabxcd" - b := "abycdf" - s := NewMatcher(splitChars(a), splitChars(b)) - w := &bytes.Buffer{} - for _, op := range s.GetOpCodes() { - fmt.Fprintf(w, "%s a[%d:%d], (%s) b[%d:%d] (%s)\n", string(op.Tag), - op.I1, op.I2, a[op.I1:op.I2], op.J1, op.J2, b[op.J1:op.J2]) - } - result := string(w.Bytes()) - expected := `d a[0:1], (q) b[0:0] () -e a[1:3], (ab) b[0:2] (ab) -r a[3:4], (x) b[2:3] (y) -e a[4:6], (cd) b[3:5] (cd) -i a[6:6], () b[5:6] (f) -` - if expected != result { - t.Errorf("unexpected op codes: \n%s", result) - } -} - -func TestGroupedOpCodes(t *testing.T) { - a := []string{} - for i := 0; i != 39; i++ { - a = append(a, fmt.Sprintf("%02d", i)) - } - b := []string{} - b = append(b, a[:8]...) - b = append(b, " i") - b = append(b, a[8:19]...) - b = append(b, " x") - b = append(b, a[20:22]...) - b = append(b, a[27:34]...) - b = append(b, " y") - b = append(b, a[35:]...) - s := NewMatcher(a, b) - w := &bytes.Buffer{} - for _, g := range s.GetGroupedOpCodes(-1) { - fmt.Fprintf(w, "group\n") - for _, op := range g { - fmt.Fprintf(w, " %s, %d, %d, %d, %d\n", string(op.Tag), - op.I1, op.I2, op.J1, op.J2) - } - } - result := string(w.Bytes()) - expected := `group - e, 5, 8, 5, 8 - i, 8, 8, 8, 9 - e, 8, 11, 9, 12 -group - e, 16, 19, 17, 20 - r, 19, 20, 20, 21 - e, 20, 22, 21, 23 - d, 22, 27, 23, 23 - e, 27, 30, 23, 26 -group - e, 31, 34, 27, 30 - r, 34, 35, 30, 31 - e, 35, 38, 31, 34 -` - if expected != result { - t.Errorf("unexpected op codes: \n%s", result) - } -} - -func ExampleGetUnifiedDiffCode() { - a := `one -two -three -four -fmt.Printf("%s,%T",a,b)` - b := `zero -one -three -four` - diff := UnifiedDiff{ - A: SplitLines(a), - B: SplitLines(b), - FromFile: "Original", - FromDate: "2005-01-26 23:30:50", - ToFile: "Current", - ToDate: "2010-04-02 10:20:52", - Context: 3, - } - result, _ := GetUnifiedDiffString(diff) - fmt.Println(strings.Replace(result, "\t", " ", -1)) - // Output: - // --- Original 2005-01-26 23:30:50 - // +++ Current 2010-04-02 10:20:52 - // @@ -1,5 +1,4 @@ - // +zero - // one - // -two - // three - // four - // -fmt.Printf("%s,%T",a,b) -} - -func ExampleGetContextDiffCode() { - a := `one -two -three -four -fmt.Printf("%s,%T",a,b)` - b := `zero -one -tree -four` - diff := ContextDiff{ - A: SplitLines(a), - B: SplitLines(b), - FromFile: "Original", - ToFile: "Current", - Context: 3, - Eol: "\n", - } - result, _ := GetContextDiffString(diff) - fmt.Print(strings.Replace(result, "\t", " ", -1)) - // Output: - // *** Original - // --- Current - // *************** - // *** 1,5 **** - // one - // ! two - // ! three - // four - // - fmt.Printf("%s,%T",a,b) - // --- 1,4 ---- - // + zero - // one - // ! tree - // four -} - -func ExampleGetContextDiffString() { - a := `one -two -three -four` - b := `zero -one -tree -four` - diff := ContextDiff{ - A: SplitLines(a), - B: SplitLines(b), - FromFile: "Original", - ToFile: "Current", - Context: 3, - Eol: "\n", - } - result, _ := GetContextDiffString(diff) - fmt.Printf(strings.Replace(result, "\t", " ", -1)) - // Output: - // *** Original - // --- Current - // *************** - // *** 1,4 **** - // one - // ! two - // ! three - // four - // --- 1,4 ---- - // + zero - // one - // ! tree - // four -} - -func rep(s string, count int) string { - return strings.Repeat(s, count) -} - -func TestWithAsciiOneInsert(t *testing.T) { - sm := NewMatcher(splitChars(rep("b", 100)), - splitChars("a"+rep("b", 100))) - assertAlmostEqual(t, sm.Ratio(), 0.995, 3) - assertEqual(t, sm.GetOpCodes(), - []OpCode{{'i', 0, 0, 0, 1}, {'e', 0, 100, 1, 101}}) - assertEqual(t, len(sm.bPopular), 0) - - sm = NewMatcher(splitChars(rep("b", 100)), - splitChars(rep("b", 50)+"a"+rep("b", 50))) - assertAlmostEqual(t, sm.Ratio(), 0.995, 3) - assertEqual(t, sm.GetOpCodes(), - []OpCode{{'e', 0, 50, 0, 50}, {'i', 50, 50, 50, 51}, {'e', 50, 100, 51, 101}}) - assertEqual(t, len(sm.bPopular), 0) -} - -func TestWithAsciiOnDelete(t *testing.T) { - sm := NewMatcher(splitChars(rep("a", 40)+"c"+rep("b", 40)), - splitChars(rep("a", 40)+rep("b", 40))) - assertAlmostEqual(t, sm.Ratio(), 0.994, 3) - assertEqual(t, sm.GetOpCodes(), - []OpCode{{'e', 0, 40, 0, 40}, {'d', 40, 41, 40, 40}, {'e', 41, 81, 40, 80}}) -} - -func TestWithAsciiBJunk(t *testing.T) { - isJunk := func(s string) bool { - return s == " " - } - sm := NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), - splitChars(rep("a", 44)+rep("b", 40)), true, isJunk) - assertEqual(t, sm.bJunk, map[string]struct{}{}) - - sm = NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), - splitChars(rep("a", 44)+rep("b", 40)+rep(" ", 20)), false, isJunk) - assertEqual(t, sm.bJunk, map[string]struct{}{" ": struct{}{}}) - - isJunk = func(s string) bool { - return s == " " || s == "b" - } - sm = NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), - splitChars(rep("a", 44)+rep("b", 40)+rep(" ", 20)), false, isJunk) - assertEqual(t, sm.bJunk, map[string]struct{}{" ": struct{}{}, "b": struct{}{}}) -} - -func TestSFBugsRatioForNullSeqn(t *testing.T) { - sm := NewMatcher(nil, nil) - assertEqual(t, sm.Ratio(), 1.0) - assertEqual(t, sm.QuickRatio(), 1.0) - assertEqual(t, sm.RealQuickRatio(), 1.0) -} - -func TestSFBugsComparingEmptyLists(t *testing.T) { - groups := NewMatcher(nil, nil).GetGroupedOpCodes(-1) - assertEqual(t, len(groups), 0) - diff := UnifiedDiff{ - FromFile: "Original", - ToFile: "Current", - Context: 3, - } - result, err := GetUnifiedDiffString(diff) - assertEqual(t, err, nil) - assertEqual(t, result, "") -} - -func TestOutputFormatRangeFormatUnified(t *testing.T) { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - // - // Each field shall be of the form: - // %1d", if the range contains exactly one line, - // and: - // "%1d,%1d", , otherwise. - // If a range is empty, its beginning line number shall be the number of - // the line just before the range, or 0 if the empty range starts the file. - fm := formatRangeUnified - assertEqual(t, fm(3, 3), "3,0") - assertEqual(t, fm(3, 4), "4") - assertEqual(t, fm(3, 5), "4,2") - assertEqual(t, fm(3, 6), "4,3") - assertEqual(t, fm(0, 0), "0,0") -} - -func TestOutputFormatRangeFormatContext(t *testing.T) { - // Per the diff spec at http://www.unix.org/single_unix_specification/ - // - // The range of lines in file1 shall be written in the following format - // if the range contains two or more lines: - // "*** %d,%d ****\n", , - // and the following format otherwise: - // "*** %d ****\n", - // The ending line number of an empty range shall be the number of the preceding line, - // or 0 if the range is at the start of the file. - // - // Next, the range of lines in file2 shall be written in the following format - // if the range contains two or more lines: - // "--- %d,%d ----\n", , - // and the following format otherwise: - // "--- %d ----\n", - fm := formatRangeContext - assertEqual(t, fm(3, 3), "3") - assertEqual(t, fm(3, 4), "4") - assertEqual(t, fm(3, 5), "4,5") - assertEqual(t, fm(3, 6), "4,6") - assertEqual(t, fm(0, 0), "0") -} - -func TestOutputFormatTabDelimiter(t *testing.T) { - diff := UnifiedDiff{ - A: splitChars("one"), - B: splitChars("two"), - FromFile: "Original", - FromDate: "2005-01-26 23:30:50", - ToFile: "Current", - ToDate: "2010-04-12 10:20:52", - Eol: "\n", - } - ud, err := GetUnifiedDiffString(diff) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(ud)[:2], []string{ - "--- Original\t2005-01-26 23:30:50\n", - "+++ Current\t2010-04-12 10:20:52\n", - }) - cd, err := GetContextDiffString(ContextDiff(diff)) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(cd)[:2], []string{ - "*** Original\t2005-01-26 23:30:50\n", - "--- Current\t2010-04-12 10:20:52\n", - }) -} - -func TestOutputFormatNoTrailingTabOnEmptyFiledate(t *testing.T) { - diff := UnifiedDiff{ - A: splitChars("one"), - B: splitChars("two"), - FromFile: "Original", - ToFile: "Current", - Eol: "\n", - } - ud, err := GetUnifiedDiffString(diff) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(ud)[:2], []string{"--- Original\n", "+++ Current\n"}) - - cd, err := GetContextDiffString(ContextDiff(diff)) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(cd)[:2], []string{"*** Original\n", "--- Current\n"}) -} - -func TestOmitFilenames(t *testing.T) { - diff := UnifiedDiff{ - A: SplitLines("o\nn\ne\n"), - B: SplitLines("t\nw\no\n"), - Eol: "\n", - } - ud, err := GetUnifiedDiffString(diff) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(ud), []string{ - "@@ -0,0 +1,2 @@\n", - "+t\n", - "+w\n", - "@@ -2,2 +3,0 @@\n", - "-n\n", - "-e\n", - "\n", - }) - - cd, err := GetContextDiffString(ContextDiff(diff)) - assertEqual(t, err, nil) - assertEqual(t, SplitLines(cd), []string{ - "***************\n", - "*** 0 ****\n", - "--- 1,2 ----\n", - "+ t\n", - "+ w\n", - "***************\n", - "*** 2,3 ****\n", - "- n\n", - "- e\n", - "--- 3 ----\n", - "\n", - }) -} - -func TestSplitLines(t *testing.T) { - allTests := []struct { - input string - want []string - }{ - {"foo", []string{"foo\n"}}, - {"foo\nbar", []string{"foo\n", "bar\n"}}, - {"foo\nbar\n", []string{"foo\n", "bar\n", "\n"}}, - } - for _, test := range allTests { - assertEqual(t, SplitLines(test.input), test.want) - } -} - -func benchmarkSplitLines(b *testing.B, count int) { - str := strings.Repeat("foo\n", count) - - b.ResetTimer() - - n := 0 - for i := 0; i < b.N; i++ { - n += len(SplitLines(str)) - } -} - -func BenchmarkSplitLines100(b *testing.B) { - benchmarkSplitLines(b, 100) -} - -func BenchmarkSplitLines10000(b *testing.B) { - benchmarkSplitLines(b, 10000) -} diff --git a/vendor/github.com/samuel/go-zookeeper/.gitignore b/vendor/github.com/samuel/go-zookeeper/.gitignore deleted file mode 100644 index e43b0f9..0000000 --- a/vendor/github.com/samuel/go-zookeeper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/vendor/github.com/samuel/go-zookeeper/.travis.yml b/vendor/github.com/samuel/go-zookeeper/.travis.yml deleted file mode 100644 index c6f1547..0000000 --- a/vendor/github.com/samuel/go-zookeeper/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: go -go: - - 1.9 - -jdk: - - oraclejdk9 - -sudo: false - -branches: - only: - - master - -before_install: - - wget http://apache.cs.utah.edu/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz - - tar -zxvf zookeeper*tar.gz - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover - -script: - - jdk_switcher use oraclejdk9 - - go build ./... - - go fmt ./... - - go vet ./... - - go test -i -race ./... - - go test -race -covermode atomic -coverprofile=profile.cov ./zk - - goveralls -coverprofile=profile.cov -service=travis-ci - -env: - global: - secure: Coha3DDcXmsekrHCZlKvRAc+pMBaQU1QS/3++3YCCUXVDBWgVsC1ZIc9df4RLdZ/ncGd86eoRq/S+zyn1XbnqK5+ePqwJoUnJ59BE8ZyHLWI9ajVn3fND1MTduu/ksGsS79+IYbdVI5wgjSgjD3Ktp6Y5uPl+BPosjYBGdNcHS4= diff --git a/vendor/github.com/samuel/go-zookeeper/LICENSE b/vendor/github.com/samuel/go-zookeeper/LICENSE deleted file mode 100644 index bc00498..0000000 --- a/vendor/github.com/samuel/go-zookeeper/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2013, Samuel Stauffer -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* Neither the name of the author nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/samuel/go-zookeeper/README.md b/vendor/github.com/samuel/go-zookeeper/README.md deleted file mode 100644 index afc1d08..0000000 --- a/vendor/github.com/samuel/go-zookeeper/README.md +++ /dev/null @@ -1,11 +0,0 @@ -Native Go Zookeeper Client Library -=================================== - -[![GoDoc](https://godoc.org/github.com/samuel/go-zookeeper?status.svg)](https://godoc.org/github.com/samuel/go-zookeeper) -[![Build Status](https://travis-ci.org/samuel/go-zookeeper.png)](https://travis-ci.org/samuel/go-zookeeper) -[![Coverage Status](https://coveralls.io/repos/github/samuel/go-zookeeper/badge.svg?branch=master)](https://coveralls.io/github/samuel/go-zookeeper?branch=master) - -License -------- - -3-clause BSD. See LICENSE file. diff --git a/vendor/github.com/samuel/go-zookeeper/examples/basic.go b/vendor/github.com/samuel/go-zookeeper/examples/basic.go deleted file mode 100644 index 28dfa63..0000000 --- a/vendor/github.com/samuel/go-zookeeper/examples/basic.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/samuel/go-zookeeper/zk" -) - -func main() { - c, _, err := zk.Connect([]string{"127.0.0.1"}, time.Second) //*10) - if err != nil { - panic(err) - } - children, stat, ch, err := c.ChildrenW("/") - if err != nil { - panic(err) - } - fmt.Printf("%+v %+v\n", children, stat) - e := <-ch - fmt.Printf("%+v\n", e) -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go b/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go deleted file mode 100644 index dcceaa4..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go +++ /dev/null @@ -1,314 +0,0 @@ -package zk - -import ( - "sync" - "testing" - "time" -) - -type logWriter struct { - t *testing.T - p string -} - -func (lw logWriter) Write(b []byte) (int, error) { - lw.t.Logf("%s%s", lw.p, string(b)) - return len(b), nil -} - -func TestBasicCluster(t *testing.T) { - ts, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk1, err := ts.Connect(0) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk1.Close() - zk2, err := ts.Connect(1) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk2.Close() - - time.Sleep(time.Second * 5) - - if _, err := zk1.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create failed on node 1: %+v", err) - } - if by, _, err := zk2.Get("/gozk-test"); err != nil { - t.Fatalf("Get failed on node 2: %+v", err) - } else if string(by) != "foo-cluster" { - t.Fatal("Wrong data for node 2") - } -} - -// If the current leader dies, then the session is reestablished with the new one. -func TestClientClusterFailover(t *testing.T) { - tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer tc.Stop() - zk, evCh, err := tc.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - sl := NewStateLogger(evCh) - - hasSessionEvent1 := sl.NewWatcher(sessionStateMatcher(StateHasSession)).Wait(8 * time.Second) - if hasSessionEvent1 == nil { - t.Fatalf("Failed to connect and get session") - } - - if _, err := zk.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create failed on node 1: %+v", err) - } - - hasSessionWatcher2 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) - - // Kill the current leader - tc.StopServer(hasSessionEvent1.Server) - - // Wait for the session to be reconnected with the new leader. - if hasSessionWatcher2.Wait(8*time.Second) == nil { - t.Fatalf("Failover failed") - } - - if by, _, err := zk.Get("/gozk-test"); err != nil { - t.Fatalf("Get failed on node 2: %+v", err) - } else if string(by) != "foo-cluster" { - t.Fatal("Wrong data for node 2") - } -} - -// If a ZooKeeper cluster looses quorum then a session is reconnected as soon -// as the quorum is restored. -func TestNoQuorum(t *testing.T) { - tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer tc.Stop() - zk, evCh, err := tc.ConnectAllTimeout(4 * time.Second) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - sl := NewStateLogger(evCh) - - // Wait for initial session to be established - hasSessionEvent1 := sl.NewWatcher(sessionStateMatcher(StateHasSession)).Wait(8 * time.Second) - if hasSessionEvent1 == nil { - t.Fatalf("Failed to connect and get session") - } - initialSessionID := zk.sessionID - DefaultLogger.Printf(" Session established: id=%d, timeout=%d", zk.sessionID, zk.sessionTimeoutMs) - - // Kill the ZooKeeper leader and wait for the session to reconnect. - DefaultLogger.Printf(" Kill the leader") - disconnectWatcher1 := sl.NewWatcher(sessionStateMatcher(StateDisconnected)) - hasSessionWatcher2 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) - tc.StopServer(hasSessionEvent1.Server) - - disconnectedEvent1 := disconnectWatcher1.Wait(8 * time.Second) - if disconnectedEvent1 == nil { - t.Fatalf("Failover failed, missed StateDisconnected event") - } - if disconnectedEvent1.Server != hasSessionEvent1.Server { - t.Fatalf("Unexpected StateDisconnected event, expected=%s, actual=%s", - hasSessionEvent1.Server, disconnectedEvent1.Server) - } - - hasSessionEvent2 := hasSessionWatcher2.Wait(8 * time.Second) - if hasSessionEvent2 == nil { - t.Fatalf("Failover failed, missed StateHasSession event") - } - - // Kill the ZooKeeper leader leaving the cluster without quorum. - DefaultLogger.Printf(" Kill the leader") - disconnectWatcher2 := sl.NewWatcher(sessionStateMatcher(StateDisconnected)) - tc.StopServer(hasSessionEvent2.Server) - - disconnectedEvent2 := disconnectWatcher2.Wait(8 * time.Second) - if disconnectedEvent2 == nil { - t.Fatalf("Failover failed, missed StateDisconnected event") - } - if disconnectedEvent2.Server != hasSessionEvent2.Server { - t.Fatalf("Unexpected StateDisconnected event, expected=%s, actual=%s", - hasSessionEvent2.Server, disconnectedEvent2.Server) - } - - // Make sure that we keep retrying connecting to the only remaining - // ZooKeeper server, but the attempts are being dropped because there is - // no quorum. - DefaultLogger.Printf(" Retrying no luck...") - var firstDisconnect *Event - begin := time.Now() - for time.Now().Sub(begin) < 6*time.Second { - disconnectedEvent := sl.NewWatcher(sessionStateMatcher(StateDisconnected)).Wait(4 * time.Second) - if disconnectedEvent == nil { - t.Fatalf("Disconnected event expected") - } - if firstDisconnect == nil { - firstDisconnect = disconnectedEvent - continue - } - if disconnectedEvent.Server != firstDisconnect.Server { - t.Fatalf("Disconnect from wrong server: expected=%s, actual=%s", - firstDisconnect.Server, disconnectedEvent.Server) - } - } - - // Start a ZooKeeper node to restore quorum. - hasSessionWatcher3 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) - tc.StartServer(hasSessionEvent1.Server) - - // Make sure that session is reconnected with the same ID. - hasSessionEvent3 := hasSessionWatcher3.Wait(8 * time.Second) - if hasSessionEvent3 == nil { - t.Fatalf("Session has not been reconnected") - } - if zk.sessionID != initialSessionID { - t.Fatalf("Wrong session ID: expected=%d, actual=%d", initialSessionID, zk.sessionID) - } - - // Make sure that the session is not dropped soon after reconnect - e := sl.NewWatcher(sessionStateMatcher(StateDisconnected)).Wait(6 * time.Second) - if e != nil { - t.Fatalf("Unexpected disconnect") - } -} - -func TestWaitForClose(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, err := ts.Connect(0) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - timeout := time.After(30 * time.Second) -CONNECTED: - for { - select { - case ev := <-zk.eventChan: - if ev.State == StateConnected { - break CONNECTED - } - case <-timeout: - zk.Close() - t.Fatal("Timeout") - } - } - zk.Close() - for { - select { - case _, ok := <-zk.eventChan: - if !ok { - return - } - case <-timeout: - t.Fatal("Timeout") - } - } -} - -func TestBadSession(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - zk.conn.Close() - time.Sleep(time.Millisecond * 100) - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } -} - -type EventLogger struct { - events []Event - watchers []*EventWatcher - lock sync.Mutex - wg sync.WaitGroup -} - -func NewStateLogger(eventCh <-chan Event) *EventLogger { - el := &EventLogger{} - el.wg.Add(1) - go func() { - defer el.wg.Done() - for event := range eventCh { - el.lock.Lock() - for _, sw := range el.watchers { - if !sw.triggered && sw.matcher(event) { - sw.triggered = true - sw.matchCh <- event - } - } - DefaultLogger.Printf(" event received: %v\n", event) - el.events = append(el.events, event) - el.lock.Unlock() - } - }() - return el -} - -func (el *EventLogger) NewWatcher(matcher func(Event) bool) *EventWatcher { - ew := &EventWatcher{matcher: matcher, matchCh: make(chan Event, 1)} - el.lock.Lock() - el.watchers = append(el.watchers, ew) - el.lock.Unlock() - return ew -} - -func (el *EventLogger) Events() []Event { - el.lock.Lock() - transitions := make([]Event, len(el.events)) - copy(transitions, el.events) - el.lock.Unlock() - return transitions -} - -func (el *EventLogger) Wait4Stop() { - el.wg.Wait() -} - -type EventWatcher struct { - matcher func(Event) bool - matchCh chan Event - triggered bool -} - -func (ew *EventWatcher) Wait(timeout time.Duration) *Event { - select { - case event := <-ew.matchCh: - return &event - case <-time.After(timeout): - return nil - } -} - -func sessionStateMatcher(s State) func(Event) bool { - return func(e Event) bool { - return e.Type == EventSession && e.State == s - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/conn.go b/vendor/github.com/samuel/go-zookeeper/zk/conn.go deleted file mode 100644 index 13fb0f0..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/conn.go +++ /dev/null @@ -1,1193 +0,0 @@ -// Package zk is a native Go client library for the ZooKeeper orchestration service. -package zk - -/* -TODO: -* make sure a ping response comes back in a reasonable time - -Possible watcher events: -* Event{Type: EventNotWatching, State: StateDisconnected, Path: path, Err: err} -*/ - -import ( - "crypto/rand" - "encoding/binary" - "errors" - "fmt" - "io" - "net" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" -) - -// ErrNoServer indicates that an operation cannot be completed -// because attempts to connect to all servers in the list failed. -var ErrNoServer = errors.New("zk: could not connect to a server") - -// ErrInvalidPath indicates that an operation was being attempted on -// an invalid path. (e.g. empty path) -var ErrInvalidPath = errors.New("zk: invalid path") - -// DefaultLogger uses the stdlib log package for logging. -var DefaultLogger Logger = defaultLogger{} - -const ( - bufferSize = 1536 * 1024 - eventChanSize = 6 - sendChanSize = 16 - protectedPrefix = "_c_" -) - -type watchType int - -const ( - watchTypeData = iota - watchTypeExist - watchTypeChild -) - -type watchPathType struct { - path string - wType watchType -} - -type Dialer func(network, address string, timeout time.Duration) (net.Conn, error) - -// Logger is an interface that can be implemented to provide custom log output. -type Logger interface { - Printf(string, ...interface{}) -} - -type authCreds struct { - scheme string - auth []byte -} - -type Conn struct { - lastZxid int64 - sessionID int64 - state State // must be 32-bit aligned - xid uint32 - sessionTimeoutMs int32 // session timeout in milliseconds - passwd []byte - - dialer Dialer - hostProvider HostProvider - serverMu sync.Mutex // protects server - server string // remember the address/port of the current server - conn net.Conn - eventChan chan Event - eventCallback EventCallback // may be nil - shouldQuit chan struct{} - pingInterval time.Duration - recvTimeout time.Duration - connectTimeout time.Duration - maxBufferSize int - - creds []authCreds - credsMu sync.Mutex // protects server - - sendChan chan *request - requests map[int32]*request // Xid -> pending request - requestsLock sync.Mutex - watchers map[watchPathType][]chan Event - watchersLock sync.Mutex - closeChan chan struct{} // channel to tell send loop stop - - // Debug (used by unit tests) - reconnectLatch chan struct{} - setWatchLimit int - setWatchCallback func([]*setWatchesRequest) - - logger Logger - logInfo bool // true if information messages are logged; false if only errors are logged - - buf []byte -} - -// connOption represents a connection option. -type connOption func(c *Conn) - -type request struct { - xid int32 - opcode int32 - pkt interface{} - recvStruct interface{} - recvChan chan response - - // Because sending and receiving happen in separate go routines, there's - // a possible race condition when creating watches from outside the read - // loop. We must ensure that a watcher gets added to the list synchronously - // with the response from the server on any request that creates a watch. - // In order to not hard code the watch logic for each opcode in the recv - // loop the caller can use recvFunc to insert some synchronously code - // after a response. - recvFunc func(*request, *responseHeader, error) -} - -type response struct { - zxid int64 - err error -} - -type Event struct { - Type EventType - State State - Path string // For non-session events, the path of the watched node. - Err error - Server string // For connection events -} - -// HostProvider is used to represent a set of hosts a ZooKeeper client should connect to. -// It is an analog of the Java equivalent: -// http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/client/HostProvider.java?view=markup -type HostProvider interface { - // Init is called first, with the servers specified in the connection string. - Init(servers []string) error - // Len returns the number of servers. - Len() int - // Next returns the next server to connect to. retryStart will be true if we've looped through - // all known servers without Connected() being called. - Next() (server string, retryStart bool) - // Notify the HostProvider of a successful connection. - Connected() -} - -// ConnectWithDialer establishes a new connection to a pool of zookeeper servers -// using a custom Dialer. See Connect for further information about session timeout. -// This method is deprecated and provided for compatibility: use the WithDialer option instead. -func ConnectWithDialer(servers []string, sessionTimeout time.Duration, dialer Dialer) (*Conn, <-chan Event, error) { - return Connect(servers, sessionTimeout, WithDialer(dialer)) -} - -// Connect establishes a new connection to a pool of zookeeper -// servers. The provided session timeout sets the amount of time for which -// a session is considered valid after losing connection to a server. Within -// the session timeout it's possible to reestablish a connection to a different -// server and keep the same session. This is means any ephemeral nodes and -// watches are maintained. -func Connect(servers []string, sessionTimeout time.Duration, options ...connOption) (*Conn, <-chan Event, error) { - if len(servers) == 0 { - return nil, nil, errors.New("zk: server list must not be empty") - } - - srvs := make([]string, len(servers)) - - for i, addr := range servers { - if strings.Contains(addr, ":") { - srvs[i] = addr - } else { - srvs[i] = addr + ":" + strconv.Itoa(DefaultPort) - } - } - - // Randomize the order of the servers to avoid creating hotspots - stringShuffle(srvs) - - ec := make(chan Event, eventChanSize) - conn := &Conn{ - dialer: net.DialTimeout, - hostProvider: &DNSHostProvider{}, - conn: nil, - state: StateDisconnected, - eventChan: ec, - shouldQuit: make(chan struct{}), - connectTimeout: 1 * time.Second, - sendChan: make(chan *request, sendChanSize), - requests: make(map[int32]*request), - watchers: make(map[watchPathType][]chan Event), - passwd: emptyPassword, - logger: DefaultLogger, - logInfo: true, // default is true for backwards compatability - buf: make([]byte, bufferSize), - } - - // Set provided options. - for _, option := range options { - option(conn) - } - - if err := conn.hostProvider.Init(srvs); err != nil { - return nil, nil, err - } - - conn.setTimeouts(int32(sessionTimeout / time.Millisecond)) - - go func() { - conn.loop() - conn.flushRequests(ErrClosing) - conn.invalidateWatches(ErrClosing) - close(conn.eventChan) - }() - return conn, ec, nil -} - -// WithDialer returns a connection option specifying a non-default Dialer. -func WithDialer(dialer Dialer) connOption { - return func(c *Conn) { - c.dialer = dialer - } -} - -// WithHostProvider returns a connection option specifying a non-default HostProvider. -func WithHostProvider(hostProvider HostProvider) connOption { - return func(c *Conn) { - c.hostProvider = hostProvider - } -} - -// WithLogger returns a connection option specifying a non-default Logger -func WithLogger(logger Logger) connOption { - return func(c *Conn) { - c.logger = logger - } -} - -// WithLogInfo returns a connection option specifying whether or not information messages -// shoud be logged. -func WithLogInfo(logInfo bool) connOption { - return func(c *Conn) { - c.logInfo = logInfo - } -} - -// EventCallback is a function that is called when an Event occurs. -type EventCallback func(Event) - -// WithEventCallback returns a connection option that specifies an event -// callback. -// The callback must not block - doing so would delay the ZK go routines. -func WithEventCallback(cb EventCallback) connOption { - return func(c *Conn) { - c.eventCallback = cb - } -} - -// WithMaxBufferSize sets the maximum buffer size used to read and decode -// packets received from the Zookeeper server. The standard Zookeeper client for -// Java defaults to a limit of 1mb. For backwards compatibility, this Go client -// defaults to unbounded unless overridden via this option. A value that is zero -// or negative indicates that no limit is enforced. -// -// This is meant to prevent resource exhaustion in the face of potentially -// malicious data in ZK. It should generally match the server setting (which -// also defaults ot 1mb) so that clients and servers agree on the limits for -// things like the size of data in an individual znode and the total size of a -// transaction. -// -// For production systems, this should be set to a reasonable value (ideally -// that matches the server configuration). For ops tooling, it is handy to use a -// much larger limit, in order to do things like clean-up problematic state in -// the ZK tree. For example, if a single znode has a huge number of children, it -// is possible for the response to a "list children" operation to exceed this -// buffer size and cause errors in clients. The only way to subsequently clean -// up the tree (by removing superfluous children) is to use a client configured -// with a larger buffer size that can successfully query for all of the child -// names and then remove them. (Note there are other tools that can list all of -// the child names without an increased buffer size in the client, but they work -// by inspecting the servers' transaction logs to enumerate children instead of -// sending an online request to a server. -func WithMaxBufferSize(maxBufferSize int) connOption { - return func(c *Conn) { - c.maxBufferSize = maxBufferSize - } -} - -// WithMaxConnBufferSize sets maximum buffer size used to send and encode -// packets to Zookeeper server. The standard Zookeepeer client for java defaults -// to a limit of 1mb. This option should be used for non-standard server setup -// where znode is bigger than default 1mb. -func WithMaxConnBufferSize(maxBufferSize int) connOption { - return func(c *Conn) { - c.buf = make([]byte, maxBufferSize) - } -} - -func (c *Conn) Close() { - close(c.shouldQuit) - - select { - case <-c.queueRequest(opClose, &closeRequest{}, &closeResponse{}, nil): - case <-time.After(time.Second): - } -} - -// State returns the current state of the connection. -func (c *Conn) State() State { - return State(atomic.LoadInt32((*int32)(&c.state))) -} - -// SessionID returns the current session id of the connection. -func (c *Conn) SessionID() int64 { - return atomic.LoadInt64(&c.sessionID) -} - -// SetLogger sets the logger to be used for printing errors. -// Logger is an interface provided by this package. -func (c *Conn) SetLogger(l Logger) { - c.logger = l -} - -func (c *Conn) setTimeouts(sessionTimeoutMs int32) { - c.sessionTimeoutMs = sessionTimeoutMs - sessionTimeout := time.Duration(sessionTimeoutMs) * time.Millisecond - c.recvTimeout = sessionTimeout * 2 / 3 - c.pingInterval = c.recvTimeout / 2 -} - -func (c *Conn) setState(state State) { - atomic.StoreInt32((*int32)(&c.state), int32(state)) - c.sendEvent(Event{Type: EventSession, State: state, Server: c.Server()}) -} - -func (c *Conn) sendEvent(evt Event) { - if c.eventCallback != nil { - c.eventCallback(evt) - } - - select { - case c.eventChan <- evt: - default: - // panic("zk: event channel full - it must be monitored and never allowed to be full") - } -} - -func (c *Conn) connect() error { - var retryStart bool - for { - c.serverMu.Lock() - c.server, retryStart = c.hostProvider.Next() - c.serverMu.Unlock() - c.setState(StateConnecting) - if retryStart { - c.flushUnsentRequests(ErrNoServer) - select { - case <-time.After(time.Second): - // pass - case <-c.shouldQuit: - c.setState(StateDisconnected) - c.flushUnsentRequests(ErrClosing) - return ErrClosing - } - } - - zkConn, err := c.dialer("tcp", c.Server(), c.connectTimeout) - if err == nil { - c.conn = zkConn - c.setState(StateConnected) - if c.logInfo { - c.logger.Printf("Connected to %s", c.Server()) - } - return nil - } - - c.logger.Printf("Failed to connect to %s: %+v", c.Server(), err) - } -} - -func (c *Conn) resendZkAuth(reauthReadyChan chan struct{}) { - c.credsMu.Lock() - defer c.credsMu.Unlock() - - defer close(reauthReadyChan) - - if c.logInfo { - c.logger.Printf("Re-submitting `%d` credentials after reconnect", - len(c.creds)) - } - - for _, cred := range c.creds { - resChan, err := c.sendRequest( - opSetAuth, - &setAuthRequest{Type: 0, - Scheme: cred.scheme, - Auth: cred.auth, - }, - &setAuthResponse{}, - nil) - - if err != nil { - c.logger.Printf("Call to sendRequest failed during credential resubmit: %s", err) - // FIXME(prozlach): lets ignore errors for now - continue - } - - res := <-resChan - if res.err != nil { - c.logger.Printf("Credential re-submit failed: %s", res.err) - // FIXME(prozlach): lets ignore errors for now - continue - } - } -} - -func (c *Conn) sendRequest( - opcode int32, - req interface{}, - res interface{}, - recvFunc func(*request, *responseHeader, error), -) ( - <-chan response, - error, -) { - rq := &request{ - xid: c.nextXid(), - opcode: opcode, - pkt: req, - recvStruct: res, - recvChan: make(chan response, 1), - recvFunc: recvFunc, - } - - if err := c.sendData(rq); err != nil { - return nil, err - } - - return rq.recvChan, nil -} - -func (c *Conn) loop() { - for { - if err := c.connect(); err != nil { - // c.Close() was called - return - } - - err := c.authenticate() - switch { - case err == ErrSessionExpired: - c.logger.Printf("Authentication failed: %s", err) - c.invalidateWatches(err) - case err != nil && c.conn != nil: - c.logger.Printf("Authentication failed: %s", err) - c.conn.Close() - case err == nil: - if c.logInfo { - c.logger.Printf("Authenticated: id=%d, timeout=%d", c.SessionID(), c.sessionTimeoutMs) - } - c.hostProvider.Connected() // mark success - c.closeChan = make(chan struct{}) // channel to tell send loop stop - reauthChan := make(chan struct{}) // channel to tell send loop that authdata has been resubmitted - - var wg sync.WaitGroup - wg.Add(1) - go func() { - <-reauthChan - err := c.sendLoop() - if err != nil || c.logInfo { - c.logger.Printf("Send loop terminated: err=%v", err) - } - c.conn.Close() // causes recv loop to EOF/exit - wg.Done() - }() - - wg.Add(1) - go func() { - err := c.recvLoop(c.conn) - if err != io.EOF || c.logInfo { - c.logger.Printf("Recv loop terminated: err=%v", err) - } - if err == nil { - panic("zk: recvLoop should never return nil error") - } - close(c.closeChan) // tell send loop to exit - wg.Done() - }() - - c.resendZkAuth(reauthChan) - - c.sendSetWatches() - wg.Wait() - } - - c.setState(StateDisconnected) - - select { - case <-c.shouldQuit: - c.flushRequests(ErrClosing) - return - default: - } - - if err != ErrSessionExpired { - err = ErrConnectionClosed - } - c.flushRequests(err) - - if c.reconnectLatch != nil { - select { - case <-c.shouldQuit: - return - case <-c.reconnectLatch: - } - } - } -} - -func (c *Conn) flushUnsentRequests(err error) { - for { - select { - default: - return - case req := <-c.sendChan: - req.recvChan <- response{-1, err} - } - } -} - -// Send error to all pending requests and clear request map -func (c *Conn) flushRequests(err error) { - c.requestsLock.Lock() - for _, req := range c.requests { - req.recvChan <- response{-1, err} - } - c.requests = make(map[int32]*request) - c.requestsLock.Unlock() -} - -// Send error to all watchers and clear watchers map -func (c *Conn) invalidateWatches(err error) { - c.watchersLock.Lock() - defer c.watchersLock.Unlock() - - if len(c.watchers) >= 0 { - for pathType, watchers := range c.watchers { - ev := Event{Type: EventNotWatching, State: StateDisconnected, Path: pathType.path, Err: err} - for _, ch := range watchers { - ch <- ev - close(ch) - } - } - c.watchers = make(map[watchPathType][]chan Event) - } -} - -func (c *Conn) sendSetWatches() { - c.watchersLock.Lock() - defer c.watchersLock.Unlock() - - if len(c.watchers) == 0 { - return - } - - // NB: A ZK server, by default, rejects packets >1mb. So, if we have too - // many watches to reset, we need to break this up into multiple packets - // to avoid hitting that limit. Mirroring the Java client behavior: we are - // conservative in that we limit requests to 128kb (since server limit is - // is actually configurable and could conceivably be configured smaller - // than default of 1mb). - limit := 128 * 1024 - if c.setWatchLimit > 0 { - limit = c.setWatchLimit - } - - var reqs []*setWatchesRequest - var req *setWatchesRequest - var sizeSoFar int - - n := 0 - for pathType, watchers := range c.watchers { - if len(watchers) == 0 { - continue - } - addlLen := 4 + len(pathType.path) - if req == nil || sizeSoFar+addlLen > limit { - if req != nil { - // add to set of requests that we'll send - reqs = append(reqs, req) - } - sizeSoFar = 28 // fixed overhead of a set-watches packet - req = &setWatchesRequest{ - RelativeZxid: c.lastZxid, - DataWatches: make([]string, 0), - ExistWatches: make([]string, 0), - ChildWatches: make([]string, 0), - } - } - sizeSoFar += addlLen - switch pathType.wType { - case watchTypeData: - req.DataWatches = append(req.DataWatches, pathType.path) - case watchTypeExist: - req.ExistWatches = append(req.ExistWatches, pathType.path) - case watchTypeChild: - req.ChildWatches = append(req.ChildWatches, pathType.path) - } - n++ - } - if n == 0 { - return - } - if req != nil { // don't forget any trailing packet we were building - reqs = append(reqs, req) - } - - if c.setWatchCallback != nil { - c.setWatchCallback(reqs) - } - - go func() { - res := &setWatchesResponse{} - // TODO: Pipeline these so queue all of them up before waiting on any - // response. That will require some investigation to make sure there - // aren't failure modes where a blocking write to the channel of requests - // could hang indefinitely and cause this goroutine to leak... - for _, req := range reqs { - _, err := c.request(opSetWatches, req, res, nil) - if err != nil { - c.logger.Printf("Failed to set previous watches: %s", err.Error()) - break - } - } - }() -} - -func (c *Conn) authenticate() error { - buf := make([]byte, 256) - - // Encode and send a connect request. - n, err := encodePacket(buf[4:], &connectRequest{ - ProtocolVersion: protocolVersion, - LastZxidSeen: c.lastZxid, - TimeOut: c.sessionTimeoutMs, - SessionID: c.SessionID(), - Passwd: c.passwd, - }) - if err != nil { - return err - } - - binary.BigEndian.PutUint32(buf[:4], uint32(n)) - - c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout * 10)) - _, err = c.conn.Write(buf[:n+4]) - c.conn.SetWriteDeadline(time.Time{}) - if err != nil { - return err - } - - // Receive and decode a connect response. - c.conn.SetReadDeadline(time.Now().Add(c.recvTimeout * 10)) - _, err = io.ReadFull(c.conn, buf[:4]) - c.conn.SetReadDeadline(time.Time{}) - if err != nil { - return err - } - - blen := int(binary.BigEndian.Uint32(buf[:4])) - if cap(buf) < blen { - buf = make([]byte, blen) - } - - _, err = io.ReadFull(c.conn, buf[:blen]) - if err != nil { - return err - } - - r := connectResponse{} - _, err = decodePacket(buf[:blen], &r) - if err != nil { - return err - } - if r.SessionID == 0 { - atomic.StoreInt64(&c.sessionID, int64(0)) - c.passwd = emptyPassword - c.lastZxid = 0 - c.setState(StateExpired) - return ErrSessionExpired - } - - atomic.StoreInt64(&c.sessionID, r.SessionID) - c.setTimeouts(r.TimeOut) - c.passwd = r.Passwd - c.setState(StateHasSession) - - return nil -} - -func (c *Conn) sendData(req *request) error { - header := &requestHeader{req.xid, req.opcode} - n, err := encodePacket(c.buf[4:], header) - if err != nil { - req.recvChan <- response{-1, err} - return nil - } - - n2, err := encodePacket(c.buf[4+n:], req.pkt) - if err != nil { - req.recvChan <- response{-1, err} - return nil - } - - n += n2 - - binary.BigEndian.PutUint32(c.buf[:4], uint32(n)) - - c.requestsLock.Lock() - select { - case <-c.closeChan: - req.recvChan <- response{-1, ErrConnectionClosed} - c.requestsLock.Unlock() - return ErrConnectionClosed - default: - } - c.requests[req.xid] = req - c.requestsLock.Unlock() - - c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout)) - _, err = c.conn.Write(c.buf[:n+4]) - c.conn.SetWriteDeadline(time.Time{}) - if err != nil { - req.recvChan <- response{-1, err} - c.conn.Close() - return err - } - - return nil -} - -func (c *Conn) sendLoop() error { - pingTicker := time.NewTicker(c.pingInterval) - defer pingTicker.Stop() - - for { - select { - case req := <-c.sendChan: - if err := c.sendData(req); err != nil { - return err - } - case <-pingTicker.C: - n, err := encodePacket(c.buf[4:], &requestHeader{Xid: -2, Opcode: opPing}) - if err != nil { - panic("zk: opPing should never fail to serialize") - } - - binary.BigEndian.PutUint32(c.buf[:4], uint32(n)) - - c.conn.SetWriteDeadline(time.Now().Add(c.recvTimeout)) - _, err = c.conn.Write(c.buf[:n+4]) - c.conn.SetWriteDeadline(time.Time{}) - if err != nil { - c.conn.Close() - return err - } - case <-c.closeChan: - return nil - } - } -} - -func (c *Conn) recvLoop(conn net.Conn) error { - sz := bufferSize - if c.maxBufferSize > 0 && sz > c.maxBufferSize { - sz = c.maxBufferSize - } - buf := make([]byte, sz) - for { - // package length - conn.SetReadDeadline(time.Now().Add(c.recvTimeout)) - _, err := io.ReadFull(conn, buf[:4]) - if err != nil { - return err - } - - blen := int(binary.BigEndian.Uint32(buf[:4])) - if cap(buf) < blen { - if c.maxBufferSize > 0 && blen > c.maxBufferSize { - return fmt.Errorf("received packet from server with length %d, which exceeds max buffer size %d", blen, c.maxBufferSize) - } - buf = make([]byte, blen) - } - - _, err = io.ReadFull(conn, buf[:blen]) - conn.SetReadDeadline(time.Time{}) - if err != nil { - return err - } - - res := responseHeader{} - _, err = decodePacket(buf[:16], &res) - if err != nil { - return err - } - - if res.Xid == -1 { - res := &watcherEvent{} - _, err := decodePacket(buf[16:blen], res) - if err != nil { - return err - } - ev := Event{ - Type: res.Type, - State: res.State, - Path: res.Path, - Err: nil, - } - c.sendEvent(ev) - wTypes := make([]watchType, 0, 2) - switch res.Type { - case EventNodeCreated: - wTypes = append(wTypes, watchTypeExist) - case EventNodeDeleted, EventNodeDataChanged: - wTypes = append(wTypes, watchTypeExist, watchTypeData, watchTypeChild) - case EventNodeChildrenChanged: - wTypes = append(wTypes, watchTypeChild) - } - c.watchersLock.Lock() - for _, t := range wTypes { - wpt := watchPathType{res.Path, t} - if watchers := c.watchers[wpt]; watchers != nil && len(watchers) > 0 { - for _, ch := range watchers { - ch <- ev - close(ch) - } - delete(c.watchers, wpt) - } - } - c.watchersLock.Unlock() - } else if res.Xid == -2 { - // Ping response. Ignore. - } else if res.Xid < 0 { - c.logger.Printf("Xid < 0 (%d) but not ping or watcher event", res.Xid) - } else { - if res.Zxid > 0 { - c.lastZxid = res.Zxid - } - - c.requestsLock.Lock() - req, ok := c.requests[res.Xid] - if ok { - delete(c.requests, res.Xid) - } - c.requestsLock.Unlock() - - if !ok { - c.logger.Printf("Response for unknown request with xid %d", res.Xid) - } else { - if res.Err != 0 { - err = res.Err.toError() - } else { - _, err = decodePacket(buf[16:blen], req.recvStruct) - } - if req.recvFunc != nil { - req.recvFunc(req, &res, err) - } - req.recvChan <- response{res.Zxid, err} - if req.opcode == opClose { - return io.EOF - } - } - } - } -} - -func (c *Conn) nextXid() int32 { - return int32(atomic.AddUint32(&c.xid, 1) & 0x7fffffff) -} - -func (c *Conn) addWatcher(path string, watchType watchType) <-chan Event { - c.watchersLock.Lock() - defer c.watchersLock.Unlock() - - ch := make(chan Event, 1) - wpt := watchPathType{path, watchType} - c.watchers[wpt] = append(c.watchers[wpt], ch) - return ch -} - -func (c *Conn) queueRequest(opcode int32, req interface{}, res interface{}, recvFunc func(*request, *responseHeader, error)) <-chan response { - rq := &request{ - xid: c.nextXid(), - opcode: opcode, - pkt: req, - recvStruct: res, - recvChan: make(chan response, 1), - recvFunc: recvFunc, - } - c.sendChan <- rq - return rq.recvChan -} - -func (c *Conn) request(opcode int32, req interface{}, res interface{}, recvFunc func(*request, *responseHeader, error)) (int64, error) { - r := <-c.queueRequest(opcode, req, res, recvFunc) - return r.zxid, r.err -} - -func (c *Conn) AddAuth(scheme string, auth []byte) error { - _, err := c.request(opSetAuth, &setAuthRequest{Type: 0, Scheme: scheme, Auth: auth}, &setAuthResponse{}, nil) - - if err != nil { - return err - } - - // Remember authdata so that it can be re-submitted on reconnect - // - // FIXME(prozlach): For now we treat "userfoo:passbar" and "userfoo:passbar2" - // as two different entries, which will be re-submitted on reconnet. Some - // research is needed on how ZK treats these cases and - // then maybe switch to something like "map[username] = password" to allow - // only single password for given user with users being unique. - obj := authCreds{ - scheme: scheme, - auth: auth, - } - - c.credsMu.Lock() - c.creds = append(c.creds, obj) - c.credsMu.Unlock() - - return nil -} - -func (c *Conn) Children(path string) ([]string, *Stat, error) { - if err := validatePath(path, false); err != nil { - return nil, nil, err - } - - res := &getChildren2Response{} - _, err := c.request(opGetChildren2, &getChildren2Request{Path: path, Watch: false}, res, nil) - return res.Children, &res.Stat, err -} - -func (c *Conn) ChildrenW(path string) ([]string, *Stat, <-chan Event, error) { - if err := validatePath(path, false); err != nil { - return nil, nil, nil, err - } - - var ech <-chan Event - res := &getChildren2Response{} - _, err := c.request(opGetChildren2, &getChildren2Request{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { - if err == nil { - ech = c.addWatcher(path, watchTypeChild) - } - }) - if err != nil { - return nil, nil, nil, err - } - return res.Children, &res.Stat, ech, err -} - -func (c *Conn) Get(path string) ([]byte, *Stat, error) { - if err := validatePath(path, false); err != nil { - return nil, nil, err - } - - res := &getDataResponse{} - _, err := c.request(opGetData, &getDataRequest{Path: path, Watch: false}, res, nil) - return res.Data, &res.Stat, err -} - -// GetW returns the contents of a znode and sets a watch -func (c *Conn) GetW(path string) ([]byte, *Stat, <-chan Event, error) { - if err := validatePath(path, false); err != nil { - return nil, nil, nil, err - } - - var ech <-chan Event - res := &getDataResponse{} - _, err := c.request(opGetData, &getDataRequest{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { - if err == nil { - ech = c.addWatcher(path, watchTypeData) - } - }) - if err != nil { - return nil, nil, nil, err - } - return res.Data, &res.Stat, ech, err -} - -func (c *Conn) Set(path string, data []byte, version int32) (*Stat, error) { - if err := validatePath(path, false); err != nil { - return nil, err - } - - res := &setDataResponse{} - _, err := c.request(opSetData, &SetDataRequest{path, data, version}, res, nil) - return &res.Stat, err -} - -func (c *Conn) Create(path string, data []byte, flags int32, acl []ACL) (string, error) { - if err := validatePath(path, flags&FlagSequence == FlagSequence); err != nil { - return "", err - } - - res := &createResponse{} - _, err := c.request(opCreate, &CreateRequest{path, data, acl, flags}, res, nil) - return res.Path, err -} - -// CreateProtectedEphemeralSequential fixes a race condition if the server crashes -// after it creates the node. On reconnect the session may still be valid so the -// ephemeral node still exists. Therefore, on reconnect we need to check if a node -// with a GUID generated on create exists. -func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl []ACL) (string, error) { - if err := validatePath(path, true); err != nil { - return "", err - } - - var guid [16]byte - _, err := io.ReadFull(rand.Reader, guid[:16]) - if err != nil { - return "", err - } - guidStr := fmt.Sprintf("%x", guid) - - parts := strings.Split(path, "/") - parts[len(parts)-1] = fmt.Sprintf("%s%s-%s", protectedPrefix, guidStr, parts[len(parts)-1]) - rootPath := strings.Join(parts[:len(parts)-1], "/") - protectedPath := strings.Join(parts, "/") - - var newPath string - for i := 0; i < 3; i++ { - newPath, err = c.Create(protectedPath, data, FlagEphemeral|FlagSequence, acl) - switch err { - case ErrSessionExpired: - // No need to search for the node since it can't exist. Just try again. - case ErrConnectionClosed: - children, _, err := c.Children(rootPath) - if err != nil { - return "", err - } - for _, p := range children { - parts := strings.Split(p, "/") - if pth := parts[len(parts)-1]; strings.HasPrefix(pth, protectedPrefix) { - if g := pth[len(protectedPrefix) : len(protectedPrefix)+32]; g == guidStr { - return rootPath + "/" + p, nil - } - } - } - case nil: - return newPath, nil - default: - return "", err - } - } - return "", err -} - -func (c *Conn) Delete(path string, version int32) error { - if err := validatePath(path, false); err != nil { - return err - } - - _, err := c.request(opDelete, &DeleteRequest{path, version}, &deleteResponse{}, nil) - return err -} - -func (c *Conn) Exists(path string) (bool, *Stat, error) { - if err := validatePath(path, false); err != nil { - return false, nil, err - } - - res := &existsResponse{} - _, err := c.request(opExists, &existsRequest{Path: path, Watch: false}, res, nil) - exists := true - if err == ErrNoNode { - exists = false - err = nil - } - return exists, &res.Stat, err -} - -func (c *Conn) ExistsW(path string) (bool, *Stat, <-chan Event, error) { - if err := validatePath(path, false); err != nil { - return false, nil, nil, err - } - - var ech <-chan Event - res := &existsResponse{} - _, err := c.request(opExists, &existsRequest{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { - if err == nil { - ech = c.addWatcher(path, watchTypeData) - } else if err == ErrNoNode { - ech = c.addWatcher(path, watchTypeExist) - } - }) - exists := true - if err == ErrNoNode { - exists = false - err = nil - } - if err != nil { - return false, nil, nil, err - } - return exists, &res.Stat, ech, err -} - -func (c *Conn) GetACL(path string) ([]ACL, *Stat, error) { - if err := validatePath(path, false); err != nil { - return nil, nil, err - } - - res := &getAclResponse{} - _, err := c.request(opGetAcl, &getAclRequest{Path: path}, res, nil) - return res.Acl, &res.Stat, err -} -func (c *Conn) SetACL(path string, acl []ACL, version int32) (*Stat, error) { - if err := validatePath(path, false); err != nil { - return nil, err - } - - res := &setAclResponse{} - _, err := c.request(opSetAcl, &setAclRequest{Path: path, Acl: acl, Version: version}, res, nil) - return &res.Stat, err -} - -func (c *Conn) Sync(path string) (string, error) { - if err := validatePath(path, false); err != nil { - return "", err - } - - res := &syncResponse{} - _, err := c.request(opSync, &syncRequest{Path: path}, res, nil) - return res.Path, err -} - -type MultiResponse struct { - Stat *Stat - String string - Error error -} - -// Multi executes multiple ZooKeeper operations or none of them. The provided -// ops must be one of *CreateRequest, *DeleteRequest, *SetDataRequest, or -// *CheckVersionRequest. -func (c *Conn) Multi(ops ...interface{}) ([]MultiResponse, error) { - req := &multiRequest{ - Ops: make([]multiRequestOp, 0, len(ops)), - DoneHeader: multiHeader{Type: -1, Done: true, Err: -1}, - } - for _, op := range ops { - var opCode int32 - switch op.(type) { - case *CreateRequest: - opCode = opCreate - case *SetDataRequest: - opCode = opSetData - case *DeleteRequest: - opCode = opDelete - case *CheckVersionRequest: - opCode = opCheck - default: - return nil, fmt.Errorf("unknown operation type %T", op) - } - req.Ops = append(req.Ops, multiRequestOp{multiHeader{opCode, false, -1}, op}) - } - res := &multiResponse{} - _, err := c.request(opMulti, req, res, nil) - mr := make([]MultiResponse, len(res.Ops)) - for i, op := range res.Ops { - mr[i] = MultiResponse{Stat: op.Stat, String: op.String, Error: op.Err.toError()} - } - return mr, err -} - -// Server returns the current or last-connected server name. -func (c *Conn) Server() string { - c.serverMu.Lock() - defer c.serverMu.Unlock() - return c.server -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/constants.go b/vendor/github.com/samuel/go-zookeeper/zk/constants.go deleted file mode 100644 index 33b5563..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/constants.go +++ /dev/null @@ -1,240 +0,0 @@ -package zk - -import ( - "errors" -) - -const ( - protocolVersion = 0 - - DefaultPort = 2181 -) - -const ( - opNotify = 0 - opCreate = 1 - opDelete = 2 - opExists = 3 - opGetData = 4 - opSetData = 5 - opGetAcl = 6 - opSetAcl = 7 - opGetChildren = 8 - opSync = 9 - opPing = 11 - opGetChildren2 = 12 - opCheck = 13 - opMulti = 14 - opClose = -11 - opSetAuth = 100 - opSetWatches = 101 - opError = -1 - // Not in protocol, used internally - opWatcherEvent = -2 -) - -const ( - EventNodeCreated EventType = 1 - EventNodeDeleted EventType = 2 - EventNodeDataChanged EventType = 3 - EventNodeChildrenChanged EventType = 4 - - EventSession EventType = -1 - EventNotWatching EventType = -2 -) - -var ( - eventNames = map[EventType]string{ - EventNodeCreated: "EventNodeCreated", - EventNodeDeleted: "EventNodeDeleted", - EventNodeDataChanged: "EventNodeDataChanged", - EventNodeChildrenChanged: "EventNodeChildrenChanged", - EventSession: "EventSession", - EventNotWatching: "EventNotWatching", - } -) - -const ( - StateUnknown State = -1 - StateDisconnected State = 0 - StateConnecting State = 1 - StateAuthFailed State = 4 - StateConnectedReadOnly State = 5 - StateSaslAuthenticated State = 6 - StateExpired State = -112 - - StateConnected = State(100) - StateHasSession = State(101) -) - -const ( - FlagEphemeral = 1 - FlagSequence = 2 -) - -var ( - stateNames = map[State]string{ - StateUnknown: "StateUnknown", - StateDisconnected: "StateDisconnected", - StateConnectedReadOnly: "StateConnectedReadOnly", - StateSaslAuthenticated: "StateSaslAuthenticated", - StateExpired: "StateExpired", - StateAuthFailed: "StateAuthFailed", - StateConnecting: "StateConnecting", - StateConnected: "StateConnected", - StateHasSession: "StateHasSession", - } -) - -type State int32 - -func (s State) String() string { - if name := stateNames[s]; name != "" { - return name - } - return "Unknown" -} - -type ErrCode int32 - -var ( - ErrConnectionClosed = errors.New("zk: connection closed") - ErrUnknown = errors.New("zk: unknown error") - ErrAPIError = errors.New("zk: api error") - ErrNoNode = errors.New("zk: node does not exist") - ErrNoAuth = errors.New("zk: not authenticated") - ErrBadVersion = errors.New("zk: version conflict") - ErrNoChildrenForEphemerals = errors.New("zk: ephemeral nodes may not have children") - ErrNodeExists = errors.New("zk: node already exists") - ErrNotEmpty = errors.New("zk: node has children") - ErrSessionExpired = errors.New("zk: session has been expired by the server") - ErrInvalidACL = errors.New("zk: invalid ACL specified") - ErrAuthFailed = errors.New("zk: client authentication failed") - ErrClosing = errors.New("zk: zookeeper is closing") - ErrNothing = errors.New("zk: no server responsees to process") - ErrSessionMoved = errors.New("zk: session moved to another server, so operation is ignored") - - // ErrInvalidCallback = errors.New("zk: invalid callback specified") - errCodeToError = map[ErrCode]error{ - 0: nil, - errAPIError: ErrAPIError, - errNoNode: ErrNoNode, - errNoAuth: ErrNoAuth, - errBadVersion: ErrBadVersion, - errNoChildrenForEphemerals: ErrNoChildrenForEphemerals, - errNodeExists: ErrNodeExists, - errNotEmpty: ErrNotEmpty, - errSessionExpired: ErrSessionExpired, - // errInvalidCallback: ErrInvalidCallback, - errInvalidAcl: ErrInvalidACL, - errAuthFailed: ErrAuthFailed, - errClosing: ErrClosing, - errNothing: ErrNothing, - errSessionMoved: ErrSessionMoved, - } -) - -func (e ErrCode) toError() error { - if err, ok := errCodeToError[e]; ok { - return err - } - return ErrUnknown -} - -const ( - errOk = 0 - // System and server-side errors - errSystemError = -1 - errRuntimeInconsistency = -2 - errDataInconsistency = -3 - errConnectionLoss = -4 - errMarshallingError = -5 - errUnimplemented = -6 - errOperationTimeout = -7 - errBadArguments = -8 - errInvalidState = -9 - // API errors - errAPIError ErrCode = -100 - errNoNode ErrCode = -101 // * - errNoAuth ErrCode = -102 - errBadVersion ErrCode = -103 // * - errNoChildrenForEphemerals ErrCode = -108 - errNodeExists ErrCode = -110 // * - errNotEmpty ErrCode = -111 - errSessionExpired ErrCode = -112 - errInvalidCallback ErrCode = -113 - errInvalidAcl ErrCode = -114 - errAuthFailed ErrCode = -115 - errClosing ErrCode = -116 - errNothing ErrCode = -117 - errSessionMoved ErrCode = -118 -) - -// Constants for ACL permissions -const ( - PermRead = 1 << iota - PermWrite - PermCreate - PermDelete - PermAdmin - PermAll = 0x1f -) - -var ( - emptyPassword = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - opNames = map[int32]string{ - opNotify: "notify", - opCreate: "create", - opDelete: "delete", - opExists: "exists", - opGetData: "getData", - opSetData: "setData", - opGetAcl: "getACL", - opSetAcl: "setACL", - opGetChildren: "getChildren", - opSync: "sync", - opPing: "ping", - opGetChildren2: "getChildren2", - opCheck: "check", - opMulti: "multi", - opClose: "close", - opSetAuth: "setAuth", - opSetWatches: "setWatches", - - opWatcherEvent: "watcherEvent", - } -) - -type EventType int32 - -func (t EventType) String() string { - if name := eventNames[t]; name != "" { - return name - } - return "Unknown" -} - -// Mode is used to build custom server modes (leader|follower|standalone). -type Mode uint8 - -func (m Mode) String() string { - if name := modeNames[m]; name != "" { - return name - } - return "unknown" -} - -const ( - ModeUnknown Mode = iota - ModeLeader Mode = iota - ModeFollower Mode = iota - ModeStandalone Mode = iota -) - -var ( - modeNames = map[Mode]string{ - ModeLeader: "leader", - ModeFollower: "follower", - ModeStandalone: "standalone", - } -) diff --git a/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go b/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go deleted file mode 100644 index 9fe6b04..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package zk - -import ( - "fmt" - "testing" -) - -func TestModeString(t *testing.T) { - if fmt.Sprintf("%v", ModeUnknown) != "unknown" { - t.Errorf("unknown value should be 'unknown'") - } - - if fmt.Sprintf("%v", ModeLeader) != "leader" { - t.Errorf("leader value should be 'leader'") - } - - if fmt.Sprintf("%v", ModeFollower) != "follower" { - t.Errorf("follower value should be 'follower'") - } - - if fmt.Sprintf("%v", ModeStandalone) != "standalone" { - t.Errorf("standlone value should be 'standalone'") - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider.go b/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider.go deleted file mode 100644 index f4bba8d..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider.go +++ /dev/null @@ -1,88 +0,0 @@ -package zk - -import ( - "fmt" - "net" - "sync" -) - -// DNSHostProvider is the default HostProvider. It currently matches -// the Java StaticHostProvider, resolving hosts from DNS once during -// the call to Init. It could be easily extended to re-query DNS -// periodically or if there is trouble connecting. -type DNSHostProvider struct { - mu sync.Mutex // Protects everything, so we can add asynchronous updates later. - servers []string - curr int - last int - lookupHost func(string) ([]string, error) // Override of net.LookupHost, for testing. -} - -// Init is called first, with the servers specified in the connection -// string. It uses DNS to look up addresses for each server, then -// shuffles them all together. -func (hp *DNSHostProvider) Init(servers []string) error { - hp.mu.Lock() - defer hp.mu.Unlock() - - lookupHost := hp.lookupHost - if lookupHost == nil { - lookupHost = net.LookupHost - } - - found := []string{} - for _, server := range servers { - host, port, err := net.SplitHostPort(server) - if err != nil { - return err - } - addrs, err := lookupHost(host) - if err != nil { - return err - } - for _, addr := range addrs { - found = append(found, net.JoinHostPort(addr, port)) - } - } - - if len(found) == 0 { - return fmt.Errorf("No hosts found for addresses %q", servers) - } - - // Randomize the order of the servers to avoid creating hotspots - stringShuffle(found) - - hp.servers = found - hp.curr = -1 - hp.last = -1 - - return nil -} - -// Len returns the number of servers available -func (hp *DNSHostProvider) Len() int { - hp.mu.Lock() - defer hp.mu.Unlock() - return len(hp.servers) -} - -// Next returns the next server to connect to. retryStart will be true -// if we've looped through all known servers without Connected() being -// called. -func (hp *DNSHostProvider) Next() (server string, retryStart bool) { - hp.mu.Lock() - defer hp.mu.Unlock() - hp.curr = (hp.curr + 1) % len(hp.servers) - retryStart = hp.curr == hp.last - if hp.last == -1 { - hp.last = 0 - } - return hp.servers[hp.curr], retryStart -} - -// Connected notifies the HostProvider of a successful connection. -func (hp *DNSHostProvider) Connected() { - hp.mu.Lock() - defer hp.mu.Unlock() - hp.last = hp.curr -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go b/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go deleted file mode 100644 index 77a6065..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go +++ /dev/null @@ -1,224 +0,0 @@ -package zk - -import ( - "fmt" - "log" - "testing" - "time" -) - -// localhostLookupHost is a test replacement for net.LookupHost that -// always returns 127.0.0.1 -func localhostLookupHost(host string) ([]string, error) { - return []string{"127.0.0.1"}, nil -} - -// TestDNSHostProviderCreate is just like TestCreate, but with an -// overridden HostProvider that ignores the provided hostname. -func TestDNSHostProviderCreate(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - port := ts.Servers[0].Port - server := fmt.Sprintf("foo.example.com:%d", port) - hostProvider := &DNSHostProvider{lookupHost: localhostLookupHost} - zk, _, err := Connect([]string{server}, time.Second*15, WithHostProvider(hostProvider)) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - path := "/gozk-test" - - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if p != path { - t.Fatalf("Create returned different path '%s' != '%s'", p, path) - } - if data, stat, err := zk.Get(path); err != nil { - t.Fatalf("Get returned error: %+v", err) - } else if stat == nil { - t.Fatal("Get returned nil stat") - } else if len(data) < 4 { - t.Fatal("Get returned wrong size data") - } -} - -// localHostPortsFacade wraps a HostProvider, remapping the -// address/port combinations it returns to "localhost:$PORT" where -// $PORT is chosen from the provided ports. -type localHostPortsFacade struct { - inner HostProvider // The wrapped HostProvider - ports []int // The provided list of ports - nextPort int // The next port to use - mapped map[string]string // Already-mapped address/port combinations -} - -func newLocalHostPortsFacade(inner HostProvider, ports []int) *localHostPortsFacade { - return &localHostPortsFacade{ - inner: inner, - ports: ports, - mapped: make(map[string]string), - } -} - -func (lhpf *localHostPortsFacade) Len() int { return lhpf.inner.Len() } -func (lhpf *localHostPortsFacade) Connected() { lhpf.inner.Connected() } -func (lhpf *localHostPortsFacade) Init(servers []string) error { return lhpf.inner.Init(servers) } -func (lhpf *localHostPortsFacade) Next() (string, bool) { - server, retryStart := lhpf.inner.Next() - - // If we've already set up a mapping for that server, just return it. - if localMapping := lhpf.mapped[server]; localMapping != "" { - return localMapping, retryStart - } - - if lhpf.nextPort == len(lhpf.ports) { - log.Fatalf("localHostPortsFacade out of ports to assign to %q; current config: %q", server, lhpf.mapped) - } - - localMapping := fmt.Sprintf("localhost:%d", lhpf.ports[lhpf.nextPort]) - lhpf.mapped[server] = localMapping - lhpf.nextPort++ - return localMapping, retryStart -} - -var _ HostProvider = &localHostPortsFacade{} - -// TestDNSHostProviderReconnect tests that the zk.Conn correctly -// reconnects when the Zookeeper instance it's connected to -// restarts. It wraps the DNSHostProvider in a lightweight facade that -// remaps addresses to localhost:$PORT combinations corresponding to -// the test ZooKeeper instances. -func TestDNSHostProviderReconnect(t *testing.T) { - ts, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - innerHp := &DNSHostProvider{lookupHost: func(host string) ([]string, error) { - return []string{"192.0.2.1", "192.0.2.2", "192.0.2.3"}, nil - }} - ports := make([]int, 0, len(ts.Servers)) - for _, server := range ts.Servers { - ports = append(ports, server.Port) - } - hp := newLocalHostPortsFacade(innerHp, ports) - - zk, _, err := Connect([]string{"foo.example.com:12345"}, time.Second, WithHostProvider(hp)) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - path := "/gozk-test" - - // Initial operation to force connection. - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - // Figure out which server we're connected to. - currentServer := zk.Server() - t.Logf("Connected to %q. Finding test server index…", currentServer) - serverIndex := -1 - for i, server := range ts.Servers { - server := fmt.Sprintf("localhost:%d", server.Port) - t.Logf("…trying %q", server) - if currentServer == server { - serverIndex = i - t.Logf("…found at index %d", i) - break - } - } - if serverIndex == -1 { - t.Fatalf("Cannot determine test server index.") - } - - // Restart the connected server. - ts.Servers[serverIndex].Srv.Stop() - ts.Servers[serverIndex].Srv.Start() - - // Continue with the basic TestCreate tests. - if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if p != path { - t.Fatalf("Create returned different path '%s' != '%s'", p, path) - } - if data, stat, err := zk.Get(path); err != nil { - t.Fatalf("Get returned error: %+v", err) - } else if stat == nil { - t.Fatal("Get returned nil stat") - } else if len(data) < 4 { - t.Fatal("Get returned wrong size data") - } - - if zk.Server() == currentServer { - t.Errorf("Still connected to %q after restart.", currentServer) - } -} - -// TestDNSHostProviderRetryStart tests the `retryStart` functionality -// of DNSHostProvider. -// It's also probably the clearest visual explanation of exactly how -// it works. -func TestDNSHostProviderRetryStart(t *testing.T) { - t.Parallel() - - hp := &DNSHostProvider{lookupHost: func(host string) ([]string, error) { - return []string{"192.0.2.1", "192.0.2.2", "192.0.2.3"}, nil - }} - - if err := hp.Init([]string{"foo.example.com:12345"}); err != nil { - t.Fatal(err) - } - - testdata := []struct { - retryStartWant bool - callConnected bool - }{ - // Repeated failures. - {false, false}, - {false, false}, - {false, false}, - {true, false}, - {false, false}, - {false, false}, - {true, true}, - - // One success offsets things. - {false, false}, - {false, true}, - {false, true}, - - // Repeated successes. - {false, true}, - {false, true}, - {false, true}, - {false, true}, - {false, true}, - - // And some more failures. - {false, false}, - {false, false}, - {true, false}, // Looped back to last known good server: all alternates failed. - {false, false}, - } - - for i, td := range testdata { - _, retryStartGot := hp.Next() - if retryStartGot != td.retryStartWant { - t.Errorf("%d: retryStart=%v; want %v", i, retryStartGot, td.retryStartWant) - } - if td.callConnected { - hp.Connected() - } - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/flw.go b/vendor/github.com/samuel/go-zookeeper/zk/flw.go deleted file mode 100644 index 3e97f96..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/flw.go +++ /dev/null @@ -1,266 +0,0 @@ -package zk - -import ( - "bufio" - "bytes" - "fmt" - "io/ioutil" - "net" - "regexp" - "strconv" - "strings" - "time" -) - -// FLWSrvr is a FourLetterWord helper function. In particular, this function pulls the srvr output -// from the zookeeper instances and parses the output. A slice of *ServerStats structs are returned -// as well as a boolean value to indicate whether this function processed successfully. -// -// If the boolean value is false there was a problem. If the *ServerStats slice is empty or nil, -// then the error happened before we started to obtain 'srvr' values. Otherwise, one of the -// servers had an issue and the "Error" value in the struct should be inspected to determine -// which server had the issue. -func FLWSrvr(servers []string, timeout time.Duration) ([]*ServerStats, bool) { - // different parts of the regular expression that are required to parse the srvr output - const ( - zrVer = `^Zookeeper version: ([A-Za-z0-9\.\-]+), built on (\d\d/\d\d/\d\d\d\d \d\d:\d\d [A-Za-z0-9:\+\-]+)` - zrLat = `^Latency min/avg/max: (\d+)/(\d+)/(\d+)` - zrNet = `^Received: (\d+).*\n^Sent: (\d+).*\n^Connections: (\d+).*\n^Outstanding: (\d+)` - zrState = `^Zxid: (0x[A-Za-z0-9]+).*\n^Mode: (\w+).*\n^Node count: (\d+)` - ) - - // build the regex from the pieces above - re, err := regexp.Compile(fmt.Sprintf(`(?m:\A%v.*\n%v.*\n%v.*\n%v)`, zrVer, zrLat, zrNet, zrState)) - if err != nil { - return nil, false - } - - imOk := true - servers = FormatServers(servers) - ss := make([]*ServerStats, len(servers)) - - for i := range ss { - response, err := fourLetterWord(servers[i], "srvr", timeout) - - if err != nil { - ss[i] = &ServerStats{Error: err} - imOk = false - continue - } - - matches := re.FindAllStringSubmatch(string(response), -1) - - if matches == nil { - err := fmt.Errorf("unable to parse fields from zookeeper response (no regex matches)") - ss[i] = &ServerStats{Error: err} - imOk = false - continue - } - - match := matches[0][1:] - - // determine current server - var srvrMode Mode - switch match[10] { - case "leader": - srvrMode = ModeLeader - case "follower": - srvrMode = ModeFollower - case "standalone": - srvrMode = ModeStandalone - default: - srvrMode = ModeUnknown - } - - buildTime, err := time.Parse("01/02/2006 15:04 MST", match[1]) - - if err != nil { - ss[i] = &ServerStats{Error: err} - imOk = false - continue - } - - parsedInt, err := strconv.ParseInt(match[9], 0, 64) - - if err != nil { - ss[i] = &ServerStats{Error: err} - imOk = false - continue - } - - // the ZxID value is an int64 with two int32s packed inside - // the high int32 is the epoch (i.e., number of leader elections) - // the low int32 is the counter - epoch := int32(parsedInt >> 32) - counter := int32(parsedInt & 0xFFFFFFFF) - - // within the regex above, these values must be numerical - // so we can avoid useless checking of the error return value - minLatency, _ := strconv.ParseInt(match[2], 0, 64) - avgLatency, _ := strconv.ParseInt(match[3], 0, 64) - maxLatency, _ := strconv.ParseInt(match[4], 0, 64) - recv, _ := strconv.ParseInt(match[5], 0, 64) - sent, _ := strconv.ParseInt(match[6], 0, 64) - cons, _ := strconv.ParseInt(match[7], 0, 64) - outs, _ := strconv.ParseInt(match[8], 0, 64) - ncnt, _ := strconv.ParseInt(match[11], 0, 64) - - ss[i] = &ServerStats{ - Sent: sent, - Received: recv, - NodeCount: ncnt, - MinLatency: minLatency, - AvgLatency: avgLatency, - MaxLatency: maxLatency, - Connections: cons, - Outstanding: outs, - Epoch: epoch, - Counter: counter, - BuildTime: buildTime, - Mode: srvrMode, - Version: match[0], - } - } - - return ss, imOk -} - -// FLWRuok is a FourLetterWord helper function. In particular, this function -// pulls the ruok output from each server. -func FLWRuok(servers []string, timeout time.Duration) []bool { - servers = FormatServers(servers) - oks := make([]bool, len(servers)) - - for i := range oks { - response, err := fourLetterWord(servers[i], "ruok", timeout) - - if err != nil { - continue - } - - if bytes.Equal(response[:4], []byte("imok")) { - oks[i] = true - } - } - return oks -} - -// FLWCons is a FourLetterWord helper function. In particular, this function -// pulls the ruok output from each server. -// -// As with FLWSrvr, the boolean value indicates whether one of the requests had -// an issue. The Clients struct has an Error value that can be checked. -func FLWCons(servers []string, timeout time.Duration) ([]*ServerClients, bool) { - const ( - zrAddr = `^ /((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):(?:\d+))\[\d+\]` - zrPac = `\(queued=(\d+),recved=(\d+),sent=(\d+),sid=(0x[A-Za-z0-9]+),lop=(\w+),est=(\d+),to=(\d+),` - zrSesh = `lcxid=(0x[A-Za-z0-9]+),lzxid=(0x[A-Za-z0-9]+),lresp=(\d+),llat=(\d+),minlat=(\d+),avglat=(\d+),maxlat=(\d+)\)` - ) - - re, err := regexp.Compile(fmt.Sprintf("%v%v%v", zrAddr, zrPac, zrSesh)) - if err != nil { - return nil, false - } - - servers = FormatServers(servers) - sc := make([]*ServerClients, len(servers)) - imOk := true - - for i := range sc { - response, err := fourLetterWord(servers[i], "cons", timeout) - - if err != nil { - sc[i] = &ServerClients{Error: err} - imOk = false - continue - } - - scan := bufio.NewScanner(bytes.NewReader(response)) - - var clients []*ServerClient - - for scan.Scan() { - line := scan.Bytes() - - if len(line) == 0 { - continue - } - - m := re.FindAllStringSubmatch(string(line), -1) - - if m == nil { - err := fmt.Errorf("unable to parse fields from zookeeper response (no regex matches)") - sc[i] = &ServerClients{Error: err} - imOk = false - continue - } - - match := m[0][1:] - - queued, _ := strconv.ParseInt(match[1], 0, 64) - recvd, _ := strconv.ParseInt(match[2], 0, 64) - sent, _ := strconv.ParseInt(match[3], 0, 64) - sid, _ := strconv.ParseInt(match[4], 0, 64) - est, _ := strconv.ParseInt(match[6], 0, 64) - timeout, _ := strconv.ParseInt(match[7], 0, 32) - lcxid, _ := parseInt64(match[8]) - lzxid, _ := parseInt64(match[9]) - lresp, _ := strconv.ParseInt(match[10], 0, 64) - llat, _ := strconv.ParseInt(match[11], 0, 32) - minlat, _ := strconv.ParseInt(match[12], 0, 32) - avglat, _ := strconv.ParseInt(match[13], 0, 32) - maxlat, _ := strconv.ParseInt(match[14], 0, 32) - - clients = append(clients, &ServerClient{ - Queued: queued, - Received: recvd, - Sent: sent, - SessionID: sid, - Lcxid: int64(lcxid), - Lzxid: int64(lzxid), - Timeout: int32(timeout), - LastLatency: int32(llat), - MinLatency: int32(minlat), - AvgLatency: int32(avglat), - MaxLatency: int32(maxlat), - Established: time.Unix(est, 0), - LastResponse: time.Unix(lresp, 0), - Addr: match[0], - LastOperation: match[5], - }) - } - - sc[i] = &ServerClients{Clients: clients} - } - - return sc, imOk -} - -// parseInt64 is similar to strconv.ParseInt, but it also handles hex values that represent negative numbers -func parseInt64(s string) (int64, error) { - if strings.HasPrefix(s, "0x") { - i, err := strconv.ParseUint(s, 0, 64) - return int64(i), err - } - return strconv.ParseInt(s, 0, 64) -} - -func fourLetterWord(server, command string, timeout time.Duration) ([]byte, error) { - conn, err := net.DialTimeout("tcp", server, timeout) - if err != nil { - return nil, err - } - - // the zookeeper server should automatically close this socket - // once the command has been processed, but better safe than sorry - defer conn.Close() - - conn.SetWriteDeadline(time.Now().Add(timeout)) - _, err = conn.Write([]byte(command)) - if err != nil { - return nil, err - } - - conn.SetReadDeadline(time.Now().Add(timeout)) - return ioutil.ReadAll(conn) -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go b/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go deleted file mode 100644 index 5bbabb9..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go +++ /dev/null @@ -1,330 +0,0 @@ -package zk - -import ( - "net" - "testing" - "time" -) - -var ( - zkSrvrOut = `Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT -Latency min/avg/max: 0/1/10 -Received: 4207 -Sent: 4220 -Connections: 81 -Outstanding: 1 -Zxid: 0x110a7a8f37 -Mode: leader -Node count: 306 -` - zkConsOut = ` /10.42.45.231:45361[1](queued=0,recved=9435,sent=9457,sid=0x94c2989e04716b5,lop=PING,est=1427238717217,to=20001,lcxid=0x55120915,lzxid=0xffffffffffffffff,lresp=1427259255908,llat=0,minlat=0,avglat=1,maxlat=17) - /10.55.33.98:34342[1](queued=0,recved=9338,sent=9350,sid=0x94c2989e0471731,lop=PING,est=1427238849319,to=20001,lcxid=0x55120944,lzxid=0xffffffffffffffff,lresp=1427259252294,llat=0,minlat=0,avglat=1,maxlat=18) - /10.44.145.114:46556[1](queued=0,recved=109253,sent=109617,sid=0x94c2989e0471709,lop=DELE,est=1427238791305,to=20001,lcxid=0x55139618,lzxid=0x110a7b187d,lresp=1427259257423,llat=2,minlat=0,avglat=1,maxlat=23) - -` -) - -func TestFLWRuok(t *testing.T) { - t.Parallel() - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - go tcpServer(l, "") - - oks := FLWRuok([]string{l.Addr().String()}, time.Second*10) - if len(oks) == 0 { - t.Errorf("no values returned") - } - if !oks[0] { - t.Errorf("instance should be marked as OK") - } - - // - // Confirm that it also returns false for dead instances - // - l, err = net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - go tcpServer(l, "dead") - - oks = FLWRuok([]string{l.Addr().String()}, time.Second*10) - if len(oks) == 0 { - t.Errorf("no values returned") - } - if oks[0] { - t.Errorf("instance should be marked as not OK") - } -} - -func TestFLWSrvr(t *testing.T) { - t.Parallel() - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - go tcpServer(l, "") - - statsSlice, ok := FLWSrvr([]string{l.Addr().String()}, time.Second*10) - if !ok { - t.Errorf("failure indicated on 'srvr' parsing") - } - if len(statsSlice) == 0 { - t.Errorf("no *ServerStats instances returned") - } - - stats := statsSlice[0] - - if stats.Error != nil { - t.Fatalf("error seen in stats: %v", err.Error()) - } - - if stats.Sent != 4220 { - t.Errorf("Sent != 4220") - } - - if stats.Received != 4207 { - t.Errorf("Received != 4207") - } - - if stats.NodeCount != 306 { - t.Errorf("NodeCount != 306") - } - - if stats.MinLatency != 0 { - t.Errorf("MinLatency != 0") - } - - if stats.AvgLatency != 1 { - t.Errorf("AvgLatency != 1") - } - - if stats.MaxLatency != 10 { - t.Errorf("MaxLatency != 10") - } - - if stats.Connections != 81 { - t.Errorf("Connection != 81") - } - - if stats.Outstanding != 1 { - t.Errorf("Outstanding != 1") - } - - if stats.Epoch != 17 { - t.Errorf("Epoch != 17") - } - - if stats.Counter != 175804215 { - t.Errorf("Counter != 175804215") - } - - if stats.Mode != ModeLeader { - t.Errorf("Mode != ModeLeader") - } - - if stats.Version != "3.4.6-1569965" { - t.Errorf("Version expected: 3.4.6-1569965") - } -} - -func TestFLWCons(t *testing.T) { - t.Parallel() - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - go tcpServer(l, "") - - clients, ok := FLWCons([]string{l.Addr().String()}, time.Second*10) - if !ok { - t.Errorf("failure indicated on 'cons' parsing") - } - if len(clients) == 0 { - t.Errorf("no *ServerClients instances returned") - } - - results := []*ServerClient{ - { - Queued: 0, - Received: 9435, - Sent: 9457, - SessionID: 669956116721374901, - LastOperation: "PING", - Established: time.Unix(1427238717217, 0), - Timeout: 20001, - Lcxid: 1427245333, - Lzxid: -1, - LastResponse: time.Unix(1427259255908, 0), - LastLatency: 0, - MinLatency: 0, - AvgLatency: 1, - MaxLatency: 17, - Addr: "10.42.45.231:45361", - }, - { - Queued: 0, - Received: 9338, - Sent: 9350, - SessionID: 669956116721375025, - LastOperation: "PING", - Established: time.Unix(1427238849319, 0), - Timeout: 20001, - Lcxid: 1427245380, - Lzxid: -1, - LastResponse: time.Unix(1427259252294, 0), - LastLatency: 0, - MinLatency: 0, - AvgLatency: 1, - MaxLatency: 18, - Addr: "10.55.33.98:34342", - }, - { - Queued: 0, - Received: 109253, - Sent: 109617, - SessionID: 669956116721374985, - LastOperation: "DELE", - Established: time.Unix(1427238791305, 0), - Timeout: 20001, - Lcxid: 1427346968, - Lzxid: 73190283389, - LastResponse: time.Unix(1427259257423, 0), - LastLatency: 2, - MinLatency: 0, - AvgLatency: 1, - MaxLatency: 23, - Addr: "10.44.145.114:46556", - }, - } - - for _, z := range clients { - if z.Error != nil { - t.Errorf("error seen: %v", err.Error()) - } - - for i, v := range z.Clients { - c := results[i] - - if v.Error != nil { - t.Errorf("client error seen: %v", err.Error()) - } - - if v.Queued != c.Queued { - t.Errorf("Queued value mismatch (%d/%d)", v.Queued, c.Queued) - } - - if v.Received != c.Received { - t.Errorf("Received value mismatch (%d/%d)", v.Received, c.Received) - } - - if v.Sent != c.Sent { - t.Errorf("Sent value mismatch (%d/%d)", v.Sent, c.Sent) - } - - if v.SessionID != c.SessionID { - t.Errorf("SessionID value mismatch (%d/%d)", v.SessionID, c.SessionID) - } - - if v.LastOperation != c.LastOperation { - t.Errorf("LastOperation value mismatch ('%v'/'%v')", v.LastOperation, c.LastOperation) - } - - if v.Timeout != c.Timeout { - t.Errorf("Timeout value mismatch (%d/%d)", v.Timeout, c.Timeout) - } - - if v.Lcxid != c.Lcxid { - t.Errorf("Lcxid value mismatch (%d/%d)", v.Lcxid, c.Lcxid) - } - - if v.Lzxid != c.Lzxid { - t.Errorf("Lzxid value mismatch (%d/%d)", v.Lzxid, c.Lzxid) - } - - if v.LastLatency != c.LastLatency { - t.Errorf("LastLatency value mismatch (%d/%d)", v.LastLatency, c.LastLatency) - } - - if v.MinLatency != c.MinLatency { - t.Errorf("MinLatency value mismatch (%d/%d)", v.MinLatency, c.MinLatency) - } - - if v.AvgLatency != c.AvgLatency { - t.Errorf("AvgLatency value mismatch (%d/%d)", v.AvgLatency, c.AvgLatency) - } - - if v.MaxLatency != c.MaxLatency { - t.Errorf("MaxLatency value mismatch (%d/%d)", v.MaxLatency, c.MaxLatency) - } - - if v.Addr != c.Addr { - t.Errorf("Addr value mismatch ('%v'/'%v')", v.Addr, c.Addr) - } - - if !c.Established.Equal(v.Established) { - t.Errorf("Established value mismatch (%v/%v)", c.Established, v.Established) - } - - if !c.LastResponse.Equal(v.LastResponse) { - t.Errorf("Established value mismatch (%v/%v)", c.LastResponse, v.LastResponse) - } - } - } -} - -func tcpServer(listener net.Listener, thing string) { - for { - conn, err := listener.Accept() - if err != nil { - return - } - go connHandler(conn, thing) - } -} - -func connHandler(conn net.Conn, thing string) { - defer conn.Close() - - data := make([]byte, 4) - - _, err := conn.Read(data) - if err != nil { - return - } - - switch string(data) { - case "ruok": - switch thing { - case "dead": - return - default: - conn.Write([]byte("imok")) - } - case "srvr": - switch thing { - case "dead": - return - default: - conn.Write([]byte(zkSrvrOut)) - } - case "cons": - switch thing { - case "dead": - return - default: - conn.Write([]byte(zkConsOut)) - } - default: - conn.Write([]byte("This ZooKeeper instance is not currently serving requests.")) - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/lock.go b/vendor/github.com/samuel/go-zookeeper/zk/lock.go deleted file mode 100644 index 3c35a42..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/lock.go +++ /dev/null @@ -1,150 +0,0 @@ -package zk - -import ( - "errors" - "fmt" - "strconv" - "strings" -) - -var ( - // ErrDeadlock is returned by Lock when trying to lock twice without unlocking first - ErrDeadlock = errors.New("zk: trying to acquire a lock twice") - // ErrNotLocked is returned by Unlock when trying to release a lock that has not first be acquired. - ErrNotLocked = errors.New("zk: not locked") -) - -// Lock is a mutual exclusion lock. -type Lock struct { - c *Conn - path string - acl []ACL - lockPath string - seq int -} - -// NewLock creates a new lock instance using the provided connection, path, and acl. -// The path must be a node that is only used by this lock. A lock instances starts -// unlocked until Lock() is called. -func NewLock(c *Conn, path string, acl []ACL) *Lock { - return &Lock{ - c: c, - path: path, - acl: acl, - } -} - -func parseSeq(path string) (int, error) { - parts := strings.Split(path, "-") - return strconv.Atoi(parts[len(parts)-1]) -} - -// Lock attempts to acquire the lock. It will wait to return until the lock -// is acquired or an error occurs. If this instance already has the lock -// then ErrDeadlock is returned. -func (l *Lock) Lock() error { - if l.lockPath != "" { - return ErrDeadlock - } - - prefix := fmt.Sprintf("%s/lock-", l.path) - - path := "" - var err error - for i := 0; i < 3; i++ { - path, err = l.c.CreateProtectedEphemeralSequential(prefix, []byte{}, l.acl) - if err == ErrNoNode { - // Create parent node. - parts := strings.Split(l.path, "/") - pth := "" - for _, p := range parts[1:] { - var exists bool - pth += "/" + p - exists, _, err = l.c.Exists(pth) - if err != nil { - return err - } - if exists == true { - continue - } - _, err = l.c.Create(pth, []byte{}, 0, l.acl) - if err != nil && err != ErrNodeExists { - return err - } - } - } else if err == nil { - break - } else { - return err - } - } - if err != nil { - return err - } - - seq, err := parseSeq(path) - if err != nil { - return err - } - - for { - children, _, err := l.c.Children(l.path) - if err != nil { - return err - } - - lowestSeq := seq - prevSeq := -1 - prevSeqPath := "" - for _, p := range children { - s, err := parseSeq(p) - if err != nil { - return err - } - if s < lowestSeq { - lowestSeq = s - } - if s < seq && s > prevSeq { - prevSeq = s - prevSeqPath = p - } - } - - if seq == lowestSeq { - // Acquired the lock - break - } - - // Wait on the node next in line for the lock - _, _, ch, err := l.c.GetW(l.path + "/" + prevSeqPath) - if err != nil && err != ErrNoNode { - return err - } else if err != nil && err == ErrNoNode { - // try again - continue - } - - ev := <-ch - if ev.Err != nil { - return ev.Err - } - } - - l.seq = seq - l.lockPath = path - return nil -} - -// Unlock releases an acquired lock. If the lock is not currently acquired by -// this Lock instance than ErrNotLocked is returned. -func (l *Lock) Unlock() error { - if l.lockPath == "" { - return ErrNotLocked - } - if err := l.c.Delete(l.lockPath, -1); err != nil { - return err - } - l.lockPath = "" - l.seq = 0 - return nil -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go b/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go deleted file mode 100644 index 8a3478a..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go +++ /dev/null @@ -1,94 +0,0 @@ -package zk - -import ( - "testing" - "time" -) - -func TestLock(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - acls := WorldACL(PermAll) - - l := NewLock(zk, "/test", acls) - if err := l.Lock(); err != nil { - t.Fatal(err) - } - if err := l.Unlock(); err != nil { - t.Fatal(err) - } - - val := make(chan int, 3) - - if err := l.Lock(); err != nil { - t.Fatal(err) - } - - l2 := NewLock(zk, "/test", acls) - go func() { - if err := l2.Lock(); err != nil { - t.Fatal(err) - } - val <- 2 - if err := l2.Unlock(); err != nil { - t.Fatal(err) - } - val <- 3 - }() - time.Sleep(time.Millisecond * 100) - - val <- 1 - if err := l.Unlock(); err != nil { - t.Fatal(err) - } - if x := <-val; x != 1 { - t.Fatalf("Expected 1 instead of %d", x) - } - if x := <-val; x != 2 { - t.Fatalf("Expected 2 instead of %d", x) - } - if x := <-val; x != 3 { - t.Fatalf("Expected 3 instead of %d", x) - } -} - -// This tests creating a lock with a path that's more than 1 node deep (e.g. "/test-multi-level/lock"), -// when a part of that path already exists (i.e. "/test-multi-level" node already exists). -func TestMultiLevelLock(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - acls := WorldACL(PermAll) - path := "/test-multi-level" - if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if p != path { - t.Fatalf("Create returned different path '%s' != '%s'", p, path) - } - l := NewLock(zk, "/test-multi-level/lock", acls) - defer zk.Delete("/test-multi-level", -1) // Clean up what we've created for this test - defer zk.Delete("/test-multi-level/lock", -1) - if err := l.Lock(); err != nil { - t.Fatal(err) - } - if err := l.Unlock(); err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/server_help.go b/vendor/github.com/samuel/go-zookeeper/zk/server_help.go deleted file mode 100644 index 3663064..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/server_help.go +++ /dev/null @@ -1,216 +0,0 @@ -package zk - -import ( - "fmt" - "io" - "io/ioutil" - "math/rand" - "os" - "path/filepath" - "strings" - "time" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -type TestServer struct { - Port int - Path string - Srv *Server -} - -type TestCluster struct { - Path string - Servers []TestServer -} - -func StartTestCluster(size int, stdout, stderr io.Writer) (*TestCluster, error) { - tmpPath, err := ioutil.TempDir("", "gozk") - if err != nil { - return nil, err - } - success := false - startPort := int(rand.Int31n(6000) + 10000) - cluster := &TestCluster{Path: tmpPath} - defer func() { - if !success { - cluster.Stop() - } - }() - for serverN := 0; serverN < size; serverN++ { - srvPath := filepath.Join(tmpPath, fmt.Sprintf("srv%d", serverN)) - if err := os.Mkdir(srvPath, 0700); err != nil { - return nil, err - } - port := startPort + serverN*3 - cfg := ServerConfig{ - ClientPort: port, - DataDir: srvPath, - } - for i := 0; i < size; i++ { - cfg.Servers = append(cfg.Servers, ServerConfigServer{ - ID: i + 1, - Host: "127.0.0.1", - PeerPort: startPort + i*3 + 1, - LeaderElectionPort: startPort + i*3 + 2, - }) - } - cfgPath := filepath.Join(srvPath, "zoo.cfg") - fi, err := os.Create(cfgPath) - if err != nil { - return nil, err - } - err = cfg.Marshall(fi) - fi.Close() - if err != nil { - return nil, err - } - - fi, err = os.Create(filepath.Join(srvPath, "myid")) - if err != nil { - return nil, err - } - _, err = fmt.Fprintf(fi, "%d\n", serverN+1) - fi.Close() - if err != nil { - return nil, err - } - - srv := &Server{ - ConfigPath: cfgPath, - Stdout: stdout, - Stderr: stderr, - } - if err := srv.Start(); err != nil { - return nil, err - } - cluster.Servers = append(cluster.Servers, TestServer{ - Path: srvPath, - Port: cfg.ClientPort, - Srv: srv, - }) - } - if err := cluster.waitForStart(10, time.Second); err != nil { - return nil, err - } - success = true - return cluster, nil -} - -func (tc *TestCluster) Connect(idx int) (*Conn, error) { - zk, _, err := Connect([]string{fmt.Sprintf("127.0.0.1:%d", tc.Servers[idx].Port)}, time.Second*15) - return zk, err -} - -func (tc *TestCluster) ConnectAll() (*Conn, <-chan Event, error) { - return tc.ConnectAllTimeout(time.Second * 15) -} - -func (tc *TestCluster) ConnectAllTimeout(sessionTimeout time.Duration) (*Conn, <-chan Event, error) { - return tc.ConnectWithOptions(sessionTimeout) -} - -func (tc *TestCluster) ConnectWithOptions(sessionTimeout time.Duration, options ...connOption) (*Conn, <-chan Event, error) { - hosts := make([]string, len(tc.Servers)) - for i, srv := range tc.Servers { - hosts[i] = fmt.Sprintf("127.0.0.1:%d", srv.Port) - } - zk, ch, err := Connect(hosts, sessionTimeout, options...) - return zk, ch, err -} - -func (tc *TestCluster) Stop() error { - for _, srv := range tc.Servers { - srv.Srv.Stop() - } - defer os.RemoveAll(tc.Path) - return tc.waitForStop(5, time.Second) -} - -// waitForStart blocks until the cluster is up -func (tc *TestCluster) waitForStart(maxRetry int, interval time.Duration) error { - // verify that the servers are up with SRVR - serverAddrs := make([]string, len(tc.Servers)) - for i, s := range tc.Servers { - serverAddrs[i] = fmt.Sprintf("127.0.0.1:%d", s.Port) - } - - for i := 0; i < maxRetry; i++ { - _, ok := FLWSrvr(serverAddrs, time.Second) - if ok { - return nil - } - time.Sleep(interval) - } - return fmt.Errorf("unable to verify health of servers") -} - -// waitForStop blocks until the cluster is down -func (tc *TestCluster) waitForStop(maxRetry int, interval time.Duration) error { - // verify that the servers are up with RUOK - serverAddrs := make([]string, len(tc.Servers)) - for i, s := range tc.Servers { - serverAddrs[i] = fmt.Sprintf("127.0.0.1:%d", s.Port) - } - - var success bool - for i := 0; i < maxRetry && !success; i++ { - success = true - for _, ok := range FLWRuok(serverAddrs, time.Second) { - if ok { - success = false - } - } - if !success { - time.Sleep(interval) - } - } - if !success { - return fmt.Errorf("unable to verify servers are down") - } - return nil -} - -func (tc *TestCluster) StartServer(server string) { - for _, s := range tc.Servers { - if strings.HasSuffix(server, fmt.Sprintf(":%d", s.Port)) { - s.Srv.Start() - return - } - } - panic(fmt.Sprintf("Unknown server: %s", server)) -} - -func (tc *TestCluster) StopServer(server string) { - for _, s := range tc.Servers { - if strings.HasSuffix(server, fmt.Sprintf(":%d", s.Port)) { - s.Srv.Stop() - return - } - } - panic(fmt.Sprintf("Unknown server: %s", server)) -} - -func (tc *TestCluster) StartAllServers() error { - for _, s := range tc.Servers { - if err := s.Srv.Start(); err != nil { - return fmt.Errorf( - "Failed to start server listening on port `%d` : %+v", s.Port, err) - } - } - - return nil -} - -func (tc *TestCluster) StopAllServers() error { - for _, s := range tc.Servers { - if err := s.Srv.Stop(); err != nil { - return fmt.Errorf( - "Failed to stop server listening on port `%d` : %+v", s.Port, err) - } - } - - return nil -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/server_java.go b/vendor/github.com/samuel/go-zookeeper/zk/server_java.go deleted file mode 100644 index e553ec1..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/server_java.go +++ /dev/null @@ -1,136 +0,0 @@ -package zk - -import ( - "fmt" - "io" - "os" - "os/exec" - "path/filepath" -) - -type ErrMissingServerConfigField string - -func (e ErrMissingServerConfigField) Error() string { - return fmt.Sprintf("zk: missing server config field '%s'", string(e)) -} - -const ( - DefaultServerTickTime = 2000 - DefaultServerInitLimit = 10 - DefaultServerSyncLimit = 5 - DefaultServerAutoPurgeSnapRetainCount = 3 - DefaultPeerPort = 2888 - DefaultLeaderElectionPort = 3888 -) - -type ServerConfigServer struct { - ID int - Host string - PeerPort int - LeaderElectionPort int -} - -type ServerConfig struct { - TickTime int // Number of milliseconds of each tick - InitLimit int // Number of ticks that the initial synchronization phase can take - SyncLimit int // Number of ticks that can pass between sending a request and getting an acknowledgement - DataDir string // Direcrory where the snapshot is stored - ClientPort int // Port at which clients will connect - AutoPurgeSnapRetainCount int // Number of snapshots to retain in dataDir - AutoPurgePurgeInterval int // Purge task internal in hours (0 to disable auto purge) - Servers []ServerConfigServer -} - -func (sc ServerConfig) Marshall(w io.Writer) error { - if sc.DataDir == "" { - return ErrMissingServerConfigField("dataDir") - } - fmt.Fprintf(w, "dataDir=%s\n", sc.DataDir) - if sc.TickTime <= 0 { - sc.TickTime = DefaultServerTickTime - } - fmt.Fprintf(w, "tickTime=%d\n", sc.TickTime) - if sc.InitLimit <= 0 { - sc.InitLimit = DefaultServerInitLimit - } - fmt.Fprintf(w, "initLimit=%d\n", sc.InitLimit) - if sc.SyncLimit <= 0 { - sc.SyncLimit = DefaultServerSyncLimit - } - fmt.Fprintf(w, "syncLimit=%d\n", sc.SyncLimit) - if sc.ClientPort <= 0 { - sc.ClientPort = DefaultPort - } - fmt.Fprintf(w, "clientPort=%d\n", sc.ClientPort) - if sc.AutoPurgePurgeInterval > 0 { - if sc.AutoPurgeSnapRetainCount <= 0 { - sc.AutoPurgeSnapRetainCount = DefaultServerAutoPurgeSnapRetainCount - } - fmt.Fprintf(w, "autopurge.snapRetainCount=%d\n", sc.AutoPurgeSnapRetainCount) - fmt.Fprintf(w, "autopurge.purgeInterval=%d\n", sc.AutoPurgePurgeInterval) - } - if len(sc.Servers) > 0 { - for _, srv := range sc.Servers { - if srv.PeerPort <= 0 { - srv.PeerPort = DefaultPeerPort - } - if srv.LeaderElectionPort <= 0 { - srv.LeaderElectionPort = DefaultLeaderElectionPort - } - fmt.Fprintf(w, "server.%d=%s:%d:%d\n", srv.ID, srv.Host, srv.PeerPort, srv.LeaderElectionPort) - } - } - return nil -} - -var jarSearchPaths = []string{ - "zookeeper-*/contrib/fatjar/zookeeper-*-fatjar.jar", - "../zookeeper-*/contrib/fatjar/zookeeper-*-fatjar.jar", - "/usr/share/java/zookeeper-*.jar", - "/usr/local/zookeeper-*/contrib/fatjar/zookeeper-*-fatjar.jar", - "/usr/local/Cellar/zookeeper/*/libexec/contrib/fatjar/zookeeper-*-fatjar.jar", -} - -func findZookeeperFatJar() string { - var paths []string - zkPath := os.Getenv("ZOOKEEPER_PATH") - if zkPath == "" { - paths = jarSearchPaths - } else { - paths = []string{filepath.Join(zkPath, "contrib/fatjar/zookeeper-*-fatjar.jar")} - } - for _, path := range paths { - matches, _ := filepath.Glob(path) - // TODO: could sort by version and pick latest - if len(matches) > 0 { - return matches[0] - } - } - return "" -} - -type Server struct { - JarPath string - ConfigPath string - Stdout, Stderr io.Writer - - cmd *exec.Cmd -} - -func (srv *Server) Start() error { - if srv.JarPath == "" { - srv.JarPath = findZookeeperFatJar() - if srv.JarPath == "" { - return fmt.Errorf("zk: unable to find server jar") - } - } - srv.cmd = exec.Command("java", "-jar", srv.JarPath, "server", srv.ConfigPath) - srv.cmd.Stdout = srv.Stdout - srv.cmd.Stderr = srv.Stderr - return srv.cmd.Start() -} - -func (srv *Server) Stop() error { - srv.cmd.Process.Signal(os.Kill) - return srv.cmd.Wait() -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/structs.go b/vendor/github.com/samuel/go-zookeeper/zk/structs.go deleted file mode 100644 index d4af27d..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/structs.go +++ /dev/null @@ -1,609 +0,0 @@ -package zk - -import ( - "encoding/binary" - "errors" - "log" - "reflect" - "runtime" - "time" -) - -var ( - ErrUnhandledFieldType = errors.New("zk: unhandled field type") - ErrPtrExpected = errors.New("zk: encode/decode expect a non-nil pointer to struct") - ErrShortBuffer = errors.New("zk: buffer too small") -) - -type defaultLogger struct{} - -func (defaultLogger) Printf(format string, a ...interface{}) { - log.Printf(format, a...) -} - -type ACL struct { - Perms int32 - Scheme string - ID string -} - -type Stat struct { - Czxid int64 // The zxid of the change that caused this znode to be created. - Mzxid int64 // The zxid of the change that last modified this znode. - Ctime int64 // The time in milliseconds from epoch when this znode was created. - Mtime int64 // The time in milliseconds from epoch when this znode was last modified. - Version int32 // The number of changes to the data of this znode. - Cversion int32 // The number of changes to the children of this znode. - Aversion int32 // The number of changes to the ACL of this znode. - EphemeralOwner int64 // The session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero. - DataLength int32 // The length of the data field of this znode. - NumChildren int32 // The number of children of this znode. - Pzxid int64 // last modified children -} - -// ServerClient is the information for a single Zookeeper client and its session. -// This is used to parse/extract the output fo the `cons` command. -type ServerClient struct { - Queued int64 - Received int64 - Sent int64 - SessionID int64 - Lcxid int64 - Lzxid int64 - Timeout int32 - LastLatency int32 - MinLatency int32 - AvgLatency int32 - MaxLatency int32 - Established time.Time - LastResponse time.Time - Addr string - LastOperation string // maybe? - Error error -} - -// ServerClients is a struct for the FLWCons() function. It's used to provide -// the list of Clients. -// -// This is needed because FLWCons() takes multiple servers. -type ServerClients struct { - Clients []*ServerClient - Error error -} - -// ServerStats is the information pulled from the Zookeeper `stat` command. -type ServerStats struct { - Sent int64 - Received int64 - NodeCount int64 - MinLatency int64 - AvgLatency int64 - MaxLatency int64 - Connections int64 - Outstanding int64 - Epoch int32 - Counter int32 - BuildTime time.Time - Mode Mode - Version string - Error error -} - -type requestHeader struct { - Xid int32 - Opcode int32 -} - -type responseHeader struct { - Xid int32 - Zxid int64 - Err ErrCode -} - -type multiHeader struct { - Type int32 - Done bool - Err ErrCode -} - -type auth struct { - Type int32 - Scheme string - Auth []byte -} - -// Generic request structs - -type pathRequest struct { - Path string -} - -type PathVersionRequest struct { - Path string - Version int32 -} - -type pathWatchRequest struct { - Path string - Watch bool -} - -type pathResponse struct { - Path string -} - -type statResponse struct { - Stat Stat -} - -// - -type CheckVersionRequest PathVersionRequest -type closeRequest struct{} -type closeResponse struct{} - -type connectRequest struct { - ProtocolVersion int32 - LastZxidSeen int64 - TimeOut int32 - SessionID int64 - Passwd []byte -} - -type connectResponse struct { - ProtocolVersion int32 - TimeOut int32 - SessionID int64 - Passwd []byte -} - -type CreateRequest struct { - Path string - Data []byte - Acl []ACL - Flags int32 -} - -type createResponse pathResponse -type DeleteRequest PathVersionRequest -type deleteResponse struct{} - -type errorResponse struct { - Err int32 -} - -type existsRequest pathWatchRequest -type existsResponse statResponse -type getAclRequest pathRequest - -type getAclResponse struct { - Acl []ACL - Stat Stat -} - -type getChildrenRequest pathRequest - -type getChildrenResponse struct { - Children []string -} - -type getChildren2Request pathWatchRequest - -type getChildren2Response struct { - Children []string - Stat Stat -} - -type getDataRequest pathWatchRequest - -type getDataResponse struct { - Data []byte - Stat Stat -} - -type getMaxChildrenRequest pathRequest - -type getMaxChildrenResponse struct { - Max int32 -} - -type getSaslRequest struct { - Token []byte -} - -type pingRequest struct{} -type pingResponse struct{} - -type setAclRequest struct { - Path string - Acl []ACL - Version int32 -} - -type setAclResponse statResponse - -type SetDataRequest struct { - Path string - Data []byte - Version int32 -} - -type setDataResponse statResponse - -type setMaxChildren struct { - Path string - Max int32 -} - -type setSaslRequest struct { - Token string -} - -type setSaslResponse struct { - Token string -} - -type setWatchesRequest struct { - RelativeZxid int64 - DataWatches []string - ExistWatches []string - ChildWatches []string -} - -type setWatchesResponse struct{} - -type syncRequest pathRequest -type syncResponse pathResponse - -type setAuthRequest auth -type setAuthResponse struct{} - -type multiRequestOp struct { - Header multiHeader - Op interface{} -} -type multiRequest struct { - Ops []multiRequestOp - DoneHeader multiHeader -} -type multiResponseOp struct { - Header multiHeader - String string - Stat *Stat - Err ErrCode -} -type multiResponse struct { - Ops []multiResponseOp - DoneHeader multiHeader -} - -func (r *multiRequest) Encode(buf []byte) (int, error) { - total := 0 - for _, op := range r.Ops { - op.Header.Done = false - n, err := encodePacketValue(buf[total:], reflect.ValueOf(op)) - if err != nil { - return total, err - } - total += n - } - r.DoneHeader.Done = true - n, err := encodePacketValue(buf[total:], reflect.ValueOf(r.DoneHeader)) - if err != nil { - return total, err - } - total += n - - return total, nil -} - -func (r *multiRequest) Decode(buf []byte) (int, error) { - r.Ops = make([]multiRequestOp, 0) - r.DoneHeader = multiHeader{-1, true, -1} - total := 0 - for { - header := &multiHeader{} - n, err := decodePacketValue(buf[total:], reflect.ValueOf(header)) - if err != nil { - return total, err - } - total += n - if header.Done { - r.DoneHeader = *header - break - } - - req := requestStructForOp(header.Type) - if req == nil { - return total, ErrAPIError - } - n, err = decodePacketValue(buf[total:], reflect.ValueOf(req)) - if err != nil { - return total, err - } - total += n - r.Ops = append(r.Ops, multiRequestOp{*header, req}) - } - return total, nil -} - -func (r *multiResponse) Decode(buf []byte) (int, error) { - var multiErr error - - r.Ops = make([]multiResponseOp, 0) - r.DoneHeader = multiHeader{-1, true, -1} - total := 0 - for { - header := &multiHeader{} - n, err := decodePacketValue(buf[total:], reflect.ValueOf(header)) - if err != nil { - return total, err - } - total += n - if header.Done { - r.DoneHeader = *header - break - } - - res := multiResponseOp{Header: *header} - var w reflect.Value - switch header.Type { - default: - return total, ErrAPIError - case opError: - w = reflect.ValueOf(&res.Err) - case opCreate: - w = reflect.ValueOf(&res.String) - case opSetData: - res.Stat = new(Stat) - w = reflect.ValueOf(res.Stat) - case opCheck, opDelete: - } - if w.IsValid() { - n, err := decodePacketValue(buf[total:], w) - if err != nil { - return total, err - } - total += n - } - r.Ops = append(r.Ops, res) - if multiErr == nil && res.Err != errOk { - // Use the first error as the error returned from Multi(). - multiErr = res.Err.toError() - } - } - return total, multiErr -} - -type watcherEvent struct { - Type EventType - State State - Path string -} - -type decoder interface { - Decode(buf []byte) (int, error) -} - -type encoder interface { - Encode(buf []byte) (int, error) -} - -func decodePacket(buf []byte, st interface{}) (n int, err error) { - defer func() { - if r := recover(); r != nil { - if e, ok := r.(runtime.Error); ok && e.Error() == "runtime error: slice bounds out of range" { - err = ErrShortBuffer - } else { - panic(r) - } - } - }() - - v := reflect.ValueOf(st) - if v.Kind() != reflect.Ptr || v.IsNil() { - return 0, ErrPtrExpected - } - return decodePacketValue(buf, v) -} - -func decodePacketValue(buf []byte, v reflect.Value) (int, error) { - rv := v - kind := v.Kind() - if kind == reflect.Ptr { - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - v = v.Elem() - kind = v.Kind() - } - - n := 0 - switch kind { - default: - return n, ErrUnhandledFieldType - case reflect.Struct: - if de, ok := rv.Interface().(decoder); ok { - return de.Decode(buf) - } else if de, ok := v.Interface().(decoder); ok { - return de.Decode(buf) - } else { - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - n2, err := decodePacketValue(buf[n:], field) - n += n2 - if err != nil { - return n, err - } - } - } - case reflect.Bool: - v.SetBool(buf[n] != 0) - n++ - case reflect.Int32: - v.SetInt(int64(binary.BigEndian.Uint32(buf[n : n+4]))) - n += 4 - case reflect.Int64: - v.SetInt(int64(binary.BigEndian.Uint64(buf[n : n+8]))) - n += 8 - case reflect.String: - ln := int(binary.BigEndian.Uint32(buf[n : n+4])) - v.SetString(string(buf[n+4 : n+4+ln])) - n += 4 + ln - case reflect.Slice: - switch v.Type().Elem().Kind() { - default: - count := int(binary.BigEndian.Uint32(buf[n : n+4])) - n += 4 - values := reflect.MakeSlice(v.Type(), count, count) - v.Set(values) - for i := 0; i < count; i++ { - n2, err := decodePacketValue(buf[n:], values.Index(i)) - n += n2 - if err != nil { - return n, err - } - } - case reflect.Uint8: - ln := int(int32(binary.BigEndian.Uint32(buf[n : n+4]))) - if ln < 0 { - n += 4 - v.SetBytes(nil) - } else { - bytes := make([]byte, ln) - copy(bytes, buf[n+4:n+4+ln]) - v.SetBytes(bytes) - n += 4 + ln - } - } - } - return n, nil -} - -func encodePacket(buf []byte, st interface{}) (n int, err error) { - defer func() { - if r := recover(); r != nil { - if e, ok := r.(runtime.Error); ok && e.Error() == "runtime error: slice bounds out of range" { - err = ErrShortBuffer - } else { - panic(r) - } - } - }() - - v := reflect.ValueOf(st) - if v.Kind() != reflect.Ptr || v.IsNil() { - return 0, ErrPtrExpected - } - return encodePacketValue(buf, v) -} - -func encodePacketValue(buf []byte, v reflect.Value) (int, error) { - rv := v - for v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface { - v = v.Elem() - } - - n := 0 - switch v.Kind() { - default: - return n, ErrUnhandledFieldType - case reflect.Struct: - if en, ok := rv.Interface().(encoder); ok { - return en.Encode(buf) - } else if en, ok := v.Interface().(encoder); ok { - return en.Encode(buf) - } else { - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - n2, err := encodePacketValue(buf[n:], field) - n += n2 - if err != nil { - return n, err - } - } - } - case reflect.Bool: - if v.Bool() { - buf[n] = 1 - } else { - buf[n] = 0 - } - n++ - case reflect.Int32: - binary.BigEndian.PutUint32(buf[n:n+4], uint32(v.Int())) - n += 4 - case reflect.Int64: - binary.BigEndian.PutUint64(buf[n:n+8], uint64(v.Int())) - n += 8 - case reflect.String: - str := v.String() - binary.BigEndian.PutUint32(buf[n:n+4], uint32(len(str))) - copy(buf[n+4:n+4+len(str)], []byte(str)) - n += 4 + len(str) - case reflect.Slice: - switch v.Type().Elem().Kind() { - default: - count := v.Len() - startN := n - n += 4 - for i := 0; i < count; i++ { - n2, err := encodePacketValue(buf[n:], v.Index(i)) - n += n2 - if err != nil { - return n, err - } - } - binary.BigEndian.PutUint32(buf[startN:startN+4], uint32(count)) - case reflect.Uint8: - if v.IsNil() { - binary.BigEndian.PutUint32(buf[n:n+4], uint32(0xffffffff)) - n += 4 - } else { - bytes := v.Bytes() - binary.BigEndian.PutUint32(buf[n:n+4], uint32(len(bytes))) - copy(buf[n+4:n+4+len(bytes)], bytes) - n += 4 + len(bytes) - } - } - } - return n, nil -} - -func requestStructForOp(op int32) interface{} { - switch op { - case opClose: - return &closeRequest{} - case opCreate: - return &CreateRequest{} - case opDelete: - return &DeleteRequest{} - case opExists: - return &existsRequest{} - case opGetAcl: - return &getAclRequest{} - case opGetChildren: - return &getChildrenRequest{} - case opGetChildren2: - return &getChildren2Request{} - case opGetData: - return &getDataRequest{} - case opPing: - return &pingRequest{} - case opSetAcl: - return &setAclRequest{} - case opSetData: - return &SetDataRequest{} - case opSetWatches: - return &setWatchesRequest{} - case opSync: - return &syncRequest{} - case opSetAuth: - return &setAuthRequest{} - case opCheck: - return &CheckVersionRequest{} - case opMulti: - return &multiRequest{} - } - return nil -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go b/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go deleted file mode 100644 index a3f2797..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package zk - -import ( - "reflect" - "testing" -) - -func TestEncodeDecodePacket(t *testing.T) { - t.Parallel() - encodeDecodeTest(t, &requestHeader{-2, 5}) - encodeDecodeTest(t, &connectResponse{1, 2, 3, nil}) - encodeDecodeTest(t, &connectResponse{1, 2, 3, []byte{4, 5, 6}}) - encodeDecodeTest(t, &getAclResponse{[]ACL{{12, "s", "anyone"}}, Stat{}}) - encodeDecodeTest(t, &getChildrenResponse{[]string{"foo", "bar"}}) - encodeDecodeTest(t, &pathWatchRequest{"path", true}) - encodeDecodeTest(t, &pathWatchRequest{"path", false}) - encodeDecodeTest(t, &CheckVersionRequest{"/", -1}) - encodeDecodeTest(t, &multiRequest{Ops: []multiRequestOp{{multiHeader{opCheck, false, -1}, &CheckVersionRequest{"/", -1}}}}) -} - -func TestRequestStructForOp(t *testing.T) { - for op, name := range opNames { - if op != opNotify && op != opWatcherEvent { - if s := requestStructForOp(op); s == nil { - t.Errorf("No struct for op %s", name) - } - } - } -} - -func encodeDecodeTest(t *testing.T, r interface{}) { - buf := make([]byte, 1024) - n, err := encodePacket(buf, r) - if err != nil { - t.Errorf("encodePacket returned non-nil error %+v\n", err) - return - } - t.Logf("%+v %x", r, buf[:n]) - r2 := reflect.New(reflect.ValueOf(r).Elem().Type()).Interface() - n2, err := decodePacket(buf[:n], r2) - if err != nil { - t.Errorf("decodePacket returned non-nil error %+v\n", err) - return - } - if n != n2 { - t.Errorf("sizes don't match: %d != %d", n, n2) - return - } - if !reflect.DeepEqual(r, r2) { - t.Errorf("results don't match: %+v != %+v", r, r2) - return - } -} - -func TestEncodeShortBuffer(t *testing.T) { - t.Parallel() - _, err := encodePacket([]byte{}, &requestHeader{1, 2}) - if err != ErrShortBuffer { - t.Errorf("encodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) - return - } -} - -func TestDecodeShortBuffer(t *testing.T) { - t.Parallel() - _, err := decodePacket([]byte{}, &responseHeader{}) - if err != ErrShortBuffer { - t.Errorf("decodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) - return - } -} - -func BenchmarkEncode(b *testing.B) { - buf := make([]byte, 4096) - st := &connectRequest{Passwd: []byte("1234567890")} - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := encodePacket(buf, st); err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go b/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go deleted file mode 100644 index 633ce05..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright 2012 Google Inc. - -Licensed 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. -*/ - -// Vendored from go4.org/net/throttle - -package zk - -import ( - "fmt" - "net" - "sync" - "time" -) - -const unitSize = 1400 // read/write chunk size. ~MTU size. - -type Rate struct { - KBps int // or 0, to not rate-limit bandwidth - Latency time.Duration -} - -// byteTime returns the time required for n bytes. -func (r Rate) byteTime(n int) time.Duration { - if r.KBps == 0 { - return 0 - } - return time.Duration(float64(n)/1024/float64(r.KBps)) * time.Second -} - -type Listener struct { - net.Listener - Down Rate // server Writes to Client - Up Rate // server Reads from client -} - -func (ln *Listener) Accept() (net.Conn, error) { - c, err := ln.Listener.Accept() - time.Sleep(ln.Up.Latency) - if err != nil { - return nil, err - } - tc := &conn{Conn: c, Down: ln.Down, Up: ln.Up} - tc.start() - return tc, nil -} - -type nErr struct { - n int - err error -} - -type writeReq struct { - writeAt time.Time - p []byte - resc chan nErr -} - -type conn struct { - net.Conn - Down Rate // for reads - Up Rate // for writes - - wchan chan writeReq - closeOnce sync.Once - closeErr error -} - -func (c *conn) start() { - c.wchan = make(chan writeReq, 1024) - go c.writeLoop() -} - -func (c *conn) writeLoop() { - for req := range c.wchan { - time.Sleep(req.writeAt.Sub(time.Now())) - var res nErr - for len(req.p) > 0 && res.err == nil { - writep := req.p - if len(writep) > unitSize { - writep = writep[:unitSize] - } - n, err := c.Conn.Write(writep) - time.Sleep(c.Up.byteTime(len(writep))) - res.n += n - res.err = err - req.p = req.p[n:] - } - req.resc <- res - } -} - -func (c *conn) Close() error { - c.closeOnce.Do(func() { - err := c.Conn.Close() - close(c.wchan) - c.closeErr = err - }) - return c.closeErr -} - -func (c *conn) Write(p []byte) (n int, err error) { - defer func() { - if e := recover(); e != nil { - n = 0 - err = fmt.Errorf("%v", err) - return - } - }() - resc := make(chan nErr, 1) - c.wchan <- writeReq{time.Now().Add(c.Up.Latency), p, resc} - res := <-resc - return res.n, res.err -} - -func (c *conn) Read(p []byte) (n int, err error) { - const max = 1024 - if len(p) > max { - p = p[:max] - } - n, err = c.Conn.Read(p) - time.Sleep(c.Down.byteTime(n)) - return -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/util.go b/vendor/github.com/samuel/go-zookeeper/zk/util.go deleted file mode 100644 index f40a5b1..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/util.go +++ /dev/null @@ -1,116 +0,0 @@ -package zk - -import ( - "crypto/sha1" - "encoding/base64" - "fmt" - "math/rand" - "strconv" - "strings" - "unicode/utf8" -) - -// AuthACL produces an ACL list containing a single ACL which uses the -// provided permissions, with the scheme "auth", and ID "", which is used -// by ZooKeeper to represent any authenticated user. -func AuthACL(perms int32) []ACL { - return []ACL{{perms, "auth", ""}} -} - -// WorldACL produces an ACL list containing a single ACL which uses the -// provided permissions, with the scheme "world", and ID "anyone", which -// is used by ZooKeeper to represent any user at all. -func WorldACL(perms int32) []ACL { - return []ACL{{perms, "world", "anyone"}} -} - -func DigestACL(perms int32, user, password string) []ACL { - userPass := []byte(fmt.Sprintf("%s:%s", user, password)) - h := sha1.New() - if n, err := h.Write(userPass); err != nil || n != len(userPass) { - panic("SHA1 failed") - } - digest := base64.StdEncoding.EncodeToString(h.Sum(nil)) - return []ACL{{perms, "digest", fmt.Sprintf("%s:%s", user, digest)}} -} - -// FormatServers takes a slice of addresses, and makes sure they are in a format -// that resembles :. If the server has no port provided, the -// DefaultPort constant is added to the end. -func FormatServers(servers []string) []string { - for i := range servers { - if !strings.Contains(servers[i], ":") { - servers[i] = servers[i] + ":" + strconv.Itoa(DefaultPort) - } - } - return servers -} - -// stringShuffle performs a Fisher-Yates shuffle on a slice of strings -func stringShuffle(s []string) { - for i := len(s) - 1; i > 0; i-- { - j := rand.Intn(i + 1) - s[i], s[j] = s[j], s[i] - } -} - -// validatePath will make sure a path is valid before sending the request -func validatePath(path string, isSequential bool) error { - if path == "" { - return ErrInvalidPath - } - - if path[0] != '/' { - return ErrInvalidPath - } - - n := len(path) - if n == 1 { - // path is just the root - return nil - } - - if !isSequential && path[n-1] == '/' { - return ErrInvalidPath - } - - // Start at rune 1 since we already know that the first character is - // a '/'. - for i, w := 1, 0; i < n; i += w { - r, width := utf8.DecodeRuneInString(path[i:]) - switch { - case r == '\u0000': - return ErrInvalidPath - case r == '/': - last, _ := utf8.DecodeLastRuneInString(path[:i]) - if last == '/' { - return ErrInvalidPath - } - case r == '.': - last, lastWidth := utf8.DecodeLastRuneInString(path[:i]) - - // Check for double dot - if last == '.' { - last, _ = utf8.DecodeLastRuneInString(path[:i-lastWidth]) - } - - if last == '/' { - if i+1 == n { - return ErrInvalidPath - } - - next, _ := utf8.DecodeRuneInString(path[i+w:]) - if next == '/' { - return ErrInvalidPath - } - } - case r >= '\u0000' && r <= '\u001f', - r >= '\u007f' && r <= '\u009f', - r >= '\uf000' && r <= '\uf8ff', - r >= '\ufff0' && r < '\uffff': - return ErrInvalidPath - } - w = width - } - return nil -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/util_test.go b/vendor/github.com/samuel/go-zookeeper/zk/util_test.go deleted file mode 100644 index 53a5950..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/util_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package zk - -import "testing" - -func TestFormatServers(t *testing.T) { - t.Parallel() - servers := []string{"127.0.0.1:2181", "127.0.0.42", "127.0.42.1:8811"} - r := []string{"127.0.0.1:2181", "127.0.0.42:2181", "127.0.42.1:8811"} - for i, s := range FormatServers(servers) { - if s != r[i] { - t.Errorf("%v should equal %v", s, r[i]) - } - } -} - -func TestValidatePath(t *testing.T) { - tt := []struct { - path string - seq bool - valid bool - }{ - {"/this is / a valid/path", false, true}, - {"/", false, true}, - {"", false, false}, - {"not/valid", false, false}, - {"/ends/with/slash/", false, false}, - {"/sequential/", true, true}, - {"/test\u0000", false, false}, - {"/double//slash", false, false}, - {"/single/./period", false, false}, - {"/double/../period", false, false}, - {"/double/..ok/period", false, true}, - {"/double/alsook../period", false, true}, - {"/double/period/at/end/..", false, false}, - {"/name/with.period", false, true}, - {"/test\u0001", false, false}, - {"/test\u001f", false, false}, - {"/test\u0020", false, true}, // first allowable - {"/test\u007e", false, true}, // last valid ascii - {"/test\u007f", false, false}, - {"/test\u009f", false, false}, - {"/test\uf8ff", false, false}, - {"/test\uffef", false, true}, - {"/test\ufff0", false, false}, - } - - for _, tc := range tt { - err := validatePath(tc.path, tc.seq) - if (err != nil) == tc.valid { - t.Errorf("failed to validate path %q", tc.path) - } - } -} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go b/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go deleted file mode 100644 index c81ef9f..0000000 --- a/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go +++ /dev/null @@ -1,939 +0,0 @@ -package zk - -import ( - "crypto/rand" - "encoding/hex" - "fmt" - "io" - "net" - "reflect" - "regexp" - "sort" - "strings" - "sync" - "sync/atomic" - "testing" - "time" -) - -func TestStateChanges(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - callbackChan := make(chan Event) - f := func(event Event) { - callbackChan <- event - } - - zk, eventChan, err := ts.ConnectWithOptions(15*time.Second, WithEventCallback(f)) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - - verifyEventOrder := func(c <-chan Event, expectedStates []State, source string) { - for _, state := range expectedStates { - for { - event, ok := <-c - if !ok { - t.Fatalf("unexpected channel close for %s", source) - } - - if event.Type != EventSession { - continue - } - - if event.State != state { - t.Fatalf("mismatched state order from %s, expected %v, received %v", source, state, event.State) - } - break - } - } - } - - states := []State{StateConnecting, StateConnected, StateHasSession} - verifyEventOrder(callbackChan, states, "callback") - verifyEventOrder(eventChan, states, "event channel") - - zk.Close() - verifyEventOrder(callbackChan, []State{StateDisconnected}, "callback") - verifyEventOrder(eventChan, []State{StateDisconnected}, "event channel") -} - -func TestCreate(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - path := "/gozk-test" - - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if p != path { - t.Fatalf("Create returned different path '%s' != '%s'", p, path) - } - if data, stat, err := zk.Get(path); err != nil { - t.Fatalf("Get returned error: %+v", err) - } else if stat == nil { - t.Fatal("Get returned nil stat") - } else if len(data) < 4 { - t.Fatal("Get returned wrong size data") - } -} - -func TestMulti(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - path := "/gozk-test" - - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - ops := []interface{}{ - &CreateRequest{Path: path, Data: []byte{1, 2, 3, 4}, Acl: WorldACL(PermAll)}, - &SetDataRequest{Path: path, Data: []byte{1, 2, 3, 4}, Version: -1}, - } - if res, err := zk.Multi(ops...); err != nil { - t.Fatalf("Multi returned error: %+v", err) - } else if len(res) != 2 { - t.Fatalf("Expected 2 responses got %d", len(res)) - } else { - t.Logf("%+v", res) - } - if data, stat, err := zk.Get(path); err != nil { - t.Fatalf("Get returned error: %+v", err) - } else if stat == nil { - t.Fatal("Get returned nil stat") - } else if len(data) < 4 { - t.Fatal("Get returned wrong size data") - } -} - -func TestIfAuthdataSurvivesReconnect(t *testing.T) { - // This test case ensures authentication data is being resubmited after - // reconnect. - testNode := "/auth-testnode" - - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - acl := DigestACL(PermAll, "userfoo", "passbar") - - _, err = zk.Create(testNode, []byte("Some very secret content"), 0, acl) - if err != nil && err != ErrNodeExists { - t.Fatalf("Failed to create test node : %+v", err) - } - - _, _, err = zk.Get(testNode) - if err == nil || err != ErrNoAuth { - var msg string - - if err == nil { - msg = "Fetching data without auth should have resulted in an error" - } else { - msg = fmt.Sprintf("Expecting ErrNoAuth, got `%+v` instead", err) - } - t.Fatalf(msg) - } - - zk.AddAuth("digest", []byte("userfoo:passbar")) - - _, _, err = zk.Get(testNode) - if err != nil { - t.Fatalf("Fetching data with auth failed: %+v", err) - } - - ts.StopAllServers() - ts.StartAllServers() - - _, _, err = zk.Get(testNode) - if err != nil { - t.Fatalf("Fetching data after reconnect failed: %+v", err) - } -} - -func TestMultiFailures(t *testing.T) { - // This test case ensures that we return the errors associated with each - // opeThis in the event a call to Multi() fails. - const firstPath = "/gozk-test-first" - const secondPath = "/gozk-test-second" - - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - // Ensure firstPath doesn't exist and secondPath does. This will cause the - // 2nd operation in the Multi() to fail. - if err := zk.Delete(firstPath, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - if _, err := zk.Create(secondPath, nil /* data */, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } - - ops := []interface{}{ - &CreateRequest{Path: firstPath, Data: []byte{1, 2}, Acl: WorldACL(PermAll)}, - &CreateRequest{Path: secondPath, Data: []byte{3, 4}, Acl: WorldACL(PermAll)}, - } - res, err := zk.Multi(ops...) - if err != ErrNodeExists { - t.Fatalf("Multi() didn't return correct error: %+v", err) - } - if len(res) != 2 { - t.Fatalf("Expected 2 responses received %d", len(res)) - } - if res[0].Error != nil { - t.Fatalf("First operation returned an unexpected error %+v", res[0].Error) - } - if res[1].Error != ErrNodeExists { - t.Fatalf("Second operation returned incorrect error %+v", res[1].Error) - } - if _, _, err := zk.Get(firstPath); err != ErrNoNode { - t.Fatalf("Node %s was incorrectly created: %+v", firstPath, err) - } -} - -func TestGetSetACL(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - if err := zk.AddAuth("digest", []byte("blah")); err != nil { - t.Fatalf("AddAuth returned error %+v", err) - } - - path := "/gozk-test" - - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - if path, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if path != "/gozk-test" { - t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) - } - - expected := WorldACL(PermAll) - - if acl, stat, err := zk.GetACL(path); err != nil { - t.Fatalf("GetACL returned error %+v", err) - } else if stat == nil { - t.Fatalf("GetACL returned nil Stat") - } else if len(acl) != 1 || expected[0] != acl[0] { - t.Fatalf("GetACL mismatch expected %+v instead of %+v", expected, acl) - } - - expected = []ACL{{PermAll, "ip", "127.0.0.1"}} - - if stat, err := zk.SetACL(path, expected, -1); err != nil { - t.Fatalf("SetACL returned error %+v", err) - } else if stat == nil { - t.Fatalf("SetACL returned nil Stat") - } - - if acl, stat, err := zk.GetACL(path); err != nil { - t.Fatalf("GetACL returned error %+v", err) - } else if stat == nil { - t.Fatalf("GetACL returned nil Stat") - } else if len(acl) != 1 || expected[0] != acl[0] { - t.Fatalf("GetACL mismatch expected %+v instead of %+v", expected, acl) - } -} - -func TestAuth(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - path := "/gozk-digest-test" - if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - acl := DigestACL(PermAll, "user", "password") - - if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, acl); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if p != path { - t.Fatalf("Create returned different path '%s' != '%s'", p, path) - } - - if a, stat, err := zk.GetACL(path); err != nil { - t.Fatalf("GetACL returned error %+v", err) - } else if stat == nil { - t.Fatalf("GetACL returned nil Stat") - } else if len(a) != 1 || acl[0] != a[0] { - t.Fatalf("GetACL mismatch expected %+v instead of %+v", acl, a) - } - - if _, _, err := zk.Get(path); err != ErrNoAuth { - t.Fatalf("Get returned error %+v instead of ErrNoAuth", err) - } - - if err := zk.AddAuth("digest", []byte("user:password")); err != nil { - t.Fatalf("AddAuth returned error %+v", err) - } - - if data, stat, err := zk.Get(path); err != nil { - t.Fatalf("Get returned error %+v", err) - } else if stat == nil { - t.Fatalf("Get returned nil Stat") - } else if len(data) != 4 { - t.Fatalf("Get returned wrong data length") - } -} - -func TestChildren(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - deleteNode := func(node string) { - if err := zk.Delete(node, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - } - - deleteNode("/gozk-test-big") - - if path, err := zk.Create("/gozk-test-big", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if path != "/gozk-test-big" { - t.Fatalf("Create returned different path '%s' != '/gozk-test-big'", path) - } - - rb := make([]byte, 1000) - hb := make([]byte, 2000) - prefix := []byte("/gozk-test-big/") - for i := 0; i < 10000; i++ { - _, err := rand.Read(rb) - if err != nil { - t.Fatal("Cannot create random znode name") - } - hex.Encode(hb, rb) - - expect := string(append(prefix, hb...)) - if path, err := zk.Create(expect, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if path != expect { - t.Fatalf("Create returned different path '%s' != '%s'", path, expect) - } - defer deleteNode(string(expect)) - } - - children, _, err := zk.Children("/gozk-test-big") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } else if len(children) != 10000 { - t.Fatal("Children returned wrong number of nodes") - } -} - -func TestChildWatch(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - children, stat, childCh, err := zk.ChildrenW("/") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } else if stat == nil { - t.Fatal("Children returned nil stat") - } else if len(children) < 1 { - t.Fatal("Children should return at least 1 child") - } - - if path, err := zk.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if path != "/gozk-test" { - t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) - } - - select { - case ev := <-childCh: - if ev.Err != nil { - t.Fatalf("Child watcher error %+v", ev.Err) - } - if ev.Path != "/" { - t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") - } - case _ = <-time.After(time.Second * 2): - t.Fatal("Child watcher timed out") - } - - // Delete of the watched node should trigger the watch - - children, stat, childCh, err = zk.ChildrenW("/gozk-test") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } else if stat == nil { - t.Fatal("Children returned nil stat") - } else if len(children) != 0 { - t.Fatal("Children should return 0 children") - } - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - select { - case ev := <-childCh: - if ev.Err != nil { - t.Fatalf("Child watcher error %+v", ev.Err) - } - if ev.Path != "/gozk-test" { - t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") - } - case _ = <-time.After(time.Second * 2): - t.Fatal("Child watcher timed out") - } -} - -func TestSetWatchers(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - zk.reconnectLatch = make(chan struct{}) - zk.setWatchLimit = 1024 // break up set-watch step into 1k requests - var setWatchReqs atomic.Value - zk.setWatchCallback = func(reqs []*setWatchesRequest) { - setWatchReqs.Store(reqs) - } - - zk2, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk2.Close() - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - testPaths := map[string]<-chan Event{} - defer func() { - // clean up all of the test paths we create - for p := range testPaths { - zk2.Delete(p, -1) - } - }() - - // we create lots of paths to watch, to make sure a "set watches" request - // on re-create will be too big and be required to span multiple packets - for i := 0; i < 1000; i++ { - testPath, err := zk.Create(fmt.Sprintf("/gozk-test-%d", i), []byte{}, 0, WorldACL(PermAll)) - if err != nil { - t.Fatalf("Create returned: %+v", err) - } - testPaths[testPath] = nil - _, _, testEvCh, err := zk.GetW(testPath) - if err != nil { - t.Fatalf("GetW returned: %+v", err) - } - testPaths[testPath] = testEvCh - } - - children, stat, childCh, err := zk.ChildrenW("/") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } else if stat == nil { - t.Fatal("Children returned nil stat") - } else if len(children) < 1 { - t.Fatal("Children should return at least 1 child") - } - - // Simulate network error by brutally closing the network connection. - zk.conn.Close() - for p := range testPaths { - if err := zk2.Delete(p, -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - } - if path, err := zk2.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatalf("Create returned error: %+v", err) - } else if path != "/gozk-test" { - t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) - } - - time.Sleep(100 * time.Millisecond) - - // zk should still be waiting to reconnect, so none of the watches should have been triggered - for p, ch := range testPaths { - select { - case <-ch: - t.Fatalf("GetW watcher for %q should not have triggered yet", p) - default: - } - } - select { - case <-childCh: - t.Fatalf("ChildrenW watcher should not have triggered yet") - default: - } - - // now we let the reconnect occur and make sure it resets watches - close(zk.reconnectLatch) - - for p, ch := range testPaths { - select { - case ev := <-ch: - if ev.Err != nil { - t.Fatalf("GetW watcher error %+v", ev.Err) - } - if ev.Path != p { - t.Fatalf("GetW watcher wrong path %s instead of %s", ev.Path, p) - } - case <-time.After(2 * time.Second): - t.Fatal("GetW watcher timed out") - } - } - - select { - case ev := <-childCh: - if ev.Err != nil { - t.Fatalf("Child watcher error %+v", ev.Err) - } - if ev.Path != "/" { - t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") - } - case <-time.After(2 * time.Second): - t.Fatal("Child watcher timed out") - } - - // Yay! All watches fired correctly. Now we also inspect the actual set-watch request objects - // to ensure they didn't exceed the expected packet set. - buf := make([]byte, bufferSize) - totalWatches := 0 - actualReqs := setWatchReqs.Load().([]*setWatchesRequest) - if len(actualReqs) < 12 { - // sanity check: we should have generated *at least* 12 requests to reset watches - t.Fatalf("too few setWatchesRequest messages: %d", len(actualReqs)) - } - for _, r := range actualReqs { - totalWatches += len(r.ChildWatches) + len(r.DataWatches) + len(r.ExistWatches) - n, err := encodePacket(buf, r) - if err != nil { - t.Fatalf("encodePacket failed: %v! request:\n%+v", err, r) - } else if n > 1024 { - t.Fatalf("setWatchesRequest exceeded allowed size (%d > 1024)! request:\n%+v", n, r) - } - } - - if totalWatches != len(testPaths)+1 { - t.Fatalf("setWatchesRequests did not include all expected watches; expecting %d, got %d", len(testPaths)+1, totalWatches) - } -} - -func TestExpiringWatch(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - zk, _, err := ts.ConnectAll() - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - - if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { - t.Fatalf("Delete returned error: %+v", err) - } - - children, stat, childCh, err := zk.ChildrenW("/") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } else if stat == nil { - t.Fatal("Children returned nil stat") - } else if len(children) < 1 { - t.Fatal("Children should return at least 1 child") - } - - zk.sessionID = 99999 - zk.conn.Close() - - select { - case ev := <-childCh: - if ev.Err != ErrSessionExpired { - t.Fatalf("Child watcher error %+v instead of expected ErrSessionExpired", ev.Err) - } - if ev.Path != "/" { - t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") - } - case <-time.After(2 * time.Second): - t.Fatal("Child watcher timed out") - } -} - -func TestRequestFail(t *testing.T) { - // If connecting fails to all servers in the list then pending requests - // should be errored out so they don't hang forever. - - zk, _, err := Connect([]string{"127.0.0.1:32444"}, time.Second*15) - if err != nil { - t.Fatal(err) - } - defer zk.Close() - - ch := make(chan error) - go func() { - _, _, err := zk.Get("/blah") - ch <- err - }() - select { - case err := <-ch: - if err == nil { - t.Fatal("Expected non-nil error on failed request due to connection failure") - } - case <-time.After(time.Second * 2): - t.Fatal("Get hung when connection could not be made") - } -} - -func TestSlowServer(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - - realAddr := fmt.Sprintf("127.0.0.1:%d", ts.Servers[0].Port) - proxyAddr, stopCh, err := startSlowProxy(t, - Rate{}, Rate{}, - realAddr, func(ln *Listener) { - if ln.Up.Latency == 0 { - ln.Up.Latency = time.Millisecond * 2000 - ln.Down.Latency = time.Millisecond * 2000 - } else { - ln.Up.Latency = 0 - ln.Down.Latency = 0 - } - }) - if err != nil { - t.Fatal(err) - } - defer close(stopCh) - - zk, _, err := Connect([]string{proxyAddr}, time.Millisecond*500) - if err != nil { - t.Fatal(err) - } - defer zk.Close() - - _, _, wch, err := zk.ChildrenW("/") - if err != nil { - t.Fatal(err) - } - - // Force a reconnect to get a throttled connection - zk.conn.Close() - - time.Sleep(time.Millisecond * 100) - - if err := zk.Delete("/gozk-test", -1); err == nil { - t.Fatal("Delete should have failed") - } - - // The previous request should have timed out causing the server to be disconnected and reconnected - - if _, err := zk.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { - t.Fatal(err) - } - - // Make sure event is still returned because the session should not have been affected - select { - case ev := <-wch: - t.Logf("Received event: %+v", ev) - case <-time.After(time.Second): - t.Fatal("Expected to receive a watch event") - } -} - -func startSlowProxy(t *testing.T, up, down Rate, upstream string, adj func(ln *Listener)) (string, chan bool, error) { - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - return "", nil, err - } - tln := &Listener{ - Listener: ln, - Up: up, - Down: down, - } - stopCh := make(chan bool) - go func() { - <-stopCh - tln.Close() - }() - go func() { - for { - cn, err := tln.Accept() - if err != nil { - if !strings.Contains(err.Error(), "use of closed network connection") { - t.Fatalf("Accept failed: %s", err.Error()) - } - return - } - if adj != nil { - adj(tln) - } - go func(cn net.Conn) { - defer cn.Close() - upcn, err := net.Dial("tcp", upstream) - if err != nil { - t.Log(err) - return - } - // This will leave hanging goroutines util stopCh is closed - // but it doesn't matter in the context of running tests. - go func() { - <-stopCh - upcn.Close() - }() - go func() { - if _, err := io.Copy(upcn, cn); err != nil { - if !strings.Contains(err.Error(), "use of closed network connection") { - // log.Printf("Upstream write failed: %s", err.Error()) - } - } - }() - if _, err := io.Copy(cn, upcn); err != nil { - if !strings.Contains(err.Error(), "use of closed network connection") { - // log.Printf("Upstream read failed: %s", err.Error()) - } - } - }(cn) - } - }() - return ln.Addr().String(), stopCh, nil -} - -func TestMaxBufferSize(t *testing.T) { - ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) - if err != nil { - t.Fatal(err) - } - defer ts.Stop() - // no buffer size - zk, _, err := ts.ConnectWithOptions(15 * time.Second) - var l testLogger - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zk.Close() - // 1k buffer size, logs to custom test logger - zkLimited, _, err := ts.ConnectWithOptions(15*time.Second, WithMaxBufferSize(1024), func(conn *Conn) { - conn.SetLogger(&l) - }) - if err != nil { - t.Fatalf("Connect returned error: %+v", err) - } - defer zkLimited.Close() - - // With small node with small number of children - data := []byte{101, 102, 103, 103} - _, err = zk.Create("/foo", data, 0, WorldACL(PermAll)) - if err != nil { - t.Fatalf("Create returned error: %+v", err) - } - var children []string - for i := 0; i < 4; i++ { - childName, err := zk.Create("/foo/child", nil, FlagEphemeral|FlagSequence, WorldACL(PermAll)) - if err != nil { - t.Fatalf("Create returned error: %+v", err) - } - children = append(children, childName[len("/foo/"):]) // strip parent prefix from name - } - sort.Strings(children) - - // Limited client works fine - resultData, _, err := zkLimited.Get("/foo") - if err != nil { - t.Fatalf("Get returned error: %+v", err) - } - if !reflect.DeepEqual(resultData, data) { - t.Fatalf("Get returned unexpected data; expecting %+v, got %+v", data, resultData) - } - resultChildren, _, err := zkLimited.Children("/foo") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } - sort.Strings(resultChildren) - if !reflect.DeepEqual(resultChildren, children) { - t.Fatalf("Children returned unexpected names; expecting %+v, got %+v", children, resultChildren) - } - - // With large node though... - data = make([]byte, 1024) - for i := 0; i < 1024; i++ { - data[i] = byte(i) - } - _, err = zk.Create("/bar", data, 0, WorldACL(PermAll)) - if err != nil { - t.Fatalf("Create returned error: %+v", err) - } - _, _, err = zkLimited.Get("/bar") - // NB: Sadly, without actually de-serializing the too-large response packet, we can't send the - // right error to the corresponding outstanding request. So the request just sees ErrConnectionClosed - // while the log will see the actual reason the connection was closed. - expectErr(t, err, ErrConnectionClosed) - expectLogMessage(t, &l, "received packet from server with length .*, which exceeds max buffer size 1024") - - // Or with large number of children... - totalLen := 0 - children = nil - for totalLen < 1024 { - childName, err := zk.Create("/bar/child", nil, FlagEphemeral|FlagSequence, WorldACL(PermAll)) - if err != nil { - t.Fatalf("Create returned error: %+v", err) - } - n := childName[len("/bar/"):] // strip parent prefix from name - children = append(children, n) - totalLen += len(n) - } - sort.Strings(children) - _, _, err = zkLimited.Children("/bar") - expectErr(t, err, ErrConnectionClosed) - expectLogMessage(t, &l, "received packet from server with length .*, which exceeds max buffer size 1024") - - // Other client (without buffer size limit) can successfully query the node and its children, of course - resultData, _, err = zk.Get("/bar") - if err != nil { - t.Fatalf("Get returned error: %+v", err) - } - if !reflect.DeepEqual(resultData, data) { - t.Fatalf("Get returned unexpected data; expecting %+v, got %+v", data, resultData) - } - resultChildren, _, err = zk.Children("/bar") - if err != nil { - t.Fatalf("Children returned error: %+v", err) - } - sort.Strings(resultChildren) - if !reflect.DeepEqual(resultChildren, children) { - t.Fatalf("Children returned unexpected names; expecting %+v, got %+v", children, resultChildren) - } -} - -func expectErr(t *testing.T, err error, expected error) { - if err == nil { - t.Fatalf("Get for node that is too large should have returned error!") - } - if err != expected { - t.Fatalf("Get returned wrong error; expecting ErrClosing, got %+v", err) - } -} - -func expectLogMessage(t *testing.T, logger *testLogger, pattern string) { - re := regexp.MustCompile(pattern) - events := logger.Reset() - if len(events) == 0 { - t.Fatalf("Failed to log error; expecting message that matches pattern: %s", pattern) - } - var found []string - for _, e := range events { - if re.Match([]byte(e)) { - found = append(found, e) - } - } - if len(found) == 0 { - t.Fatalf("Failed to log error; expecting message that matches pattern: %s", pattern) - } else if len(found) > 1 { - t.Fatalf("Logged error redundantly %d times:\n%+v", len(found), found) - } -} - -type testLogger struct { - mu sync.Mutex - events []string -} - -func (l *testLogger) Printf(msgFormat string, args ...interface{}) { - msg := fmt.Sprintf(msgFormat, args...) - fmt.Println(msg) - l.mu.Lock() - defer l.mu.Unlock() - l.events = append(l.events, msg) -} - -func (l *testLogger) Reset() []string { - l.mu.Lock() - defer l.mu.Unlock() - ret := l.events - l.events = nil - return ret -} diff --git a/vendor/github.com/stretchr/testify/.gitignore b/vendor/github.com/stretchr/testify/.gitignore deleted file mode 100644 index 5aacdb7..0000000 --- a/vendor/github.com/stretchr/testify/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe - -.DS_Store diff --git a/vendor/github.com/stretchr/testify/.travis.gofmt.sh b/vendor/github.com/stretchr/testify/.travis.gofmt.sh deleted file mode 100755 index bfffdca..0000000 --- a/vendor/github.com/stretchr/testify/.travis.gofmt.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -if [ -n "$(gofmt -l .)" ]; then - echo "Go code is not formatted:" - gofmt -d . - exit 1 -fi diff --git a/vendor/github.com/stretchr/testify/.travis.gogenerate.sh b/vendor/github.com/stretchr/testify/.travis.gogenerate.sh deleted file mode 100755 index 161b449..0000000 --- a/vendor/github.com/stretchr/testify/.travis.gogenerate.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -if [[ "$TRAVIS_GO_VERSION" =~ ^1\.[45](\..*)?$ ]]; then - exit 0 -fi - -go get github.com/ernesto-jimenez/gogen/imports -go generate ./... -if [ -n "$(git diff)" ]; then - echo "Go generate had not been run" - git diff - exit 1 -fi diff --git a/vendor/github.com/stretchr/testify/.travis.govet.sh b/vendor/github.com/stretchr/testify/.travis.govet.sh deleted file mode 100755 index f8fbba7..0000000 --- a/vendor/github.com/stretchr/testify/.travis.govet.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -cd "$(dirname $0)" -DIRS=". assert require mock _codegen" -set -e -for subdir in $DIRS; do - pushd $subdir - go vet - popd -done diff --git a/vendor/github.com/stretchr/testify/.travis.yml b/vendor/github.com/stretchr/testify/.travis.yml deleted file mode 100644 index f408b4c..0000000 --- a/vendor/github.com/stretchr/testify/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: go - -sudo: false - -go: - - "1.8" - - "1.9" - - "1.10" - - tip - -script: - - ./.travis.gogenerate.sh - - ./.travis.gofmt.sh - - ./.travis.govet.sh - - go test -v -race $(go list ./... | grep -v vendor) diff --git a/vendor/github.com/stretchr/testify/Gopkg.lock b/vendor/github.com/stretchr/testify/Gopkg.lock deleted file mode 100644 index 294cda0..0000000 --- a/vendor/github.com/stretchr/testify/Gopkg.lock +++ /dev/null @@ -1,27 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - name = "github.com/stretchr/objx" - packages = ["."] - revision = "facf9a85c22f48d2f52f2380e4efce1768749a89" - version = "v0.1" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "448ddae4702c6aded2555faafd390c537789bb1c483f70b0431e6634f73f2090" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/github.com/stretchr/testify/Gopkg.toml b/vendor/github.com/stretchr/testify/Gopkg.toml deleted file mode 100644 index a16374c..0000000 --- a/vendor/github.com/stretchr/testify/Gopkg.toml +++ /dev/null @@ -1,16 +0,0 @@ -[prune] - unused-packages = true - non-go = true - go-tests = true - -[[constraint]] - name = "github.com/davecgh/go-spew" - version = "~1.1.0" - -[[constraint]] - name = "github.com/pmezard/go-difflib" - version = "~1.0.0" - -[[constraint]] - name = "github.com/stretchr/objx" - version = "~0.1.0" diff --git a/vendor/github.com/stretchr/testify/LICENSE b/vendor/github.com/stretchr/testify/LICENSE deleted file mode 100644 index 473b670..0000000 --- a/vendor/github.com/stretchr/testify/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell - -Please consider promoting this project if you find it useful. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, -and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT -OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/stretchr/testify/README.md b/vendor/github.com/stretchr/testify/README.md deleted file mode 100644 index 51b6df3..0000000 --- a/vendor/github.com/stretchr/testify/README.md +++ /dev/null @@ -1,331 +0,0 @@ -Testify - Thou Shalt Write Tests -================================ - -[![Build Status](https://travis-ci.org/stretchr/testify.svg)](https://travis-ci.org/stretchr/testify) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/testify)](https://goreportcard.com/report/github.com/stretchr/testify) [![GoDoc](https://godoc.org/github.com/stretchr/testify?status.svg)](https://godoc.org/github.com/stretchr/testify) - -Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend. - -Features include: - - * [Easy assertions](#assert-package) - * [Mocking](#mock-package) - * [Testing suite interfaces and functions](#suite-package) - -Get started: - - * Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date) - * For an introduction to writing test code in Go, see http://golang.org/doc/code.html#Testing - * Check out the API Documentation http://godoc.org/github.com/stretchr/testify - * To make your testing life easier, check out our other project, [gorc](http://github.com/stretchr/gorc) - * A little about [Test-Driven Development (TDD)](http://en.wikipedia.org/wiki/Test-driven_development) - - - -[`assert`](http://godoc.org/github.com/stretchr/testify/assert "API documentation") package -------------------------------------------------------------------------------------------- - -The `assert` package provides some helpful methods that allow you to write better test code in Go. - - * Prints friendly, easy to read failure descriptions - * Allows for very readable code - * Optionally annotate each assertion with a message - -See it in action: - -```go -package yours - -import ( - "testing" - "github.com/stretchr/testify/assert" -) - -func TestSomething(t *testing.T) { - - // assert equality - assert.Equal(t, 123, 123, "they should be equal") - - // assert inequality - assert.NotEqual(t, 123, 456, "they should not be equal") - - // assert for nil (good for errors) - assert.Nil(t, object) - - // assert for not nil (good when you expect something) - if assert.NotNil(t, object) { - - // now we know that object isn't nil, we are safe to make - // further assertions without causing any errors - assert.Equal(t, "Something", object.Value) - - } - -} -``` - - * Every assert func takes the `testing.T` object as the first argument. This is how it writes the errors out through the normal `go test` capabilities. - * Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions. - -if you assert many times, use the below: - -```go -package yours - -import ( - "testing" - "github.com/stretchr/testify/assert" -) - -func TestSomething(t *testing.T) { - assert := assert.New(t) - - // assert equality - assert.Equal(123, 123, "they should be equal") - - // assert inequality - assert.NotEqual(123, 456, "they should not be equal") - - // assert for nil (good for errors) - assert.Nil(object) - - // assert for not nil (good when you expect something) - if assert.NotNil(object) { - - // now we know that object isn't nil, we are safe to make - // further assertions without causing any errors - assert.Equal("Something", object.Value) - } -} -``` - -[`require`](http://godoc.org/github.com/stretchr/testify/require "API documentation") package ---------------------------------------------------------------------------------------------- - -The `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test. - -See [t.FailNow](http://golang.org/pkg/testing/#T.FailNow) for details. - -[`mock`](http://godoc.org/github.com/stretchr/testify/mock "API documentation") package ----------------------------------------------------------------------------------------- - -The `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code. - -An example test function that tests a piece of code that relies on an external object `testObj`, can setup expectations (testify) and assert that they indeed happened: - -```go -package yours - -import ( - "testing" - "github.com/stretchr/testify/mock" -) - -/* - Test objects -*/ - -// MyMockedObject is a mocked object that implements an interface -// that describes an object that the code I am testing relies on. -type MyMockedObject struct{ - mock.Mock -} - -// DoSomething is a method on MyMockedObject that implements some interface -// and just records the activity, and returns what the Mock object tells it to. -// -// In the real object, this method would do something useful, but since this -// is a mocked object - we're just going to stub it out. -// -// NOTE: This method is not being tested here, code that uses this object is. -func (m *MyMockedObject) DoSomething(number int) (bool, error) { - - args := m.Called(number) - return args.Bool(0), args.Error(1) - -} - -/* - Actual test functions -*/ - -// TestSomething is an example of how to use our test object to -// make assertions about some target code we are testing. -func TestSomething(t *testing.T) { - - // create an instance of our test object - testObj := new(MyMockedObject) - - // setup expectations - testObj.On("DoSomething", 123).Return(true, nil) - - // call the code we are testing - targetFuncThatDoesSomethingWithObj(testObj) - - // assert that the expectations were met - testObj.AssertExpectations(t) - - -} - -// TestSomethingElse is a second example of how to use our test object to -// make assertions about some target code we are testing. -// This time using a placeholder. Placeholders might be used when the -// data being passed in is normally dynamically generated and cannot be -// predicted beforehand (eg. containing hashes that are time sensitive) -func TestSomethingElse(t *testing.T) { - - // create an instance of our test object - testObj := new(MyMockedObject) - - // setup expectations with a placeholder in the argument list - testObj.On("DoSomething", mock.Anything).Return(true, nil) - - // call the code we are testing - targetFuncThatDoesSomethingWithObj(testObj) - - // assert that the expectations were met - testObj.AssertExpectations(t) - - -} -``` - -For more information on how to write mock code, check out the [API documentation for the `mock` package](http://godoc.org/github.com/stretchr/testify/mock). - -You can use the [mockery tool](http://github.com/vektra/mockery) to autogenerate the mock code against an interface as well, making using mocks much quicker. - -[`suite`](http://godoc.org/github.com/stretchr/testify/suite "API documentation") package ------------------------------------------------------------------------------------------ - -The `suite` package provides functionality that you might be used to from more common object oriented languages. With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal. - -An example suite is shown below: - -```go -// Basic imports -import ( - "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" -) - -// Define the suite, and absorb the built-in basic suite -// functionality from testify - including a T() method which -// returns the current testing context -type ExampleTestSuite struct { - suite.Suite - VariableThatShouldStartAtFive int -} - -// Make sure that VariableThatShouldStartAtFive is set to five -// before each test -func (suite *ExampleTestSuite) SetupTest() { - suite.VariableThatShouldStartAtFive = 5 -} - -// All methods that begin with "Test" are run as tests within a -// suite. -func (suite *ExampleTestSuite) TestExample() { - assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestExampleTestSuite(t *testing.T) { - suite.Run(t, new(ExampleTestSuite)) -} -``` - -For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go) - -For more information on writing suites, check out the [API documentation for the `suite` package](http://godoc.org/github.com/stretchr/testify/suite). - -`Suite` object has assertion methods: - -```go -// Basic imports -import ( - "testing" - "github.com/stretchr/testify/suite" -) - -// Define the suite, and absorb the built-in basic suite -// functionality from testify - including assertion methods. -type ExampleTestSuite struct { - suite.Suite - VariableThatShouldStartAtFive int -} - -// Make sure that VariableThatShouldStartAtFive is set to five -// before each test -func (suite *ExampleTestSuite) SetupTest() { - suite.VariableThatShouldStartAtFive = 5 -} - -// All methods that begin with "Test" are run as tests within a -// suite. -func (suite *ExampleTestSuite) TestExample() { - suite.Equal(suite.VariableThatShouldStartAtFive, 5) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestExampleTestSuite(t *testing.T) { - suite.Run(t, new(ExampleTestSuite)) -} -``` - ------- - -Installation -============ - -To install Testify, use `go get`: - - go get github.com/stretchr/testify - -This will then make the following packages available to you: - - github.com/stretchr/testify/assert - github.com/stretchr/testify/mock - github.com/stretchr/testify/http - -Import the `testify/assert` package into your code using this template: - -```go -package yours - -import ( - "testing" - "github.com/stretchr/testify/assert" -) - -func TestSomething(t *testing.T) { - - assert.True(t, true, "True is true!") - -} -``` - ------- - -Staying up to date -================== - -To update Testify to the latest version, use `go get -u github.com/stretchr/testify`. - ------- - -Supported go versions -================== - -We support the three major Go versions, which are 1.8, 1.9 and 1.10 at the moment. - ------- - -Contributing -============ - -Please feel free to submit issues, fork the repository and send pull requests! - -When submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it. diff --git a/vendor/github.com/stretchr/testify/_codegen/main.go b/vendor/github.com/stretchr/testify/_codegen/main.go deleted file mode 100644 index 2e5e812..0000000 --- a/vendor/github.com/stretchr/testify/_codegen/main.go +++ /dev/null @@ -1,316 +0,0 @@ -// This program reads all assertion functions from the assert package and -// automatically generates the corresponding requires and forwarded assertions - -package main - -import ( - "bytes" - "flag" - "fmt" - "go/ast" - "go/build" - "go/doc" - "go/format" - "go/importer" - "go/parser" - "go/token" - "go/types" - "io" - "io/ioutil" - "log" - "os" - "path" - "regexp" - "strings" - "text/template" - - "github.com/ernesto-jimenez/gogen/imports" -) - -var ( - pkg = flag.String("assert-path", "github.com/stretchr/testify/assert", "Path to the assert package") - includeF = flag.Bool("include-format-funcs", false, "include format functions such as Errorf and Equalf") - outputPkg = flag.String("output-package", "", "package for the resulting code") - tmplFile = flag.String("template", "", "What file to load the function template from") - out = flag.String("out", "", "What file to write the source code to") -) - -func main() { - flag.Parse() - - scope, docs, err := parsePackageSource(*pkg) - if err != nil { - log.Fatal(err) - } - - importer, funcs, err := analyzeCode(scope, docs) - if err != nil { - log.Fatal(err) - } - - if err := generateCode(importer, funcs); err != nil { - log.Fatal(err) - } -} - -func generateCode(importer imports.Importer, funcs []testFunc) error { - buff := bytes.NewBuffer(nil) - - tmplHead, tmplFunc, err := parseTemplates() - if err != nil { - return err - } - - // Generate header - if err := tmplHead.Execute(buff, struct { - Name string - Imports map[string]string - }{ - *outputPkg, - importer.Imports(), - }); err != nil { - return err - } - - // Generate funcs - for _, fn := range funcs { - buff.Write([]byte("\n\n")) - if err := tmplFunc.Execute(buff, &fn); err != nil { - return err - } - } - - code, err := format.Source(buff.Bytes()) - if err != nil { - return err - } - - // Write file - output, err := outputFile() - if err != nil { - return err - } - defer output.Close() - _, err = io.Copy(output, bytes.NewReader(code)) - return err -} - -func parseTemplates() (*template.Template, *template.Template, error) { - tmplHead, err := template.New("header").Parse(headerTemplate) - if err != nil { - return nil, nil, err - } - if *tmplFile != "" { - f, err := ioutil.ReadFile(*tmplFile) - if err != nil { - return nil, nil, err - } - funcTemplate = string(f) - } - tmpl, err := template.New("function").Parse(funcTemplate) - if err != nil { - return nil, nil, err - } - return tmplHead, tmpl, nil -} - -func outputFile() (*os.File, error) { - filename := *out - if filename == "-" || (filename == "" && *tmplFile == "") { - return os.Stdout, nil - } - if filename == "" { - filename = strings.TrimSuffix(strings.TrimSuffix(*tmplFile, ".tmpl"), ".go") + ".go" - } - return os.Create(filename) -} - -// analyzeCode takes the types scope and the docs and returns the import -// information and information about all the assertion functions. -func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []testFunc, error) { - testingT := scope.Lookup("TestingT").Type().Underlying().(*types.Interface) - - importer := imports.New(*outputPkg) - var funcs []testFunc - // Go through all the top level functions - for _, fdocs := range docs.Funcs { - // Find the function - obj := scope.Lookup(fdocs.Name) - - fn, ok := obj.(*types.Func) - if !ok { - continue - } - // Check function signature has at least two arguments - sig := fn.Type().(*types.Signature) - if sig.Params().Len() < 2 { - continue - } - // Check first argument is of type testingT - first, ok := sig.Params().At(0).Type().(*types.Named) - if !ok { - continue - } - firstType, ok := first.Underlying().(*types.Interface) - if !ok { - continue - } - if !types.Implements(firstType, testingT) { - continue - } - - // Skip functions ending with f - if strings.HasSuffix(fdocs.Name, "f") && !*includeF { - continue - } - - funcs = append(funcs, testFunc{*outputPkg, fdocs, fn}) - importer.AddImportsFrom(sig.Params()) - } - return importer, funcs, nil -} - -// parsePackageSource returns the types scope and the package documentation from the package -func parsePackageSource(pkg string) (*types.Scope, *doc.Package, error) { - pd, err := build.Import(pkg, ".", 0) - if err != nil { - return nil, nil, err - } - - fset := token.NewFileSet() - files := make(map[string]*ast.File) - fileList := make([]*ast.File, len(pd.GoFiles)) - for i, fname := range pd.GoFiles { - src, err := ioutil.ReadFile(path.Join(pd.SrcRoot, pd.ImportPath, fname)) - if err != nil { - return nil, nil, err - } - f, err := parser.ParseFile(fset, fname, src, parser.ParseComments|parser.AllErrors) - if err != nil { - return nil, nil, err - } - files[fname] = f - fileList[i] = f - } - - cfg := types.Config{ - Importer: importer.Default(), - } - info := types.Info{ - Defs: make(map[*ast.Ident]types.Object), - } - tp, err := cfg.Check(pkg, fset, fileList, &info) - if err != nil { - return nil, nil, err - } - - scope := tp.Scope() - - ap, _ := ast.NewPackage(fset, files, nil, nil) - docs := doc.New(ap, pkg, 0) - - return scope, docs, nil -} - -type testFunc struct { - CurrentPkg string - DocInfo *doc.Func - TypeInfo *types.Func -} - -func (f *testFunc) Qualifier(p *types.Package) string { - if p == nil || p.Name() == f.CurrentPkg { - return "" - } - return p.Name() -} - -func (f *testFunc) Params() string { - sig := f.TypeInfo.Type().(*types.Signature) - params := sig.Params() - p := "" - comma := "" - to := params.Len() - var i int - - if sig.Variadic() { - to-- - } - for i = 1; i < to; i++ { - param := params.At(i) - p += fmt.Sprintf("%s%s %s", comma, param.Name(), types.TypeString(param.Type(), f.Qualifier)) - comma = ", " - } - if sig.Variadic() { - param := params.At(params.Len() - 1) - p += fmt.Sprintf("%s%s ...%s", comma, param.Name(), types.TypeString(param.Type().(*types.Slice).Elem(), f.Qualifier)) - } - return p -} - -func (f *testFunc) ForwardedParams() string { - sig := f.TypeInfo.Type().(*types.Signature) - params := sig.Params() - p := "" - comma := "" - to := params.Len() - var i int - - if sig.Variadic() { - to-- - } - for i = 1; i < to; i++ { - param := params.At(i) - p += fmt.Sprintf("%s%s", comma, param.Name()) - comma = ", " - } - if sig.Variadic() { - param := params.At(params.Len() - 1) - p += fmt.Sprintf("%s%s...", comma, param.Name()) - } - return p -} - -func (f *testFunc) ParamsFormat() string { - return strings.Replace(f.Params(), "msgAndArgs", "msg string, args", 1) -} - -func (f *testFunc) ForwardedParamsFormat() string { - return strings.Replace(f.ForwardedParams(), "msgAndArgs", "append([]interface{}{msg}, args...)", 1) -} - -func (f *testFunc) Comment() string { - return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1) -} - -func (f *testFunc) CommentFormat() string { - search := fmt.Sprintf("%s", f.DocInfo.Name) - replace := fmt.Sprintf("%sf", f.DocInfo.Name) - comment := strings.Replace(f.Comment(), search, replace, -1) - exp := regexp.MustCompile(replace + `\(((\(\)|[^)])+)\)`) - return exp.ReplaceAllString(comment, replace+`($1, "error message %s", "formatted")`) -} - -func (f *testFunc) CommentWithoutT(receiver string) string { - search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name) - replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name) - return strings.Replace(f.Comment(), search, replace, -1) -} - -var headerTemplate = `/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND -*/ - -package {{.Name}} - -import ( -{{range $path, $name := .Imports}} - {{$name}} "{{$path}}"{{end}} -) -` - -var funcTemplate = `{{.Comment}} -func (fwd *AssertionsForwarder) {{.DocInfo.Name}}({{.Params}}) bool { - return assert.{{.DocInfo.Name}}({{.ForwardedParams}}) -}` diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go deleted file mode 100644 index aa1c2b9..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ /dev/null @@ -1,484 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package assert - -import ( - http "net/http" - url "net/url" - time "time" -) - -// Conditionf uses a Comparison to assert a complex condition. -func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Condition(t, comp, append([]interface{}{msg}, args...)...) -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") -// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") -// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") -func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Contains(t, s, contains, append([]interface{}{msg}, args...)...) -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return DirExists(t, path, append([]interface{}{msg}, args...)...) -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...) -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Emptyf(t, obj, "error message %s", "formatted") -func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Empty(t, object, append([]interface{}{msg}, args...)...) -} - -// Equalf asserts that two objects are equal. -// -// assert.Equalf(t, 123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Equal(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") -func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...) -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) -func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Error(t, err, append([]interface{}{msg}, args...)...) -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) -func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Failf reports a failure through -func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Fail(t, failureMessage, append([]interface{}{msg}, args...)...) -} - -// FailNowf fails test -func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...) -} - -// Falsef asserts that the specified value is false. -// -// assert.Falsef(t, myBool, "error message %s", "formatted") -func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return False(t, value, append([]interface{}{msg}, args...)...) -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return FileExists(t, path, append([]interface{}{msg}, args...)...) -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...) -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...) -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) -} - -// IsTypef asserts that the specified objects are of the same type. -func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...) -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") -func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Len(t, object, length, append([]interface{}{msg}, args...)...) -} - -// Nilf asserts that the specified object is nil. -// -// assert.Nilf(t, err, "error message %s", "formatted") -func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Nil(t, object, append([]interface{}{msg}, args...)...) -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoErrorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NoError(t, err, append([]interface{}{msg}, args...)...) -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") -func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotEmpty(t, object, append([]interface{}{msg}, args...)...) -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...) -} - -// NotNilf asserts that the specified object is not nil. -// -// assert.NotNilf(t, err, "error message %s", "formatted") -func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotNil(t, object, append([]interface{}{msg}, args...)...) -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") -func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotPanics(t, f, append([]interface{}{msg}, args...)...) -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") -func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...) -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...) -} - -// NotZerof asserts that i is not the zero value for its type. -func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return NotZero(t, i, append([]interface{}{msg}, args...)...) -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") -func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Panics(t, f, append([]interface{}{msg}, args...)...) -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...) -} - -// Regexpf asserts that a specified regexp matches a string. -// -// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") -func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Regexp(t, rx, str, append([]interface{}{msg}, args...)...) -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Subset(t, list, subset, append([]interface{}{msg}, args...)...) -} - -// Truef asserts that the specified value is true. -// -// assert.Truef(t, myBool, "error message %s", "formatted") -func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return True(t, value, append([]interface{}{msg}, args...)...) -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) -} - -// Zerof asserts that i is the zero value for its type. -func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - return Zero(t, i, append([]interface{}{msg}, args...)...) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl deleted file mode 100644 index d2bb0b8..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{.CommentFormat}} -func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { - if h, ok := t.(tHelper); ok { h.Helper() } - return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go deleted file mode 100644 index de39f79..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ /dev/null @@ -1,956 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package assert - -import ( - http "net/http" - url "net/url" - time "time" -) - -// Condition uses a Comparison to assert a complex condition. -func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Condition(a.t, comp, msgAndArgs...) -} - -// Conditionf uses a Comparison to assert a complex condition. -func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Conditionf(a.t, comp, msg, args...) -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Contains("Hello World", "World") -// a.Contains(["Hello", "World"], "World") -// a.Contains({"Hello": "World"}, "Hello") -func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Contains(a.t, s, contains, msgAndArgs...) -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Containsf("Hello World", "World", "error message %s", "formatted") -// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") -// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") -func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Containsf(a.t, s, contains, msg, args...) -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return DirExists(a.t, path, msgAndArgs...) -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return DirExistsf(a.t, path, msg, args...) -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) -func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return ElementsMatch(a.t, listA, listB, msgAndArgs...) -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return ElementsMatchf(a.t, listA, listB, msg, args...) -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Empty(obj) -func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Empty(a.t, object, msgAndArgs...) -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Emptyf(obj, "error message %s", "formatted") -func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Emptyf(a.t, object, msg, args...) -} - -// Equal asserts that two objects are equal. -// -// a.Equal(123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Equal(a.t, expected, actual, msgAndArgs...) -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualError(err, expectedErrorString) -func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualError(a.t, theError, errString, msgAndArgs...) -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") -func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualErrorf(a.t, theError, errString, msg, args...) -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValues(uint32(123), int32(123)) -func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualValues(a.t, expected, actual, msgAndArgs...) -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123)) -func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return EqualValuesf(a.t, expected, actual, msg, args...) -} - -// Equalf asserts that two objects are equal. -// -// a.Equalf(123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Equalf(a.t, expected, actual, msg, args...) -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } -func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Error(a.t, err, msgAndArgs...) -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Errorf(a.t, err, msg, args...) -} - -// Exactly asserts that two objects are equal in value and type. -// -// a.Exactly(int32(123), int64(123)) -func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Exactly(a.t, expected, actual, msgAndArgs...) -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) -func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Exactlyf(a.t, expected, actual, msg, args...) -} - -// Fail reports a failure through -func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Fail(a.t, failureMessage, msgAndArgs...) -} - -// FailNow fails test -func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FailNow(a.t, failureMessage, msgAndArgs...) -} - -// FailNowf fails test -func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FailNowf(a.t, failureMessage, msg, args...) -} - -// Failf reports a failure through -func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Failf(a.t, failureMessage, msg, args...) -} - -// False asserts that the specified value is false. -// -// a.False(myBool) -func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return False(a.t, value, msgAndArgs...) -} - -// Falsef asserts that the specified value is false. -// -// a.Falsef(myBool, "error message %s", "formatted") -func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Falsef(a.t, value, msg, args...) -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FileExists(a.t, path, msgAndArgs...) -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return FileExistsf(a.t, path, msg, args...) -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPError(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPErrorf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPRedirectf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return HTTPSuccessf(a.t, handler, method, url, values, msg, args...) -} - -// Implements asserts that an object is implemented by the specified interface. -// -// a.Implements((*MyInterface)(nil), new(MyObject)) -func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Implements(a.t, interfaceObject, object, msgAndArgs...) -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Implementsf(a.t, interfaceObject, object, msg, args...) -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// a.InDelta(math.Pi, (22 / 7.0), 0.01) -func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDelta(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaSlicef(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InDeltaf(a.t, expected, actual, delta, msg, args...) -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...) -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return InEpsilonf(a.t, expected, actual, epsilon, msg, args...) -} - -// IsType asserts that the specified objects are of the same type. -func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return IsType(a.t, expectedType, object, msgAndArgs...) -} - -// IsTypef asserts that the specified objects are of the same type. -func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return IsTypef(a.t, expectedType, object, msg, args...) -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return JSONEq(a.t, expected, actual, msgAndArgs...) -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return JSONEqf(a.t, expected, actual, msg, args...) -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// a.Len(mySlice, 3) -func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Len(a.t, object, length, msgAndArgs...) -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// a.Lenf(mySlice, 3, "error message %s", "formatted") -func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Lenf(a.t, object, length, msg, args...) -} - -// Nil asserts that the specified object is nil. -// -// a.Nil(err) -func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Nil(a.t, object, msgAndArgs...) -} - -// Nilf asserts that the specified object is nil. -// -// a.Nilf(err, "error message %s", "formatted") -func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Nilf(a.t, object, msg, args...) -} - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NoError(a.t, err, msgAndArgs...) -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NoErrorf(a.t, err, msg, args...) -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContains("Hello World", "Earth") -// a.NotContains(["Hello", "World"], "Earth") -// a.NotContains({"Hello": "World"}, "Earth") -func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotContains(a.t, s, contains, msgAndArgs...) -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") -// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") -// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") -func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotContainsf(a.t, s, contains, msg, args...) -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEmpty(a.t, object, msgAndArgs...) -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEmptyf(a.t, object, msg, args...) -} - -// NotEqual asserts that the specified values are NOT equal. -// -// a.NotEqual(obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEqual(a.t, expected, actual, msgAndArgs...) -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// a.NotEqualf(obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotEqualf(a.t, expected, actual, msg, args...) -} - -// NotNil asserts that the specified object is not nil. -// -// a.NotNil(err) -func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotNil(a.t, object, msgAndArgs...) -} - -// NotNilf asserts that the specified object is not nil. -// -// a.NotNilf(err, "error message %s", "formatted") -func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotNilf(a.t, object, msg, args...) -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanics(func(){ RemainCalm() }) -func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotPanics(a.t, f, msgAndArgs...) -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") -func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotPanicsf(a.t, f, msg, args...) -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") -// a.NotRegexp("^start", "it's not starting") -func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotRegexp(a.t, rx, str, msgAndArgs...) -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") -func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotRegexpf(a.t, rx, str, msg, args...) -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotSubset(a.t, list, subset, msgAndArgs...) -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotSubsetf(a.t, list, subset, msg, args...) -} - -// NotZero asserts that i is not the zero value for its type. -func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotZero(a.t, i, msgAndArgs...) -} - -// NotZerof asserts that i is not the zero value for its type. -func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return NotZerof(a.t, i, msg, args...) -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panics(func(){ GoCrazy() }) -func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Panics(a.t, f, msgAndArgs...) -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) -func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return PanicsWithValue(a.t, expected, f, msgAndArgs...) -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return PanicsWithValuef(a.t, expected, f, msg, args...) -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Panicsf(a.t, f, msg, args...) -} - -// Regexp asserts that a specified regexp matches a string. -// -// a.Regexp(regexp.MustCompile("start"), "it's starting") -// a.Regexp("start...$", "it's not starting") -func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Regexp(a.t, rx, str, msgAndArgs...) -} - -// Regexpf asserts that a specified regexp matches a string. -// -// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") -func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Regexpf(a.t, rx, str, msg, args...) -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Subset(a.t, list, subset, msgAndArgs...) -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Subsetf(a.t, list, subset, msg, args...) -} - -// True asserts that the specified value is true. -// -// a.True(myBool) -func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return True(a.t, value, msgAndArgs...) -} - -// Truef asserts that the specified value is true. -// -// a.Truef(myBool, "error message %s", "formatted") -func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Truef(a.t, value, msg, args...) -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) -func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return WithinDuration(a.t, expected, actual, delta, msgAndArgs...) -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return WithinDurationf(a.t, expected, actual, delta, msg, args...) -} - -// Zero asserts that i is the zero value for its type. -func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Zero(a.t, i, msgAndArgs...) -} - -// Zerof asserts that i is the zero value for its type. -func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - return Zerof(a.t, i, msg, args...) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl deleted file mode 100644 index 188bb9e..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{.CommentWithoutT "a"}} -func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { - if h, ok := a.t.(tHelper); ok { h.Helper() } - return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go deleted file mode 100644 index 5bdec56..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ /dev/null @@ -1,1394 +0,0 @@ -package assert - -import ( - "bufio" - "bytes" - "encoding/json" - "errors" - "fmt" - "math" - "os" - "reflect" - "regexp" - "runtime" - "strings" - "time" - "unicode" - "unicode/utf8" - - "github.com/davecgh/go-spew/spew" - "github.com/pmezard/go-difflib/difflib" -) - -//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_format.go.tmpl - -// TestingT is an interface wrapper around *testing.T -type TestingT interface { - Errorf(format string, args ...interface{}) -} - -// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful -// for table driven tests. -type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool - -// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful -// for table driven tests. -type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool - -// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful -// for table driven tests. -type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool - -// ValuesAssertionFunc is a common function prototype when validating an error value. Can be useful -// for table driven tests. -type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool - -// Comparison a custom function that returns true on success and false on failure -type Comparison func() (success bool) - -/* - Helper functions -*/ - -// ObjectsAreEqual determines if two objects are considered equal. -// -// This function does no assertion of any kind. -func ObjectsAreEqual(expected, actual interface{}) bool { - if expected == nil || actual == nil { - return expected == actual - } - - exp, ok := expected.([]byte) - if !ok { - return reflect.DeepEqual(expected, actual) - } - - act, ok := actual.([]byte) - if !ok { - return false - } - if exp == nil || act == nil { - return exp == nil && act == nil - } - return bytes.Equal(exp, act) -} - -// ObjectsAreEqualValues gets whether two objects are equal, or if their -// values are equal. -func ObjectsAreEqualValues(expected, actual interface{}) bool { - if ObjectsAreEqual(expected, actual) { - return true - } - - actualType := reflect.TypeOf(actual) - if actualType == nil { - return false - } - expectedValue := reflect.ValueOf(expected) - if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) { - // Attempt comparison after type conversion - return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual) - } - - return false -} - -/* CallerInfo is necessary because the assert functions use the testing object -internally, causing it to print the file:line of the assert method, rather than where -the problem actually occurred in calling code.*/ - -// CallerInfo returns an array of strings containing the file and line number -// of each stack frame leading from the current test to the assert call that -// failed. -func CallerInfo() []string { - - pc := uintptr(0) - file := "" - line := 0 - ok := false - name := "" - - callers := []string{} - for i := 0; ; i++ { - pc, file, line, ok = runtime.Caller(i) - if !ok { - // The breaks below failed to terminate the loop, and we ran off the - // end of the call stack. - break - } - - // This is a huge edge case, but it will panic if this is the case, see #180 - if file == "" { - break - } - - f := runtime.FuncForPC(pc) - if f == nil { - break - } - name = f.Name() - - // testing.tRunner is the standard library function that calls - // tests. Subtests are called directly by tRunner, without going through - // the Test/Benchmark/Example function that contains the t.Run calls, so - // with subtests we should break when we hit tRunner, without adding it - // to the list of callers. - if name == "testing.tRunner" { - break - } - - parts := strings.Split(file, "/") - file = parts[len(parts)-1] - if len(parts) > 1 { - dir := parts[len(parts)-2] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { - callers = append(callers, fmt.Sprintf("%s:%d", file, line)) - } - } - - // Drop the package - segments := strings.Split(name, ".") - name = segments[len(segments)-1] - if isTest(name, "Test") || - isTest(name, "Benchmark") || - isTest(name, "Example") { - break - } - } - - return callers -} - -// Stolen from the `go test` tool. -// isTest tells whether name looks like a test (or benchmark, according to prefix). -// It is a Test (say) if there is a character after Test that is not a lower-case letter. -// We don't want TesticularCancer. -func isTest(name, prefix string) bool { - if !strings.HasPrefix(name, prefix) { - return false - } - if len(name) == len(prefix) { // "Test" is ok - return true - } - rune, _ := utf8.DecodeRuneInString(name[len(prefix):]) - return !unicode.IsLower(rune) -} - -func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { - if len(msgAndArgs) == 0 || msgAndArgs == nil { - return "" - } - if len(msgAndArgs) == 1 { - return msgAndArgs[0].(string) - } - if len(msgAndArgs) > 1 { - return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) - } - return "" -} - -// Aligns the provided message so that all lines after the first line start at the same location as the first line. -// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). -// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the -// basis on which the alignment occurs). -func indentMessageLines(message string, longestLabelLen int) string { - outBuf := new(bytes.Buffer) - - for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ { - // no need to align first line because it starts at the correct location (after the label) - if i != 0 { - // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab - outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t") - } - outBuf.WriteString(scanner.Text()) - } - - return outBuf.String() -} - -type failNower interface { - FailNow() -} - -// FailNow fails test -func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - Fail(t, failureMessage, msgAndArgs...) - - // We cannot extend TestingT with FailNow() and - // maintain backwards compatibility, so we fallback - // to panicking when FailNow is not available in - // TestingT. - // See issue #263 - - if t, ok := t.(failNower); ok { - t.FailNow() - } else { - panic("test failed and t is missing `FailNow()`") - } - return false -} - -// Fail reports a failure through -func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - content := []labeledContent{ - {"Error Trace", strings.Join(CallerInfo(), "\n\t\t\t")}, - {"Error", failureMessage}, - } - - // Add test name if the Go version supports it - if n, ok := t.(interface { - Name() string - }); ok { - content = append(content, labeledContent{"Test", n.Name()}) - } - - message := messageFromMsgAndArgs(msgAndArgs...) - if len(message) > 0 { - content = append(content, labeledContent{"Messages", message}) - } - - t.Errorf("\n%s", ""+labeledOutput(content...)) - - return false -} - -type labeledContent struct { - label string - content string -} - -// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner: -// -// \t{{label}}:{{align_spaces}}\t{{content}}\n -// -// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label. -// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this -// alignment is achieved, "\t{{content}}\n" is added for the output. -// -// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line. -func labeledOutput(content ...labeledContent) string { - longestLabel := 0 - for _, v := range content { - if len(v.label) > longestLabel { - longestLabel = len(v.label) - } - } - var output string - for _, v := range content { - output += "\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n" - } - return output -} - -// Implements asserts that an object is implemented by the specified interface. -// -// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) -func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - interfaceType := reflect.TypeOf(interfaceObject).Elem() - - if object == nil { - return Fail(t, fmt.Sprintf("Cannot check if nil implements %v", interfaceType), msgAndArgs...) - } - if !reflect.TypeOf(object).Implements(interfaceType) { - return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...) - } - - return true -} - -// IsType asserts that the specified objects are of the same type. -func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) { - return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...) - } - - return true -} - -// Equal asserts that two objects are equal. -// -// assert.Equal(t, 123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err := validateEqualArgs(expected, actual); err != nil { - return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)", - expected, actual, err), msgAndArgs...) - } - - if !ObjectsAreEqual(expected, actual) { - diff := diff(expected, actual) - expected, actual = formatUnequalValues(expected, actual) - return Fail(t, fmt.Sprintf("Not equal: \n"+ - "expected: %s\n"+ - "actual : %s%s", expected, actual, diff), msgAndArgs...) - } - - return true - -} - -// formatUnequalValues takes two values of arbitrary types and returns string -// representations appropriate to be presented to the user. -// -// If the values are not of like type, the returned strings will be prefixed -// with the type name, and the value will be enclosed in parenthesis similar -// to a type conversion in the Go grammar. -func formatUnequalValues(expected, actual interface{}) (e string, a string) { - if reflect.TypeOf(expected) != reflect.TypeOf(actual) { - return fmt.Sprintf("%T(%#v)", expected, expected), - fmt.Sprintf("%T(%#v)", actual, actual) - } - - return fmt.Sprintf("%#v", expected), - fmt.Sprintf("%#v", actual) -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValues(t, uint32(123), int32(123)) -func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if !ObjectsAreEqualValues(expected, actual) { - diff := diff(expected, actual) - expected, actual = formatUnequalValues(expected, actual) - return Fail(t, fmt.Sprintf("Not equal: \n"+ - "expected: %s\n"+ - "actual : %s%s", expected, actual, diff), msgAndArgs...) - } - - return true - -} - -// Exactly asserts that two objects are equal in value and type. -// -// assert.Exactly(t, int32(123), int64(123)) -func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - aType := reflect.TypeOf(expected) - bType := reflect.TypeOf(actual) - - if aType != bType { - return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) - } - - return Equal(t, expected, actual, msgAndArgs...) - -} - -// NotNil asserts that the specified object is not nil. -// -// assert.NotNil(t, err) -func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if !isNil(object) { - return true - } - return Fail(t, "Expected value not to be nil.", msgAndArgs...) -} - -// isNil checks if a specified object is nil or not, without Failing. -func isNil(object interface{}) bool { - if object == nil { - return true - } - - value := reflect.ValueOf(object) - kind := value.Kind() - if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { - return true - } - - return false -} - -// Nil asserts that the specified object is nil. -// -// assert.Nil(t, err) -func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if isNil(object) { - return true - } - return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...) -} - -// isEmpty gets whether the specified object is considered empty or not. -func isEmpty(object interface{}) bool { - - // get nil case out of the way - if object == nil { - return true - } - - objValue := reflect.ValueOf(object) - - switch objValue.Kind() { - // collection types are empty when they have no element - case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: - return objValue.Len() == 0 - // pointers are empty if nil or if the value they point to is empty - case reflect.Ptr: - if objValue.IsNil() { - return true - } - deref := objValue.Elem().Interface() - return isEmpty(deref) - // for all other types, compare against the zero value - default: - zero := reflect.Zero(objValue.Type()) - return reflect.DeepEqual(object, zero.Interface()) - } -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Empty(t, obj) -func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - pass := isEmpty(object) - if !pass { - Fail(t, fmt.Sprintf("Should be empty, but was %v", object), msgAndArgs...) - } - - return pass - -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmpty(t, obj) { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - pass := !isEmpty(object) - if !pass { - Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...) - } - - return pass - -} - -// getLen try to get length of object. -// return (false, 0) if impossible. -func getLen(x interface{}) (ok bool, length int) { - v := reflect.ValueOf(x) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - return true, v.Len() -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// assert.Len(t, mySlice, 3) -func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - ok, l := getLen(object) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...) - } - - if l != length { - return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) - } - return true -} - -// True asserts that the specified value is true. -// -// assert.True(t, myBool) -func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if h, ok := t.(interface { - Helper() - }); ok { - h.Helper() - } - - if value != true { - return Fail(t, "Should be true", msgAndArgs...) - } - - return true - -} - -// False asserts that the specified value is false. -// -// assert.False(t, myBool) -func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if value != false { - return Fail(t, "Should be false", msgAndArgs...) - } - - return true - -} - -// NotEqual asserts that the specified values are NOT equal. -// -// assert.NotEqual(t, obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err := validateEqualArgs(expected, actual); err != nil { - return Fail(t, fmt.Sprintf("Invalid operation: %#v != %#v (%s)", - expected, actual, err), msgAndArgs...) - } - - if ObjectsAreEqual(expected, actual) { - return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...) - } - - return true - -} - -// containsElement try loop over the list check if the list includes the element. -// return (false, false) if impossible. -// return (true, false) if element was not found. -// return (true, true) if element was found. -func includeElement(list interface{}, element interface{}) (ok, found bool) { - - listValue := reflect.ValueOf(list) - elementValue := reflect.ValueOf(element) - defer func() { - if e := recover(); e != nil { - ok = false - found = false - } - }() - - if reflect.TypeOf(list).Kind() == reflect.String { - return true, strings.Contains(listValue.String(), elementValue.String()) - } - - if reflect.TypeOf(list).Kind() == reflect.Map { - mapKeys := listValue.MapKeys() - for i := 0; i < len(mapKeys); i++ { - if ObjectsAreEqual(mapKeys[i].Interface(), element) { - return true, true - } - } - return true, false - } - - for i := 0; i < listValue.Len(); i++ { - if ObjectsAreEqual(listValue.Index(i).Interface(), element) { - return true, true - } - } - return true, false - -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Contains(t, "Hello World", "World") -// assert.Contains(t, ["Hello", "World"], "World") -// assert.Contains(t, {"Hello": "World"}, "Hello") -func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - ok, found := includeElement(s, contains) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) - } - if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", s, contains), msgAndArgs...) - } - - return true - -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContains(t, "Hello World", "Earth") -// assert.NotContains(t, ["Hello", "World"], "Earth") -// assert.NotContains(t, {"Hello": "World"}, "Earth") -func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - ok, found := includeElement(s, contains) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) - } - if found { - return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...) - } - - return true - -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if subset == nil { - return true // we consider nil to be equal to the nil set - } - - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) - } - - if subsetKind != reflect.Array && subsetKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) - } - - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() - ok, found := includeElement(list, element) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) - } - if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) - } - } - - return true -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if subset == nil { - return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...) - } - - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) - } - - if subsetKind != reflect.Array && subsetKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) - } - - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() - ok, found := includeElement(list, element) - if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) - } - if !found { - return true - } - } - - return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) -func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if isEmpty(listA) && isEmpty(listB) { - return true - } - - aKind := reflect.TypeOf(listA).Kind() - bKind := reflect.TypeOf(listB).Kind() - - if aKind != reflect.Array && aKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listA, aKind), msgAndArgs...) - } - - if bKind != reflect.Array && bKind != reflect.Slice { - return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listB, bKind), msgAndArgs...) - } - - aValue := reflect.ValueOf(listA) - bValue := reflect.ValueOf(listB) - - aLen := aValue.Len() - bLen := bValue.Len() - - if aLen != bLen { - return Fail(t, fmt.Sprintf("lengths don't match: %d != %d", aLen, bLen), msgAndArgs...) - } - - // Mark indexes in bValue that we already used - visited := make([]bool, bLen) - for i := 0; i < aLen; i++ { - element := aValue.Index(i).Interface() - found := false - for j := 0; j < bLen; j++ { - if visited[j] { - continue - } - if ObjectsAreEqual(bValue.Index(j).Interface(), element) { - visited[j] = true - found = true - break - } - } - if !found { - return Fail(t, fmt.Sprintf("element %s appears more times in %s than in %s", element, aValue, bValue), msgAndArgs...) - } - } - - return true -} - -// Condition uses a Comparison to assert a complex condition. -func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - result := comp() - if !result { - Fail(t, "Condition failed!", msgAndArgs...) - } - return result -} - -// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics -// methods, and represents a simple func that takes no arguments, and returns nothing. -type PanicTestFunc func() - -// didPanic returns true if the function passed to it panics. Otherwise, it returns false. -func didPanic(f PanicTestFunc) (bool, interface{}) { - - didPanic := false - var message interface{} - func() { - - defer func() { - if message = recover(); message != nil { - didPanic = true - } - }() - - // call the target function - f() - - }() - - return didPanic, message - -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panics(t, func(){ GoCrazy() }) -func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if funcDidPanic, panicValue := didPanic(f); !funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) - } - - return true -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) -func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - funcDidPanic, panicValue := didPanic(f) - if !funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) - } - if panicValue != expected { - return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v", f, expected, panicValue), msgAndArgs...) - } - - return true -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanics(t, func(){ RemainCalm() }) -func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if funcDidPanic, panicValue := didPanic(f); funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should not panic\n\tPanic value:\t%v", f, panicValue), msgAndArgs...) - } - - return true -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) -func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - dt := expected.Sub(actual) - if dt < -delta || dt > delta { - return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) - } - - return true -} - -func toFloat(x interface{}) (float64, bool) { - var xf float64 - xok := true - - switch xn := x.(type) { - case uint8: - xf = float64(xn) - case uint16: - xf = float64(xn) - case uint32: - xf = float64(xn) - case uint64: - xf = float64(xn) - case int: - xf = float64(xn) - case int8: - xf = float64(xn) - case int16: - xf = float64(xn) - case int32: - xf = float64(xn) - case int64: - xf = float64(xn) - case float32: - xf = float64(xn) - case float64: - xf = float64(xn) - case time.Duration: - xf = float64(xn) - default: - xok = false - } - - return xf, xok -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) -func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - af, aok := toFloat(expected) - bf, bok := toFloat(actual) - - if !aok || !bok { - return Fail(t, fmt.Sprintf("Parameters must be numerical"), msgAndArgs...) - } - - if math.IsNaN(af) { - return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...) - } - - if math.IsNaN(bf) { - return Fail(t, fmt.Sprintf("Expected %v with delta %v, but was NaN", expected, delta), msgAndArgs...) - } - - dt := af - bf - if dt < -delta || dt > delta { - return Fail(t, fmt.Sprintf("Max difference between %v and %v allowed is %v, but difference was %v", expected, actual, delta, dt), msgAndArgs...) - } - - return true -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Slice || - reflect.TypeOf(expected).Kind() != reflect.Slice { - return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...) - } - - actualSlice := reflect.ValueOf(actual) - expectedSlice := reflect.ValueOf(expected) - - for i := 0; i < actualSlice.Len(); i++ { - result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...) - if !result { - return result - } - } - - return true -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Map || - reflect.TypeOf(expected).Kind() != reflect.Map { - return Fail(t, "Arguments must be maps", msgAndArgs...) - } - - expectedMap := reflect.ValueOf(expected) - actualMap := reflect.ValueOf(actual) - - if expectedMap.Len() != actualMap.Len() { - return Fail(t, "Arguments must have the same number of keys", msgAndArgs...) - } - - for _, k := range expectedMap.MapKeys() { - ev := expectedMap.MapIndex(k) - av := actualMap.MapIndex(k) - - if !ev.IsValid() { - return Fail(t, fmt.Sprintf("missing key %q in expected map", k), msgAndArgs...) - } - - if !av.IsValid() { - return Fail(t, fmt.Sprintf("missing key %q in actual map", k), msgAndArgs...) - } - - if !InDelta( - t, - ev.Interface(), - av.Interface(), - delta, - msgAndArgs..., - ) { - return false - } - } - - return true -} - -func calcRelativeError(expected, actual interface{}) (float64, error) { - af, aok := toFloat(expected) - if !aok { - return 0, fmt.Errorf("expected value %q cannot be converted to float", expected) - } - if af == 0 { - return 0, fmt.Errorf("expected value must have a value other than zero to calculate the relative error") - } - bf, bok := toFloat(actual) - if !bok { - return 0, fmt.Errorf("actual value %q cannot be converted to float", actual) - } - - return math.Abs(af-bf) / math.Abs(af), nil -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - actualEpsilon, err := calcRelativeError(expected, actual) - if err != nil { - return Fail(t, err.Error(), msgAndArgs...) - } - if actualEpsilon > epsilon { - return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+ - " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...) - } - - return true -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Slice || - reflect.TypeOf(expected).Kind() != reflect.Slice { - return Fail(t, fmt.Sprintf("Parameters must be slice"), msgAndArgs...) - } - - actualSlice := reflect.ValueOf(actual) - expectedSlice := reflect.ValueOf(expected) - - for i := 0; i < actualSlice.Len(); i++ { - result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon) - if !result { - return result - } - } - - return true -} - -/* - Errors -*/ - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoError(t, err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if err != nil { - return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...) - } - - return true -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } -func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - if err == nil { - return Fail(t, "An error is expected but got nil.", msgAndArgs...) - } - - return true -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualError(t, err, expectedErrorString) -func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if !Error(t, theError, msgAndArgs...) { - return false - } - expected := errString - actual := theError.Error() - // don't need to use deep equals here, we know they are both strings - if expected != actual { - return Fail(t, fmt.Sprintf("Error message not equal:\n"+ - "expected: %q\n"+ - "actual : %q", expected, actual), msgAndArgs...) - } - return true -} - -// matchRegexp return true if a specified regexp matches a string. -func matchRegexp(rx interface{}, str interface{}) bool { - - var r *regexp.Regexp - if rr, ok := rx.(*regexp.Regexp); ok { - r = rr - } else { - r = regexp.MustCompile(fmt.Sprint(rx)) - } - - return (r.FindStringIndex(fmt.Sprint(str)) != nil) - -} - -// Regexp asserts that a specified regexp matches a string. -// -// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") -// assert.Regexp(t, "start...$", "it's not starting") -func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - match := matchRegexp(rx, str) - - if !match { - Fail(t, fmt.Sprintf("Expect \"%v\" to match \"%v\"", str, rx), msgAndArgs...) - } - - return match -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") -// assert.NotRegexp(t, "^start", "it's not starting") -func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - match := matchRegexp(rx, str) - - if match { - Fail(t, fmt.Sprintf("Expect \"%v\" to NOT match \"%v\"", str, rx), msgAndArgs...) - } - - return !match - -} - -// Zero asserts that i is the zero value for its type. -func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { - return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...) - } - return true -} - -// NotZero asserts that i is not the zero value for its type. -func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - if i == nil || reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { - return Fail(t, fmt.Sprintf("Should not be zero, but was %v", i), msgAndArgs...) - } - return true -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - info, err := os.Lstat(path) - if err != nil { - if os.IsNotExist(err) { - return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) - } - return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) - } - if info.IsDir() { - return Fail(t, fmt.Sprintf("%q is a directory", path), msgAndArgs...) - } - return true -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - info, err := os.Lstat(path) - if err != nil { - if os.IsNotExist(err) { - return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) - } - return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) - } - if !info.IsDir() { - return Fail(t, fmt.Sprintf("%q is a file", path), msgAndArgs...) - } - return true -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - var expectedJSONAsInterface, actualJSONAsInterface interface{} - - if err := json.Unmarshal([]byte(expected), &expectedJSONAsInterface); err != nil { - return Fail(t, fmt.Sprintf("Expected value ('%s') is not valid json.\nJSON parsing error: '%s'", expected, err.Error()), msgAndArgs...) - } - - if err := json.Unmarshal([]byte(actual), &actualJSONAsInterface); err != nil { - return Fail(t, fmt.Sprintf("Input ('%s') needs to be valid json.\nJSON parsing error: '%s'", actual, err.Error()), msgAndArgs...) - } - - return Equal(t, expectedJSONAsInterface, actualJSONAsInterface, msgAndArgs...) -} - -func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { - t := reflect.TypeOf(v) - k := t.Kind() - - if k == reflect.Ptr { - t = t.Elem() - k = t.Kind() - } - return t, k -} - -// diff returns a diff of both values as long as both are of the same type and -// are a struct, map, slice or array. Otherwise it returns an empty string. -func diff(expected interface{}, actual interface{}) string { - if expected == nil || actual == nil { - return "" - } - - et, ek := typeAndKind(expected) - at, _ := typeAndKind(actual) - - if et != at { - return "" - } - - if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String { - return "" - } - - var e, a string - if ek != reflect.String { - e = spewConfig.Sdump(expected) - a = spewConfig.Sdump(actual) - } else { - e = expected.(string) - a = actual.(string) - } - - diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ - A: difflib.SplitLines(e), - B: difflib.SplitLines(a), - FromFile: "Expected", - FromDate: "", - ToFile: "Actual", - ToDate: "", - Context: 1, - }) - - return "\n\nDiff:\n" + diff -} - -// validateEqualArgs checks whether provided arguments can be safely used in the -// Equal/NotEqual functions. -func validateEqualArgs(expected, actual interface{}) error { - if isFunction(expected) || isFunction(actual) { - return errors.New("cannot take func type as argument") - } - return nil -} - -func isFunction(arg interface{}) bool { - if arg == nil { - return false - } - return reflect.TypeOf(arg).Kind() == reflect.Func -} - -var spewConfig = spew.ConfigState{ - Indent: " ", - DisablePointerAddresses: true, - DisableCapacities: true, - SortKeys: true, -} - -type tHelper interface { - Helper() -} diff --git a/vendor/github.com/stretchr/testify/assert/assertions_test.go b/vendor/github.com/stretchr/testify/assert/assertions_test.go deleted file mode 100644 index 91b5ee9..0000000 --- a/vendor/github.com/stretchr/testify/assert/assertions_test.go +++ /dev/null @@ -1,1793 +0,0 @@ -package assert - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "io" - "math" - "os" - "reflect" - "regexp" - "runtime" - "strings" - "testing" - "time" -) - -var ( - i interface{} - zeros = []interface{}{ - false, - byte(0), - complex64(0), - complex128(0), - float32(0), - float64(0), - int(0), - int8(0), - int16(0), - int32(0), - int64(0), - rune(0), - uint(0), - uint8(0), - uint16(0), - uint32(0), - uint64(0), - uintptr(0), - "", - [0]interface{}{}, - []interface{}(nil), - struct{ x int }{}, - (*interface{})(nil), - (func())(nil), - nil, - interface{}(nil), - map[interface{}]interface{}(nil), - (chan interface{})(nil), - (<-chan interface{})(nil), - (chan<- interface{})(nil), - } - nonZeros = []interface{}{ - true, - byte(1), - complex64(1), - complex128(1), - float32(1), - float64(1), - int(1), - int8(1), - int16(1), - int32(1), - int64(1), - rune(1), - uint(1), - uint8(1), - uint16(1), - uint32(1), - uint64(1), - uintptr(1), - "s", - [1]interface{}{1}, - []interface{}{}, - struct{ x int }{1}, - (*interface{})(&i), - (func())(func() {}), - interface{}(1), - map[interface{}]interface{}{}, - (chan interface{})(make(chan interface{})), - (<-chan interface{})(make(chan interface{})), - (chan<- interface{})(make(chan interface{})), - } -) - -// AssertionTesterInterface defines an interface to be used for testing assertion methods -type AssertionTesterInterface interface { - TestMethod() -} - -// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface -type AssertionTesterConformingObject struct { -} - -func (a *AssertionTesterConformingObject) TestMethod() { -} - -// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface -type AssertionTesterNonConformingObject struct { -} - -func TestObjectsAreEqual(t *testing.T) { - - if !ObjectsAreEqual("Hello World", "Hello World") { - t.Error("objectsAreEqual should return true") - } - if !ObjectsAreEqual(123, 123) { - t.Error("objectsAreEqual should return true") - } - if !ObjectsAreEqual(123.5, 123.5) { - t.Error("objectsAreEqual should return true") - } - if !ObjectsAreEqual([]byte("Hello World"), []byte("Hello World")) { - t.Error("objectsAreEqual should return true") - } - if !ObjectsAreEqual(nil, nil) { - t.Error("objectsAreEqual should return true") - } - if ObjectsAreEqual(map[int]int{5: 10}, map[int]int{10: 20}) { - t.Error("objectsAreEqual should return false") - } - if ObjectsAreEqual('x', "x") { - t.Error("objectsAreEqual should return false") - } - if ObjectsAreEqual("x", 'x') { - t.Error("objectsAreEqual should return false") - } - if ObjectsAreEqual(0, 0.1) { - t.Error("objectsAreEqual should return false") - } - if ObjectsAreEqual(0.1, 0) { - t.Error("objectsAreEqual should return false") - } - if ObjectsAreEqual(uint32(10), int32(10)) { - t.Error("objectsAreEqual should return false") - } - if !ObjectsAreEqualValues(uint32(10), int32(10)) { - t.Error("ObjectsAreEqualValues should return true") - } - if ObjectsAreEqualValues(0, nil) { - t.Fail() - } - if ObjectsAreEqualValues(nil, 0) { - t.Fail() - } - -} - -func TestImplements(t *testing.T) { - - mockT := new(testing.T) - - if !Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { - t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") - } - if Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { - t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") - } - if Implements(mockT, (*AssertionTesterInterface)(nil), nil) { - t.Error("Implements method should return false: nil does not implement AssertionTesterInterface") - } - -} - -func TestIsType(t *testing.T) { - - mockT := new(testing.T) - - if !IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { - t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") - } - if IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { - t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") - } - -} - -func TestEqual(t *testing.T) { - - mockT := new(testing.T) - - if !Equal(mockT, "Hello World", "Hello World") { - t.Error("Equal should return true") - } - if !Equal(mockT, 123, 123) { - t.Error("Equal should return true") - } - if !Equal(mockT, 123.5, 123.5) { - t.Error("Equal should return true") - } - if !Equal(mockT, []byte("Hello World"), []byte("Hello World")) { - t.Error("Equal should return true") - } - if !Equal(mockT, nil, nil) { - t.Error("Equal should return true") - } - if !Equal(mockT, int32(123), int32(123)) { - t.Error("Equal should return true") - } - if !Equal(mockT, uint64(123), uint64(123)) { - t.Error("Equal should return true") - } - if !Equal(mockT, &struct{}{}, &struct{}{}) { - t.Error("Equal should return true (pointer equality is based on equality of underlying value)") - } - var m map[string]interface{} - if Equal(mockT, m["bar"], "something") { - t.Error("Equal should return false") - } -} - -// bufferT implements TestingT. Its implementation of Errorf writes the output that would be produced by -// testing.T.Errorf to an internal bytes.Buffer. -type bufferT struct { - buf bytes.Buffer -} - -func (t *bufferT) Errorf(format string, args ...interface{}) { - // implementation of decorate is copied from testing.T - decorate := func(s string) string { - _, file, line, ok := runtime.Caller(3) // decorate + log + public function. - if ok { - // Truncate file name at last file name separator. - if index := strings.LastIndex(file, "/"); index >= 0 { - file = file[index+1:] - } else if index = strings.LastIndex(file, "\\"); index >= 0 { - file = file[index+1:] - } - } else { - file = "???" - line = 1 - } - buf := new(bytes.Buffer) - // Every line is indented at least one tab. - buf.WriteByte('\t') - fmt.Fprintf(buf, "%s:%d: ", file, line) - lines := strings.Split(s, "\n") - if l := len(lines); l > 1 && lines[l-1] == "" { - lines = lines[:l-1] - } - for i, line := range lines { - if i > 0 { - // Second and subsequent lines are indented an extra tab. - buf.WriteString("\n\t\t") - } - buf.WriteString(line) - } - buf.WriteByte('\n') - return buf.String() - } - t.buf.WriteString(decorate(fmt.Sprintf(format, args...))) -} - -func TestStringEqual(t *testing.T) { - for i, currCase := range []struct { - equalWant string - equalGot string - msgAndArgs []interface{} - want string - }{ - {equalWant: "hi, \nmy name is", equalGot: "what,\nmy name is", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"hi, \\\\nmy name is\"\n\\s+actual\\s+: \"what,\\\\nmy name is\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1,2 \\+1,2 @@\n\\s+-hi, \n\\s+\\+what,\n\\s+my name is"}, - } { - mockT := &bufferT{} - Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...) - Regexp(t, regexp.MustCompile(currCase.want), mockT.buf.String(), "Case %d", i) - } -} - -func TestEqualFormatting(t *testing.T) { - for i, currCase := range []struct { - equalWant string - equalGot string - msgAndArgs []interface{} - want string - }{ - {equalWant: "want", equalGot: "got", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n"}, - {equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n\\s+Messages:\\s+hello, world!\n"}, - } { - mockT := &bufferT{} - Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...) - Regexp(t, regexp.MustCompile(currCase.want), mockT.buf.String(), "Case %d", i) - } -} - -func TestFormatUnequalValues(t *testing.T) { - expected, actual := formatUnequalValues("foo", "bar") - Equal(t, `"foo"`, expected, "value should not include type") - Equal(t, `"bar"`, actual, "value should not include type") - - expected, actual = formatUnequalValues(123, 123) - Equal(t, `123`, expected, "value should not include type") - Equal(t, `123`, actual, "value should not include type") - - expected, actual = formatUnequalValues(int64(123), int32(123)) - Equal(t, `int64(123)`, expected, "value should include type") - Equal(t, `int32(123)`, actual, "value should include type") - - expected, actual = formatUnequalValues(int64(123), nil) - Equal(t, `int64(123)`, expected, "value should include type") - Equal(t, `()`, actual, "value should include type") - - type testStructType struct { - Val string - } - - expected, actual = formatUnequalValues(&testStructType{Val: "test"}, &testStructType{Val: "test"}) - Equal(t, `&assert.testStructType{Val:"test"}`, expected, "value should not include type annotation") - Equal(t, `&assert.testStructType{Val:"test"}`, actual, "value should not include type annotation") -} - -func TestNotNil(t *testing.T) { - - mockT := new(testing.T) - - if !NotNil(mockT, new(AssertionTesterConformingObject)) { - t.Error("NotNil should return true: object is not nil") - } - if NotNil(mockT, nil) { - t.Error("NotNil should return false: object is nil") - } - if NotNil(mockT, (*struct{})(nil)) { - t.Error("NotNil should return false: object is (*struct{})(nil)") - } - -} - -func TestNil(t *testing.T) { - - mockT := new(testing.T) - - if !Nil(mockT, nil) { - t.Error("Nil should return true: object is nil") - } - if !Nil(mockT, (*struct{})(nil)) { - t.Error("Nil should return true: object is (*struct{})(nil)") - } - if Nil(mockT, new(AssertionTesterConformingObject)) { - t.Error("Nil should return false: object is not nil") - } - -} - -func TestTrue(t *testing.T) { - - mockT := new(testing.T) - - if !True(mockT, true) { - t.Error("True should return true") - } - if True(mockT, false) { - t.Error("True should return false") - } - -} - -func TestFalse(t *testing.T) { - - mockT := new(testing.T) - - if !False(mockT, false) { - t.Error("False should return true") - } - if False(mockT, true) { - t.Error("False should return false") - } - -} - -func TestExactly(t *testing.T) { - - mockT := new(testing.T) - - a := float32(1) - b := float64(1) - c := float32(1) - d := float32(2) - - if Exactly(mockT, a, b) { - t.Error("Exactly should return false") - } - if Exactly(mockT, a, d) { - t.Error("Exactly should return false") - } - if !Exactly(mockT, a, c) { - t.Error("Exactly should return true") - } - - if Exactly(mockT, nil, a) { - t.Error("Exactly should return false") - } - if Exactly(mockT, a, nil) { - t.Error("Exactly should return false") - } - -} - -func TestNotEqual(t *testing.T) { - - mockT := new(testing.T) - - if !NotEqual(mockT, "Hello World", "Hello World!") { - t.Error("NotEqual should return true") - } - if !NotEqual(mockT, 123, 1234) { - t.Error("NotEqual should return true") - } - if !NotEqual(mockT, 123.5, 123.55) { - t.Error("NotEqual should return true") - } - if !NotEqual(mockT, []byte("Hello World"), []byte("Hello World!")) { - t.Error("NotEqual should return true") - } - if !NotEqual(mockT, nil, new(AssertionTesterConformingObject)) { - t.Error("NotEqual should return true") - } - funcA := func() int { return 23 } - funcB := func() int { return 42 } - if NotEqual(mockT, funcA, funcB) { - t.Error("NotEqual should return false") - } - - if NotEqual(mockT, "Hello World", "Hello World") { - t.Error("NotEqual should return false") - } - if NotEqual(mockT, 123, 123) { - t.Error("NotEqual should return false") - } - if NotEqual(mockT, 123.5, 123.5) { - t.Error("NotEqual should return false") - } - if NotEqual(mockT, []byte("Hello World"), []byte("Hello World")) { - t.Error("NotEqual should return false") - } - if NotEqual(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { - t.Error("NotEqual should return false") - } - if NotEqual(mockT, &struct{}{}, &struct{}{}) { - t.Error("NotEqual should return false") - } -} - -type A struct { - Name, Value string -} - -func TestContains(t *testing.T) { - - mockT := new(testing.T) - list := []string{"Foo", "Bar"} - complexList := []*A{ - {"b", "c"}, - {"d", "e"}, - {"g", "h"}, - {"j", "k"}, - } - simpleMap := map[interface{}]interface{}{"Foo": "Bar"} - - if !Contains(mockT, "Hello World", "Hello") { - t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") - } - if Contains(mockT, "Hello World", "Salut") { - t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") - } - - if !Contains(mockT, list, "Bar") { - t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Bar\"") - } - if Contains(mockT, list, "Salut") { - t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") - } - if !Contains(mockT, complexList, &A{"g", "h"}) { - t.Error("Contains should return true: complexList contains {\"g\", \"h\"}") - } - if Contains(mockT, complexList, &A{"g", "e"}) { - t.Error("Contains should return false: complexList contains {\"g\", \"e\"}") - } - if Contains(mockT, complexList, &A{"g", "e"}) { - t.Error("Contains should return false: complexList contains {\"g\", \"e\"}") - } - if !Contains(mockT, simpleMap, "Foo") { - t.Error("Contains should return true: \"{\"Foo\": \"Bar\"}\" contains \"Foo\"") - } - if Contains(mockT, simpleMap, "Bar") { - t.Error("Contains should return false: \"{\"Foo\": \"Bar\"}\" does not contains \"Bar\"") - } -} - -func TestNotContains(t *testing.T) { - - mockT := new(testing.T) - list := []string{"Foo", "Bar"} - simpleMap := map[interface{}]interface{}{"Foo": "Bar"} - - if !NotContains(mockT, "Hello World", "Hello!") { - t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") - } - if NotContains(mockT, "Hello World", "Hello") { - t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") - } - - if !NotContains(mockT, list, "Foo!") { - t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") - } - if NotContains(mockT, list, "Foo") { - t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") - } - if NotContains(mockT, simpleMap, "Foo") { - t.Error("Contains should return true: \"{\"Foo\": \"Bar\"}\" contains \"Foo\"") - } - if !NotContains(mockT, simpleMap, "Bar") { - t.Error("Contains should return false: \"{\"Foo\": \"Bar\"}\" does not contains \"Bar\"") - } -} - -func TestSubset(t *testing.T) { - mockT := new(testing.T) - - if !Subset(mockT, []int{1, 2, 3}, nil) { - t.Error("Subset should return true: given subset is nil") - } - if !Subset(mockT, []int{1, 2, 3}, []int{}) { - t.Error("Subset should return true: any set contains the nil set") - } - if !Subset(mockT, []int{1, 2, 3}, []int{1, 2}) { - t.Error("Subset should return true: [1, 2, 3] contains [1, 2]") - } - if !Subset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) { - t.Error("Subset should return true: [1, 2, 3] contains [1, 2, 3]") - } - if !Subset(mockT, []string{"hello", "world"}, []string{"hello"}) { - t.Error("Subset should return true: [\"hello\", \"world\"] contains [\"hello\"]") - } - - if Subset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) { - t.Error("Subset should return false: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]") - } - if Subset(mockT, []int{1, 2, 3}, []int{4, 5}) { - t.Error("Subset should return false: [1, 2, 3] does not contain [4, 5]") - } - if Subset(mockT, []int{1, 2, 3}, []int{1, 5}) { - t.Error("Subset should return false: [1, 2, 3] does not contain [1, 5]") - } -} - -func TestNotSubset(t *testing.T) { - mockT := new(testing.T) - - if NotSubset(mockT, []int{1, 2, 3}, nil) { - t.Error("NotSubset should return false: given subset is nil") - } - if NotSubset(mockT, []int{1, 2, 3}, []int{}) { - t.Error("NotSubset should return false: any set contains the nil set") - } - if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2}) { - t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2]") - } - if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) { - t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2, 3]") - } - if NotSubset(mockT, []string{"hello", "world"}, []string{"hello"}) { - t.Error("NotSubset should return false: [\"hello\", \"world\"] contains [\"hello\"]") - } - - if !NotSubset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) { - t.Error("NotSubset should return true: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]") - } - if !NotSubset(mockT, []int{1, 2, 3}, []int{4, 5}) { - t.Error("NotSubset should return true: [1, 2, 3] does not contain [4, 5]") - } - if !NotSubset(mockT, []int{1, 2, 3}, []int{1, 5}) { - t.Error("NotSubset should return true: [1, 2, 3] does not contain [1, 5]") - } -} - -func TestNotSubsetNil(t *testing.T) { - mockT := new(testing.T) - NotSubset(mockT, []string{"foo"}, nil) - if !mockT.Failed() { - t.Error("NotSubset on nil set should have failed the test") - } -} - -func Test_includeElement(t *testing.T) { - - list1 := []string{"Foo", "Bar"} - list2 := []int{1, 2} - simpleMap := map[interface{}]interface{}{"Foo": "Bar"} - - ok, found := includeElement("Hello World", "World") - True(t, ok) - True(t, found) - - ok, found = includeElement(list1, "Foo") - True(t, ok) - True(t, found) - - ok, found = includeElement(list1, "Bar") - True(t, ok) - True(t, found) - - ok, found = includeElement(list2, 1) - True(t, ok) - True(t, found) - - ok, found = includeElement(list2, 2) - True(t, ok) - True(t, found) - - ok, found = includeElement(list1, "Foo!") - True(t, ok) - False(t, found) - - ok, found = includeElement(list2, 3) - True(t, ok) - False(t, found) - - ok, found = includeElement(list2, "1") - True(t, ok) - False(t, found) - - ok, found = includeElement(simpleMap, "Foo") - True(t, ok) - True(t, found) - - ok, found = includeElement(simpleMap, "Bar") - True(t, ok) - False(t, found) - - ok, found = includeElement(1433, "1") - False(t, ok) - False(t, found) -} - -func TestElementsMatch(t *testing.T) { - mockT := new(testing.T) - - if !ElementsMatch(mockT, nil, nil) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{}, []int{}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{1}, []int{1}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{1, 1}, []int{1, 1}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{1, 2}, []int{1, 2}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{1, 2}, []int{2, 1}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, [2]int{1, 2}, [2]int{2, 1}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []string{"hello", "world"}, []string{"world", "hello"}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []string{"hello", "hello"}, []string{"hello", "hello"}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []string{"hello", "hello", "world"}, []string{"hello", "world", "hello"}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, [3]string{"hello", "hello", "world"}, [3]string{"hello", "world", "hello"}) { - t.Error("ElementsMatch should return true") - } - if !ElementsMatch(mockT, []int{}, nil) { - t.Error("ElementsMatch should return true") - } - - if ElementsMatch(mockT, []int{1}, []int{1, 1}) { - t.Error("ElementsMatch should return false") - } - if ElementsMatch(mockT, []int{1, 2}, []int{2, 2}) { - t.Error("ElementsMatch should return false") - } - if ElementsMatch(mockT, []string{"hello", "hello"}, []string{"hello"}) { - t.Error("ElementsMatch should return false") - } -} - -func TestCondition(t *testing.T) { - mockT := new(testing.T) - - if !Condition(mockT, func() bool { return true }, "Truth") { - t.Error("Condition should return true") - } - - if Condition(mockT, func() bool { return false }, "Lie") { - t.Error("Condition should return false") - } - -} - -func TestDidPanic(t *testing.T) { - - if funcDidPanic, _ := didPanic(func() { - panic("Panic!") - }); !funcDidPanic { - t.Error("didPanic should return true") - } - - if funcDidPanic, _ := didPanic(func() { - }); funcDidPanic { - t.Error("didPanic should return false") - } - -} - -func TestPanics(t *testing.T) { - - mockT := new(testing.T) - - if !Panics(mockT, func() { - panic("Panic!") - }) { - t.Error("Panics should return true") - } - - if Panics(mockT, func() { - }) { - t.Error("Panics should return false") - } - -} - -func TestPanicsWithValue(t *testing.T) { - - mockT := new(testing.T) - - if !PanicsWithValue(mockT, "Panic!", func() { - panic("Panic!") - }) { - t.Error("PanicsWithValue should return true") - } - - if PanicsWithValue(mockT, "Panic!", func() { - }) { - t.Error("PanicsWithValue should return false") - } - - if PanicsWithValue(mockT, "at the disco", func() { - panic("Panic!") - }) { - t.Error("PanicsWithValue should return false") - } -} - -func TestNotPanics(t *testing.T) { - - mockT := new(testing.T) - - if !NotPanics(mockT, func() { - }) { - t.Error("NotPanics should return true") - } - - if NotPanics(mockT, func() { - panic("Panic!") - }) { - t.Error("NotPanics should return false") - } - -} - -func TestNoError(t *testing.T) { - - mockT := new(testing.T) - - // start with a nil error - var err error - - True(t, NoError(mockT, err), "NoError should return True for nil arg") - - // now set an error - err = errors.New("some error") - - False(t, NoError(mockT, err), "NoError with error should return False") - - // returning an empty error interface - err = func() error { - var err *customError - if err != nil { - t.Fatal("err should be nil here") - } - return err - }() - - if err == nil { // err is not nil here! - t.Errorf("Error should be nil due to empty interface: %s", err) - } - - False(t, NoError(mockT, err), "NoError should fail with empty error interface") -} - -type customError struct{} - -func (*customError) Error() string { return "fail" } - -func TestError(t *testing.T) { - - mockT := new(testing.T) - - // start with a nil error - var err error - - False(t, Error(mockT, err), "Error should return False for nil arg") - - // now set an error - err = errors.New("some error") - - True(t, Error(mockT, err), "Error with error should return True") - - // go vet check - True(t, Errorf(mockT, err, "example with %s", "formatted message"), "Errorf with error should rturn True") - - // returning an empty error interface - err = func() error { - var err *customError - if err != nil { - t.Fatal("err should be nil here") - } - return err - }() - - if err == nil { // err is not nil here! - t.Errorf("Error should be nil due to empty interface: %s", err) - } - - True(t, Error(mockT, err), "Error should pass with empty error interface") -} - -func TestEqualError(t *testing.T) { - mockT := new(testing.T) - - // start with a nil error - var err error - False(t, EqualError(mockT, err, ""), - "EqualError should return false for nil arg") - - // now set an error - err = errors.New("some error") - False(t, EqualError(mockT, err, "Not some error"), - "EqualError should return false for different error string") - True(t, EqualError(mockT, err, "some error"), - "EqualError should return true") -} - -func Test_isEmpty(t *testing.T) { - - chWithValue := make(chan struct{}, 1) - chWithValue <- struct{}{} - - True(t, isEmpty("")) - True(t, isEmpty(nil)) - True(t, isEmpty([]string{})) - True(t, isEmpty(0)) - True(t, isEmpty(int32(0))) - True(t, isEmpty(int64(0))) - True(t, isEmpty(false)) - True(t, isEmpty(map[string]string{})) - True(t, isEmpty(new(time.Time))) - True(t, isEmpty(time.Time{})) - True(t, isEmpty(make(chan struct{}))) - False(t, isEmpty("something")) - False(t, isEmpty(errors.New("something"))) - False(t, isEmpty([]string{"something"})) - False(t, isEmpty(1)) - False(t, isEmpty(true)) - False(t, isEmpty(map[string]string{"Hello": "World"})) - False(t, isEmpty(chWithValue)) - -} - -func TestEmpty(t *testing.T) { - - mockT := new(testing.T) - chWithValue := make(chan struct{}, 1) - chWithValue <- struct{}{} - var tiP *time.Time - var tiNP time.Time - var s *string - var f *os.File - sP := &s - x := 1 - xP := &x - - type TString string - type TStruct struct { - x int - s []int - } - - True(t, Empty(mockT, ""), "Empty string is empty") - True(t, Empty(mockT, nil), "Nil is empty") - True(t, Empty(mockT, []string{}), "Empty string array is empty") - True(t, Empty(mockT, 0), "Zero int value is empty") - True(t, Empty(mockT, false), "False value is empty") - True(t, Empty(mockT, make(chan struct{})), "Channel without values is empty") - True(t, Empty(mockT, s), "Nil string pointer is empty") - True(t, Empty(mockT, f), "Nil os.File pointer is empty") - True(t, Empty(mockT, tiP), "Nil time.Time pointer is empty") - True(t, Empty(mockT, tiNP), "time.Time is empty") - True(t, Empty(mockT, TStruct{}), "struct with zero values is empty") - True(t, Empty(mockT, TString("")), "empty aliased string is empty") - True(t, Empty(mockT, sP), "ptr to nil value is empty") - - False(t, Empty(mockT, "something"), "Non Empty string is not empty") - False(t, Empty(mockT, errors.New("something")), "Non nil object is not empty") - False(t, Empty(mockT, []string{"something"}), "Non empty string array is not empty") - False(t, Empty(mockT, 1), "Non-zero int value is not empty") - False(t, Empty(mockT, true), "True value is not empty") - False(t, Empty(mockT, chWithValue), "Channel with values is not empty") - False(t, Empty(mockT, TStruct{x: 1}), "struct with initialized values is empty") - False(t, Empty(mockT, TString("abc")), "non-empty aliased string is empty") - False(t, Empty(mockT, xP), "ptr to non-nil value is not empty") -} - -func TestNotEmpty(t *testing.T) { - - mockT := new(testing.T) - chWithValue := make(chan struct{}, 1) - chWithValue <- struct{}{} - - False(t, NotEmpty(mockT, ""), "Empty string is empty") - False(t, NotEmpty(mockT, nil), "Nil is empty") - False(t, NotEmpty(mockT, []string{}), "Empty string array is empty") - False(t, NotEmpty(mockT, 0), "Zero int value is empty") - False(t, NotEmpty(mockT, false), "False value is empty") - False(t, NotEmpty(mockT, make(chan struct{})), "Channel without values is empty") - - True(t, NotEmpty(mockT, "something"), "Non Empty string is not empty") - True(t, NotEmpty(mockT, errors.New("something")), "Non nil object is not empty") - True(t, NotEmpty(mockT, []string{"something"}), "Non empty string array is not empty") - True(t, NotEmpty(mockT, 1), "Non-zero int value is not empty") - True(t, NotEmpty(mockT, true), "True value is not empty") - True(t, NotEmpty(mockT, chWithValue), "Channel with values is not empty") -} - -func Test_getLen(t *testing.T) { - falseCases := []interface{}{ - nil, - 0, - true, - false, - 'A', - struct{}{}, - } - for _, v := range falseCases { - ok, l := getLen(v) - False(t, ok, "Expected getLen fail to get length of %#v", v) - Equal(t, 0, l, "getLen should return 0 for %#v", v) - } - - ch := make(chan int, 5) - ch <- 1 - ch <- 2 - ch <- 3 - trueCases := []struct { - v interface{} - l int - }{ - {[]int{1, 2, 3}, 3}, - {[...]int{1, 2, 3}, 3}, - {"ABC", 3}, - {map[int]int{1: 2, 2: 4, 3: 6}, 3}, - {ch, 3}, - - {[]int{}, 0}, - {map[int]int{}, 0}, - {make(chan int), 0}, - - {[]int(nil), 0}, - {map[int]int(nil), 0}, - {(chan int)(nil), 0}, - } - - for _, c := range trueCases { - ok, l := getLen(c.v) - True(t, ok, "Expected getLen success to get length of %#v", c.v) - Equal(t, c.l, l) - } -} - -func TestLen(t *testing.T) { - mockT := new(testing.T) - - False(t, Len(mockT, nil, 0), "nil does not have length") - False(t, Len(mockT, 0, 0), "int does not have length") - False(t, Len(mockT, true, 0), "true does not have length") - False(t, Len(mockT, false, 0), "false does not have length") - False(t, Len(mockT, 'A', 0), "Rune does not have length") - False(t, Len(mockT, struct{}{}, 0), "Struct does not have length") - - ch := make(chan int, 5) - ch <- 1 - ch <- 2 - ch <- 3 - - cases := []struct { - v interface{} - l int - }{ - {[]int{1, 2, 3}, 3}, - {[...]int{1, 2, 3}, 3}, - {"ABC", 3}, - {map[int]int{1: 2, 2: 4, 3: 6}, 3}, - {ch, 3}, - - {[]int{}, 0}, - {map[int]int{}, 0}, - {make(chan int), 0}, - - {[]int(nil), 0}, - {map[int]int(nil), 0}, - {(chan int)(nil), 0}, - } - - for _, c := range cases { - True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) - } - - cases = []struct { - v interface{} - l int - }{ - {[]int{1, 2, 3}, 4}, - {[...]int{1, 2, 3}, 2}, - {"ABC", 2}, - {map[int]int{1: 2, 2: 4, 3: 6}, 4}, - {ch, 2}, - - {[]int{}, 1}, - {map[int]int{}, 1}, - {make(chan int), 1}, - - {[]int(nil), 1}, - {map[int]int(nil), 1}, - {(chan int)(nil), 1}, - } - - for _, c := range cases { - False(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) - } -} - -func TestWithinDuration(t *testing.T) { - - mockT := new(testing.T) - a := time.Now() - b := a.Add(10 * time.Second) - - True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference") - True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference") - - False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") - False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") - - False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") - False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") - - False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") - False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") -} - -func TestInDelta(t *testing.T) { - mockT := new(testing.T) - - True(t, InDelta(mockT, 1.001, 1, 0.01), "|1.001 - 1| <= 0.01") - True(t, InDelta(mockT, 1, 1.001, 0.01), "|1 - 1.001| <= 0.01") - True(t, InDelta(mockT, 1, 2, 1), "|1 - 2| <= 1") - False(t, InDelta(mockT, 1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") - False(t, InDelta(mockT, 2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") - False(t, InDelta(mockT, "", nil, 1), "Expected non numerals to fail") - False(t, InDelta(mockT, 42, math.NaN(), 0.01), "Expected NaN for actual to fail") - False(t, InDelta(mockT, math.NaN(), 42, 0.01), "Expected NaN for expected to fail") - - cases := []struct { - a, b interface{} - delta float64 - }{ - {uint8(2), uint8(1), 1}, - {uint16(2), uint16(1), 1}, - {uint32(2), uint32(1), 1}, - {uint64(2), uint64(1), 1}, - - {int(2), int(1), 1}, - {int8(2), int8(1), 1}, - {int16(2), int16(1), 1}, - {int32(2), int32(1), 1}, - {int64(2), int64(1), 1}, - - {float32(2), float32(1), 1}, - {float64(2), float64(1), 1}, - } - - for _, tc := range cases { - True(t, InDelta(mockT, tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) - } -} - -func TestInDeltaSlice(t *testing.T) { - mockT := new(testing.T) - - True(t, InDeltaSlice(mockT, - []float64{1.001, 0.999}, - []float64{1, 1}, - 0.1), "{1.001, 0.009} is element-wise close to {1, 1} in delta=0.1") - - True(t, InDeltaSlice(mockT, - []float64{1, 2}, - []float64{0, 3}, - 1), "{1, 2} is element-wise close to {0, 3} in delta=1") - - False(t, InDeltaSlice(mockT, - []float64{1, 2}, - []float64{0, 3}, - 0.1), "{1, 2} is not element-wise close to {0, 3} in delta=0.1") - - False(t, InDeltaSlice(mockT, "", nil, 1), "Expected non numeral slices to fail") -} - -func TestInDeltaMapValues(t *testing.T) { - mockT := new(testing.T) - - for _, tc := range []struct { - title string - expect interface{} - actual interface{} - f func(TestingT, bool, ...interface{}) bool - delta float64 - }{ - { - title: "Within delta", - expect: map[string]float64{ - "foo": 1.0, - "bar": 2.0, - }, - actual: map[string]float64{ - "foo": 1.01, - "bar": 1.99, - }, - delta: 0.1, - f: True, - }, - { - title: "Within delta", - expect: map[int]float64{ - 1: 1.0, - 2: 2.0, - }, - actual: map[int]float64{ - 1: 1.0, - 2: 1.99, - }, - delta: 0.1, - f: True, - }, - { - title: "Different number of keys", - expect: map[int]float64{ - 1: 1.0, - 2: 2.0, - }, - actual: map[int]float64{ - 1: 1.0, - }, - delta: 0.1, - f: False, - }, - { - title: "Within delta with zero value", - expect: map[string]float64{ - "zero": 0.0, - }, - actual: map[string]float64{ - "zero": 0.0, - }, - delta: 0.1, - f: True, - }, - { - title: "With missing key with zero value", - expect: map[string]float64{ - "zero": 0.0, - "foo": 0.0, - }, - actual: map[string]float64{ - "zero": 0.0, - "bar": 0.0, - }, - f: False, - }, - } { - tc.f(t, InDeltaMapValues(mockT, tc.expect, tc.actual, tc.delta), tc.title+"\n"+diff(tc.expect, tc.actual)) - } -} - -func TestInEpsilon(t *testing.T) { - mockT := new(testing.T) - - cases := []struct { - a, b interface{} - epsilon float64 - }{ - {uint8(2), uint16(2), .001}, - {2.1, 2.2, 0.1}, - {2.2, 2.1, 0.1}, - {-2.1, -2.2, 0.1}, - {-2.2, -2.1, 0.1}, - {uint64(100), uint8(101), 0.01}, - {0.1, -0.1, 2}, - {0.1, 0, 2}, - {time.Second, time.Second + time.Millisecond, 0.002}, - } - - for _, tc := range cases { - True(t, InEpsilon(t, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon), "test: %q", tc) - } - - cases = []struct { - a, b interface{} - epsilon float64 - }{ - {uint8(2), int16(-2), .001}, - {uint64(100), uint8(102), 0.01}, - {2.1, 2.2, 0.001}, - {2.2, 2.1, 0.001}, - {2.1, -2.2, 1}, - {2.1, "bla-bla", 0}, - {0.1, -0.1, 1.99}, - {0, 0.1, 2}, // expected must be different to zero - {time.Second, time.Second + 10*time.Millisecond, 0.002}, - } - - for _, tc := range cases { - False(t, InEpsilon(mockT, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) - } - -} - -func TestInEpsilonSlice(t *testing.T) { - mockT := new(testing.T) - - True(t, InEpsilonSlice(mockT, - []float64{2.2, 2.0}, - []float64{2.1, 2.1}, - 0.06), "{2.2, 2.0} is element-wise close to {2.1, 2.1} in espilon=0.06") - - False(t, InEpsilonSlice(mockT, - []float64{2.2, 2.0}, - []float64{2.1, 2.1}, - 0.04), "{2.2, 2.0} is not element-wise close to {2.1, 2.1} in espilon=0.04") - - False(t, InEpsilonSlice(mockT, "", nil, 1), "Expected non numeral slices to fail") -} - -func TestRegexp(t *testing.T) { - mockT := new(testing.T) - - cases := []struct { - rx, str string - }{ - {"^start", "start of the line"}, - {"end$", "in the end"}, - {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, - } - - for _, tc := range cases { - True(t, Regexp(mockT, tc.rx, tc.str)) - True(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) - False(t, NotRegexp(mockT, tc.rx, tc.str)) - False(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) - } - - cases = []struct { - rx, str string - }{ - {"^asdfastart", "Not the start of the line"}, - {"end$", "in the end."}, - {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, - } - - for _, tc := range cases { - False(t, Regexp(mockT, tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) - False(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) - True(t, NotRegexp(mockT, tc.rx, tc.str)) - True(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) - } -} - -func testAutogeneratedFunction() { - defer func() { - if err := recover(); err == nil { - panic("did not panic") - } - CallerInfo() - }() - t := struct { - io.Closer - }{} - var c io.Closer - c = t - c.Close() -} - -func TestCallerInfoWithAutogeneratedFunctions(t *testing.T) { - NotPanics(t, func() { - testAutogeneratedFunction() - }) -} - -func TestZero(t *testing.T) { - mockT := new(testing.T) - - for _, test := range zeros { - True(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) - } - - for _, test := range nonZeros { - False(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) - } -} - -func TestNotZero(t *testing.T) { - mockT := new(testing.T) - - for _, test := range zeros { - False(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) - } - - for _, test := range nonZeros { - True(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) - } -} - -func TestFileExists(t *testing.T) { - mockT := new(testing.T) - True(t, FileExists(mockT, "assertions.go")) - - mockT = new(testing.T) - False(t, FileExists(mockT, "random_file")) - - mockT = new(testing.T) - False(t, FileExists(mockT, "../_codegen")) -} - -func TestDirExists(t *testing.T) { - mockT := new(testing.T) - False(t, DirExists(mockT, "assertions.go")) - - mockT = new(testing.T) - False(t, DirExists(mockT, "random_dir")) - - mockT = new(testing.T) - True(t, DirExists(mockT, "../_codegen")) -} - -func TestJSONEq_EqualSONString(t *testing.T) { - mockT := new(testing.T) - True(t, JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`)) -} - -func TestJSONEq_EquivalentButNotEqual(t *testing.T) { - mockT := new(testing.T) - True(t, JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)) -} - -func TestJSONEq_HashOfArraysAndHashes(t *testing.T) { - mockT := new(testing.T) - True(t, JSONEq(mockT, "{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", - "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}")) -} - -func TestJSONEq_Array(t *testing.T) { - mockT := new(testing.T) - True(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`)) -} - -func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`)) -} - -func TestJSONEq_HashesNotEquivalent(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)) -} - -func TestJSONEq_ActualIsNotJSON(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, `{"foo": "bar"}`, "Not JSON")) -} - -func TestJSONEq_ExpectedIsNotJSON(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, "Not JSON", `{"foo": "bar", "hello": "world"}`)) -} - -func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, "Not JSON", "Not JSON")) -} - -func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) { - mockT := new(testing.T) - False(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`)) -} - -func TestDiff(t *testing.T) { - expected := ` - -Diff: ---- Expected -+++ Actual -@@ -1,3 +1,3 @@ - (struct { foo string }) { -- foo: (string) (len=5) "hello" -+ foo: (string) (len=3) "bar" - } -` - actual := diff( - struct{ foo string }{"hello"}, - struct{ foo string }{"bar"}, - ) - Equal(t, expected, actual) - - expected = ` - -Diff: ---- Expected -+++ Actual -@@ -2,5 +2,5 @@ - (int) 1, -- (int) 2, - (int) 3, -- (int) 4 -+ (int) 5, -+ (int) 7 - } -` - actual = diff( - []int{1, 2, 3, 4}, - []int{1, 3, 5, 7}, - ) - Equal(t, expected, actual) - - expected = ` - -Diff: ---- Expected -+++ Actual -@@ -2,4 +2,4 @@ - (int) 1, -- (int) 2, -- (int) 3 -+ (int) 3, -+ (int) 5 - } -` - actual = diff( - []int{1, 2, 3, 4}[0:3], - []int{1, 3, 5, 7}[0:3], - ) - Equal(t, expected, actual) - - expected = ` - -Diff: ---- Expected -+++ Actual -@@ -1,6 +1,6 @@ - (map[string]int) (len=4) { -- (string) (len=4) "four": (int) 4, -+ (string) (len=4) "five": (int) 5, - (string) (len=3) "one": (int) 1, -- (string) (len=5) "three": (int) 3, -- (string) (len=3) "two": (int) 2 -+ (string) (len=5) "seven": (int) 7, -+ (string) (len=5) "three": (int) 3 - } -` - - actual = diff( - map[string]int{"one": 1, "two": 2, "three": 3, "four": 4}, - map[string]int{"one": 1, "three": 3, "five": 5, "seven": 7}, - ) - Equal(t, expected, actual) -} - -func TestDiffEmptyCases(t *testing.T) { - Equal(t, "", diff(nil, nil)) - Equal(t, "", diff(struct{ foo string }{}, nil)) - Equal(t, "", diff(nil, struct{ foo string }{})) - Equal(t, "", diff(1, 2)) - Equal(t, "", diff(1, 2)) - Equal(t, "", diff([]int{1}, []bool{true})) -} - -// Ensure there are no data races -func TestDiffRace(t *testing.T) { - t.Parallel() - - expected := map[string]string{ - "a": "A", - "b": "B", - "c": "C", - } - - actual := map[string]string{ - "d": "D", - "e": "E", - "f": "F", - } - - // run diffs in parallel simulating tests with t.Parallel() - numRoutines := 10 - rChans := make([]chan string, numRoutines) - for idx := range rChans { - rChans[idx] = make(chan string) - go func(ch chan string) { - defer close(ch) - ch <- diff(expected, actual) - }(rChans[idx]) - } - - for _, ch := range rChans { - for msg := range ch { - NotZero(t, msg) // dummy assert - } - } -} - -type mockTestingT struct { -} - -func (m *mockTestingT) Errorf(format string, args ...interface{}) {} - -func TestFailNowWithPlainTestingT(t *testing.T) { - mockT := &mockTestingT{} - - Panics(t, func() { - FailNow(mockT, "failed") - }, "should panic since mockT is missing FailNow()") -} - -type mockFailNowTestingT struct { -} - -func (m *mockFailNowTestingT) Errorf(format string, args ...interface{}) {} - -func (m *mockFailNowTestingT) FailNow() {} - -func TestFailNowWithFullTestingT(t *testing.T) { - mockT := &mockFailNowTestingT{} - - NotPanics(t, func() { - FailNow(mockT, "failed") - }, "should call mockT.FailNow() rather than panicking") -} - -func TestBytesEqual(t *testing.T) { - var cases = []struct { - a, b []byte - }{ - {make([]byte, 2), make([]byte, 2)}, - {make([]byte, 2), make([]byte, 2, 3)}, - {nil, make([]byte, 0)}, - } - for i, c := range cases { - Equal(t, reflect.DeepEqual(c.a, c.b), ObjectsAreEqual(c.a, c.b), "case %d failed", i+1) - } -} - -func BenchmarkBytesEqual(b *testing.B) { - const size = 1024 * 8 - s := make([]byte, size) - for i := range s { - s[i] = byte(i % 255) - } - s2 := make([]byte, size) - copy(s2, s) - - mockT := &mockFailNowTestingT{} - b.ResetTimer() - for i := 0; i < b.N; i++ { - Equal(mockT, s, s2) - } -} - -func TestEqualArgsValidation(t *testing.T) { - err := validateEqualArgs(time.Now, time.Now) - EqualError(t, err, "cannot take func type as argument") -} - -func ExampleComparisonAssertionFunc() { - t := &testing.T{} // provided by test - - adder := func(x, y int) int { - return x + y - } - - type args struct { - x int - y int - } - - tests := []struct { - name string - args args - expect int - assertion ComparisonAssertionFunc - }{ - {"2+2=4", args{2, 2}, 4, Equal}, - {"2+2!=5", args{2, 2}, 5, NotEqual}, - {"2+3==5", args{2, 3}, 5, Exactly}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y)) - }) - } -} - -func TestComparisonAssertionFunc(t *testing.T) { - type iface interface { - Name() string - } - - tests := []struct { - name string - expect interface{} - got interface{} - assertion ComparisonAssertionFunc - }{ - {"implements", (*iface)(nil), t, Implements}, - {"isType", (*testing.T)(nil), t, IsType}, - {"equal", t, t, Equal}, - {"equalValues", t, t, EqualValues}, - {"exactly", t, t, Exactly}, - {"notEqual", t, nil, NotEqual}, - {"notContains", []int{1, 2, 3}, 4, NotContains}, - {"subset", []int{1, 2, 3, 4}, []int{2, 3}, Subset}, - {"notSubset", []int{1, 2, 3, 4}, []int{0, 3}, NotSubset}, - {"elementsMatch", []byte("abc"), []byte("bac"), ElementsMatch}, - {"regexp", "^t.*y$", "testify", Regexp}, - {"notRegexp", "^t.*y$", "Testify", NotRegexp}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.expect, tt.got) - }) - } -} - -func ExampleValueAssertionFunc() { - t := &testing.T{} // provided by test - - dumbParse := func(input string) interface{} { - var x interface{} - json.Unmarshal([]byte(input), &x) - return x - } - - tests := []struct { - name string - arg string - assertion ValueAssertionFunc - }{ - {"true is not nil", "true", NotNil}, - {"empty string is nil", "", Nil}, - {"zero is not nil", "0", NotNil}, - {"zero is zero", "0", Zero}, - {"false is zero", "false", Zero}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, dumbParse(tt.arg)) - }) - } -} - -func TestValueAssertionFunc(t *testing.T) { - tests := []struct { - name string - value interface{} - assertion ValueAssertionFunc - }{ - {"notNil", true, NotNil}, - {"nil", nil, Nil}, - {"empty", []int{}, Empty}, - {"notEmpty", []int{1}, NotEmpty}, - {"zero", false, Zero}, - {"notZero", 42, NotZero}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.value) - }) - } -} - -func ExampleBoolAssertionFunc() { - t := &testing.T{} // provided by test - - isOkay := func(x int) bool { - return x >= 42 - } - - tests := []struct { - name string - arg int - assertion BoolAssertionFunc - }{ - {"-1 is bad", -1, False}, - {"42 is good", 42, True}, - {"41 is bad", 41, False}, - {"45 is cool", 45, True}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, isOkay(tt.arg)) - }) - } -} - -func TestBoolAssertionFunc(t *testing.T) { - tests := []struct { - name string - value bool - assertion BoolAssertionFunc - }{ - {"true", true, True}, - {"false", false, False}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.value) - }) - } -} - -func ExampleErrorAssertionFunc() { - t := &testing.T{} // provided by test - - dumbParseNum := func(input string, v interface{}) error { - return json.Unmarshal([]byte(input), v) - } - - tests := []struct { - name string - arg string - assertion ErrorAssertionFunc - }{ - {"1.2 is number", "1.2", NoError}, - {"1.2.3 not number", "1.2.3", Error}, - {"true is not number", "true", Error}, - {"3 is number", "3", NoError}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var x float64 - tt.assertion(t, dumbParseNum(tt.arg, &x)) - }) - } -} - -func TestErrorAssertionFunc(t *testing.T) { - tests := []struct { - name string - err error - assertion ErrorAssertionFunc - }{ - {"noError", nil, NoError}, - {"error", errors.New("whoops"), Error}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.err) - }) - } -} diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go deleted file mode 100644 index c9dccc4..0000000 --- a/vendor/github.com/stretchr/testify/assert/doc.go +++ /dev/null @@ -1,45 +0,0 @@ -// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. -// -// Example Usage -// -// The following is a complete example using assert in a standard test function: -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) -// -// func TestSomething(t *testing.T) { -// -// var a string = "Hello" -// var b string = "Hello" -// -// assert.Equal(t, a, b, "The two words should be the same.") -// -// } -// -// if you assert many times, use the format below: -// -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) -// -// func TestSomething(t *testing.T) { -// assert := assert.New(t) -// -// var a string = "Hello" -// var b string = "Hello" -// -// assert.Equal(a, b, "The two words should be the same.") -// } -// -// Assertions -// -// Assertions allow you to easily write test code, and are global funcs in the `assert` package. -// All assertion functions take, as the first argument, the `*testing.T` object provided by the -// testing framework. This allows the assertion funcs to write the failings and other details to -// the correct place. -// -// Every assertion function also takes an optional string message as the final argument, -// allowing custom error messages to be appended to the message the assertion method outputs. -package assert diff --git a/vendor/github.com/stretchr/testify/assert/errors.go b/vendor/github.com/stretchr/testify/assert/errors.go deleted file mode 100644 index ac9dc9d..0000000 --- a/vendor/github.com/stretchr/testify/assert/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package assert - -import ( - "errors" -) - -// AnError is an error instance useful for testing. If the code does not care -// about error specifics, and only needs to return the error for example, this -// error should be used to make the test code more readable. -var AnError = errors.New("assert.AnError general error for testing") diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions.go b/vendor/github.com/stretchr/testify/assert/forward_assertions.go deleted file mode 100644 index 9ad5685..0000000 --- a/vendor/github.com/stretchr/testify/assert/forward_assertions.go +++ /dev/null @@ -1,16 +0,0 @@ -package assert - -// Assertions provides assertion methods around the -// TestingT interface. -type Assertions struct { - t TestingT -} - -// New makes a new Assertions object for the specified TestingT. -func New(t TestingT) *Assertions { - return &Assertions{ - t: t, - } -} - -//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go b/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go deleted file mode 100644 index 22e1df1..0000000 --- a/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go +++ /dev/null @@ -1,611 +0,0 @@ -package assert - -import ( - "errors" - "regexp" - "testing" - "time" -) - -func TestImplementsWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { - t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") - } - if assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { - t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") - } -} - -func TestIsTypeWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { - t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") - } - if assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { - t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") - } - -} - -func TestEqualWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.Equal("Hello World", "Hello World") { - t.Error("Equal should return true") - } - if !assert.Equal(123, 123) { - t.Error("Equal should return true") - } - if !assert.Equal(123.5, 123.5) { - t.Error("Equal should return true") - } - if !assert.Equal([]byte("Hello World"), []byte("Hello World")) { - t.Error("Equal should return true") - } - if !assert.Equal(nil, nil) { - t.Error("Equal should return true") - } -} - -func TestEqualValuesWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.EqualValues(uint32(10), int32(10)) { - t.Error("EqualValues should return true") - } -} - -func TestNotNilWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.NotNil(new(AssertionTesterConformingObject)) { - t.Error("NotNil should return true: object is not nil") - } - if assert.NotNil(nil) { - t.Error("NotNil should return false: object is nil") - } - -} - -func TestNilWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.Nil(nil) { - t.Error("Nil should return true: object is nil") - } - if assert.Nil(new(AssertionTesterConformingObject)) { - t.Error("Nil should return false: object is not nil") - } - -} - -func TestTrueWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.True(true) { - t.Error("True should return true") - } - if assert.True(false) { - t.Error("True should return false") - } - -} - -func TestFalseWrapper(t *testing.T) { - assert := New(new(testing.T)) - - if !assert.False(false) { - t.Error("False should return true") - } - if assert.False(true) { - t.Error("False should return false") - } - -} - -func TestExactlyWrapper(t *testing.T) { - assert := New(new(testing.T)) - - a := float32(1) - b := float64(1) - c := float32(1) - d := float32(2) - - if assert.Exactly(a, b) { - t.Error("Exactly should return false") - } - if assert.Exactly(a, d) { - t.Error("Exactly should return false") - } - if !assert.Exactly(a, c) { - t.Error("Exactly should return true") - } - - if assert.Exactly(nil, a) { - t.Error("Exactly should return false") - } - if assert.Exactly(a, nil) { - t.Error("Exactly should return false") - } - -} - -func TestNotEqualWrapper(t *testing.T) { - - assert := New(new(testing.T)) - - if !assert.NotEqual("Hello World", "Hello World!") { - t.Error("NotEqual should return true") - } - if !assert.NotEqual(123, 1234) { - t.Error("NotEqual should return true") - } - if !assert.NotEqual(123.5, 123.55) { - t.Error("NotEqual should return true") - } - if !assert.NotEqual([]byte("Hello World"), []byte("Hello World!")) { - t.Error("NotEqual should return true") - } - if !assert.NotEqual(nil, new(AssertionTesterConformingObject)) { - t.Error("NotEqual should return true") - } -} - -func TestContainsWrapper(t *testing.T) { - - assert := New(new(testing.T)) - list := []string{"Foo", "Bar"} - - if !assert.Contains("Hello World", "Hello") { - t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") - } - if assert.Contains("Hello World", "Salut") { - t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") - } - - if !assert.Contains(list, "Foo") { - t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") - } - if assert.Contains(list, "Salut") { - t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") - } - -} - -func TestNotContainsWrapper(t *testing.T) { - - assert := New(new(testing.T)) - list := []string{"Foo", "Bar"} - - if !assert.NotContains("Hello World", "Hello!") { - t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") - } - if assert.NotContains("Hello World", "Hello") { - t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") - } - - if !assert.NotContains(list, "Foo!") { - t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") - } - if assert.NotContains(list, "Foo") { - t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") - } - -} - -func TestConditionWrapper(t *testing.T) { - - assert := New(new(testing.T)) - - if !assert.Condition(func() bool { return true }, "Truth") { - t.Error("Condition should return true") - } - - if assert.Condition(func() bool { return false }, "Lie") { - t.Error("Condition should return false") - } - -} - -func TestDidPanicWrapper(t *testing.T) { - - if funcDidPanic, _ := didPanic(func() { - panic("Panic!") - }); !funcDidPanic { - t.Error("didPanic should return true") - } - - if funcDidPanic, _ := didPanic(func() { - }); funcDidPanic { - t.Error("didPanic should return false") - } - -} - -func TestPanicsWrapper(t *testing.T) { - - assert := New(new(testing.T)) - - if !assert.Panics(func() { - panic("Panic!") - }) { - t.Error("Panics should return true") - } - - if assert.Panics(func() { - }) { - t.Error("Panics should return false") - } - -} - -func TestNotPanicsWrapper(t *testing.T) { - - assert := New(new(testing.T)) - - if !assert.NotPanics(func() { - }) { - t.Error("NotPanics should return true") - } - - if assert.NotPanics(func() { - panic("Panic!") - }) { - t.Error("NotPanics should return false") - } - -} - -func TestNoErrorWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - // start with a nil error - var err error - - assert.True(mockAssert.NoError(err), "NoError should return True for nil arg") - - // now set an error - err = errors.New("Some error") - - assert.False(mockAssert.NoError(err), "NoError with error should return False") - -} - -func TestErrorWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - // start with a nil error - var err error - - assert.False(mockAssert.Error(err), "Error should return False for nil arg") - - // now set an error - err = errors.New("Some error") - - assert.True(mockAssert.Error(err), "Error with error should return True") - -} - -func TestEqualErrorWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - // start with a nil error - var err error - assert.False(mockAssert.EqualError(err, ""), - "EqualError should return false for nil arg") - - // now set an error - err = errors.New("some error") - assert.False(mockAssert.EqualError(err, "Not some error"), - "EqualError should return false for different error string") - assert.True(mockAssert.EqualError(err, "some error"), - "EqualError should return true") -} - -func TestEmptyWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - assert.True(mockAssert.Empty(""), "Empty string is empty") - assert.True(mockAssert.Empty(nil), "Nil is empty") - assert.True(mockAssert.Empty([]string{}), "Empty string array is empty") - assert.True(mockAssert.Empty(0), "Zero int value is empty") - assert.True(mockAssert.Empty(false), "False value is empty") - - assert.False(mockAssert.Empty("something"), "Non Empty string is not empty") - assert.False(mockAssert.Empty(errors.New("something")), "Non nil object is not empty") - assert.False(mockAssert.Empty([]string{"something"}), "Non empty string array is not empty") - assert.False(mockAssert.Empty(1), "Non-zero int value is not empty") - assert.False(mockAssert.Empty(true), "True value is not empty") - -} - -func TestNotEmptyWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - assert.False(mockAssert.NotEmpty(""), "Empty string is empty") - assert.False(mockAssert.NotEmpty(nil), "Nil is empty") - assert.False(mockAssert.NotEmpty([]string{}), "Empty string array is empty") - assert.False(mockAssert.NotEmpty(0), "Zero int value is empty") - assert.False(mockAssert.NotEmpty(false), "False value is empty") - - assert.True(mockAssert.NotEmpty("something"), "Non Empty string is not empty") - assert.True(mockAssert.NotEmpty(errors.New("something")), "Non nil object is not empty") - assert.True(mockAssert.NotEmpty([]string{"something"}), "Non empty string array is not empty") - assert.True(mockAssert.NotEmpty(1), "Non-zero int value is not empty") - assert.True(mockAssert.NotEmpty(true), "True value is not empty") - -} - -func TestLenWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - assert.False(mockAssert.Len(nil, 0), "nil does not have length") - assert.False(mockAssert.Len(0, 0), "int does not have length") - assert.False(mockAssert.Len(true, 0), "true does not have length") - assert.False(mockAssert.Len(false, 0), "false does not have length") - assert.False(mockAssert.Len('A', 0), "Rune does not have length") - assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length") - - ch := make(chan int, 5) - ch <- 1 - ch <- 2 - ch <- 3 - - cases := []struct { - v interface{} - l int - }{ - {[]int{1, 2, 3}, 3}, - {[...]int{1, 2, 3}, 3}, - {"ABC", 3}, - {map[int]int{1: 2, 2: 4, 3: 6}, 3}, - {ch, 3}, - - {[]int{}, 0}, - {map[int]int{}, 0}, - {make(chan int), 0}, - - {[]int(nil), 0}, - {map[int]int(nil), 0}, - {(chan int)(nil), 0}, - } - - for _, c := range cases { - assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l) - } -} - -func TestWithinDurationWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - a := time.Now() - b := a.Add(10 * time.Second) - - assert.True(mockAssert.WithinDuration(a, b, 10*time.Second), "A 10s difference is within a 10s time difference") - assert.True(mockAssert.WithinDuration(b, a, 10*time.Second), "A 10s difference is within a 10s time difference") - - assert.False(mockAssert.WithinDuration(a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") - assert.False(mockAssert.WithinDuration(b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") - - assert.False(mockAssert.WithinDuration(a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") - assert.False(mockAssert.WithinDuration(b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") - - assert.False(mockAssert.WithinDuration(a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") - assert.False(mockAssert.WithinDuration(b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") -} - -func TestInDeltaWrapper(t *testing.T) { - assert := New(new(testing.T)) - - True(t, assert.InDelta(1.001, 1, 0.01), "|1.001 - 1| <= 0.01") - True(t, assert.InDelta(1, 1.001, 0.01), "|1 - 1.001| <= 0.01") - True(t, assert.InDelta(1, 2, 1), "|1 - 2| <= 1") - False(t, assert.InDelta(1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") - False(t, assert.InDelta(2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") - False(t, assert.InDelta("", nil, 1), "Expected non numerals to fail") - - cases := []struct { - a, b interface{} - delta float64 - }{ - {uint8(2), uint8(1), 1}, - {uint16(2), uint16(1), 1}, - {uint32(2), uint32(1), 1}, - {uint64(2), uint64(1), 1}, - - {int(2), int(1), 1}, - {int8(2), int8(1), 1}, - {int16(2), int16(1), 1}, - {int32(2), int32(1), 1}, - {int64(2), int64(1), 1}, - - {float32(2), float32(1), 1}, - {float64(2), float64(1), 1}, - } - - for _, tc := range cases { - True(t, assert.InDelta(tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) - } -} - -func TestInEpsilonWrapper(t *testing.T) { - assert := New(new(testing.T)) - - cases := []struct { - a, b interface{} - epsilon float64 - }{ - {uint8(2), uint16(2), .001}, - {2.1, 2.2, 0.1}, - {2.2, 2.1, 0.1}, - {-2.1, -2.2, 0.1}, - {-2.2, -2.1, 0.1}, - {uint64(100), uint8(101), 0.01}, - {0.1, -0.1, 2}, - } - - for _, tc := range cases { - True(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) - } - - cases = []struct { - a, b interface{} - epsilon float64 - }{ - {uint8(2), int16(-2), .001}, - {uint64(100), uint8(102), 0.01}, - {2.1, 2.2, 0.001}, - {2.2, 2.1, 0.001}, - {2.1, -2.2, 1}, - {2.1, "bla-bla", 0}, - {0.1, -0.1, 1.99}, - } - - for _, tc := range cases { - False(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) - } -} - -func TestRegexpWrapper(t *testing.T) { - - assert := New(new(testing.T)) - - cases := []struct { - rx, str string - }{ - {"^start", "start of the line"}, - {"end$", "in the end"}, - {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, - } - - for _, tc := range cases { - True(t, assert.Regexp(tc.rx, tc.str)) - True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) - False(t, assert.NotRegexp(tc.rx, tc.str)) - False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) - } - - cases = []struct { - rx, str string - }{ - {"^asdfastart", "Not the start of the line"}, - {"end$", "in the end."}, - {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, - } - - for _, tc := range cases { - False(t, assert.Regexp(tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) - False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) - True(t, assert.NotRegexp(tc.rx, tc.str)) - True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) - } -} - -func TestZeroWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - for _, test := range zeros { - assert.True(mockAssert.Zero(test), "Zero should return true for %v", test) - } - - for _, test := range nonZeros { - assert.False(mockAssert.Zero(test), "Zero should return false for %v", test) - } -} - -func TestNotZeroWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - for _, test := range zeros { - assert.False(mockAssert.NotZero(test), "Zero should return true for %v", test) - } - - for _, test := range nonZeros { - assert.True(mockAssert.NotZero(test), "Zero should return false for %v", test) - } -} - -func TestJSONEqWrapper_EqualSONString(t *testing.T) { - assert := New(new(testing.T)) - if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) { - t.Error("JSONEq should return true") - } - -} - -func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) { - assert := New(new(testing.T)) - if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) { - t.Error("JSONEq should return true") - } - -} - -func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) { - assert := New(new(testing.T)) - if !assert.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", - "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") { - t.Error("JSONEq should return true") - } -} - -func TestJSONEqWrapper_Array(t *testing.T) { - assert := New(new(testing.T)) - if !assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) { - t.Error("JSONEq should return true") - } - -} - -func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) { - t.Error("JSONEq should return false") - } -} - -func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) { - t.Error("JSONEq should return false") - } -} - -func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq(`{"foo": "bar"}`, "Not JSON") { - t.Error("JSONEq should return false") - } -} - -func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`) { - t.Error("JSONEq should return false") - } -} - -func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq("Not JSON", "Not JSON") { - t.Error("JSONEq should return false") - } -} - -func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) { - assert := New(new(testing.T)) - if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) { - t.Error("JSONEq should return false") - } -} diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go deleted file mode 100644 index df46fa7..0000000 --- a/vendor/github.com/stretchr/testify/assert/http_assertions.go +++ /dev/null @@ -1,143 +0,0 @@ -package assert - -import ( - "fmt" - "net/http" - "net/http/httptest" - "net/url" - "strings" -) - -// httpCode is a helper that returns HTTP code of the response. It returns -1 and -// an error if building a new request fails. -func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { - w := httptest.NewRecorder() - req, err := http.NewRequest(method, url, nil) - if err != nil { - return -1, err - } - req.URL.RawQuery = values.Encode() - handler(w, req) - return w.Code, nil -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent - if !isSuccessCode { - Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isSuccessCode -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect - if !isRedirectCode { - Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isRedirectCode -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - code, err := httpCode(handler, method, url, values) - if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) - return false - } - - isErrorCode := code >= http.StatusBadRequest - if !isErrorCode { - Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) - } - - return isErrorCode -} - -// HTTPBody is a helper that returns HTTP body of the response. It returns -// empty string if building a new request fails. -func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { - w := httptest.NewRecorder() - req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) - if err != nil { - return "" - } - handler(w, req) - return w.Body.String() -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - body := HTTPBody(handler, method, url, values) - - contains := strings.Contains(body, fmt.Sprint(str)) - if !contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) - } - - return contains -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - body := HTTPBody(handler, method, url, values) - - contains := strings.Contains(body, fmt.Sprint(str)) - if contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) - } - - return !contains -} diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions_test.go b/vendor/github.com/stretchr/testify/assert/http_assertions_test.go deleted file mode 100644 index 112beaf..0000000 --- a/vendor/github.com/stretchr/testify/assert/http_assertions_test.go +++ /dev/null @@ -1,146 +0,0 @@ -package assert - -import ( - "fmt" - "net/http" - "net/url" - "testing" -) - -func httpOK(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) -} - -func httpRedirect(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusTemporaryRedirect) -} - -func httpError(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusInternalServerError) -} - -func TestHTTPSuccess(t *testing.T) { - assert := New(t) - - mockT1 := new(testing.T) - assert.Equal(HTTPSuccess(mockT1, httpOK, "GET", "/", nil), true) - assert.False(mockT1.Failed()) - - mockT2 := new(testing.T) - assert.Equal(HTTPSuccess(mockT2, httpRedirect, "GET", "/", nil), false) - assert.True(mockT2.Failed()) - - mockT3 := new(testing.T) - assert.Equal(HTTPSuccess(mockT3, httpError, "GET", "/", nil), false) - assert.True(mockT3.Failed()) -} - -func TestHTTPRedirect(t *testing.T) { - assert := New(t) - - mockT1 := new(testing.T) - assert.Equal(HTTPRedirect(mockT1, httpOK, "GET", "/", nil), false) - assert.True(mockT1.Failed()) - - mockT2 := new(testing.T) - assert.Equal(HTTPRedirect(mockT2, httpRedirect, "GET", "/", nil), true) - assert.False(mockT2.Failed()) - - mockT3 := new(testing.T) - assert.Equal(HTTPRedirect(mockT3, httpError, "GET", "/", nil), false) - assert.True(mockT3.Failed()) -} - -func TestHTTPError(t *testing.T) { - assert := New(t) - - mockT1 := new(testing.T) - assert.Equal(HTTPError(mockT1, httpOK, "GET", "/", nil), false) - assert.True(mockT1.Failed()) - - mockT2 := new(testing.T) - assert.Equal(HTTPError(mockT2, httpRedirect, "GET", "/", nil), false) - assert.True(mockT2.Failed()) - - mockT3 := new(testing.T) - assert.Equal(HTTPError(mockT3, httpError, "GET", "/", nil), true) - assert.False(mockT3.Failed()) -} - -func TestHTTPStatusesWrapper(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - assert.Equal(mockAssert.HTTPSuccess(httpOK, "GET", "/", nil), true) - assert.Equal(mockAssert.HTTPSuccess(httpRedirect, "GET", "/", nil), false) - assert.Equal(mockAssert.HTTPSuccess(httpError, "GET", "/", nil), false) - - assert.Equal(mockAssert.HTTPRedirect(httpOK, "GET", "/", nil), false) - assert.Equal(mockAssert.HTTPRedirect(httpRedirect, "GET", "/", nil), true) - assert.Equal(mockAssert.HTTPRedirect(httpError, "GET", "/", nil), false) - - assert.Equal(mockAssert.HTTPError(httpOK, "GET", "/", nil), false) - assert.Equal(mockAssert.HTTPError(httpRedirect, "GET", "/", nil), false) - assert.Equal(mockAssert.HTTPError(httpError, "GET", "/", nil), true) -} - -func httpHelloName(w http.ResponseWriter, r *http.Request) { - name := r.FormValue("name") - w.Write([]byte(fmt.Sprintf("Hello, %s!", name))) -} - -func TestHTTPRequestWithNoParams(t *testing.T) { - var got *http.Request - handler := func(w http.ResponseWriter, r *http.Request) { - got = r - w.WriteHeader(http.StatusOK) - } - - True(t, HTTPSuccess(t, handler, "GET", "/url", nil)) - - Empty(t, got.URL.Query()) - Equal(t, "/url", got.URL.RequestURI()) -} - -func TestHTTPRequestWithParams(t *testing.T) { - var got *http.Request - handler := func(w http.ResponseWriter, r *http.Request) { - got = r - w.WriteHeader(http.StatusOK) - } - params := url.Values{} - params.Add("id", "12345") - - True(t, HTTPSuccess(t, handler, "GET", "/url", params)) - - Equal(t, url.Values{"id": []string{"12345"}}, got.URL.Query()) - Equal(t, "/url?id=12345", got.URL.String()) - Equal(t, "/url?id=12345", got.URL.RequestURI()) -} - -func TestHttpBody(t *testing.T) { - assert := New(t) - mockT := new(testing.T) - - assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) - assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) - assert.False(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) - - assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) - assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) - assert.True(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) -} - -func TestHttpBodyWrappers(t *testing.T) { - assert := New(t) - mockAssert := New(new(testing.T)) - - assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) - assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) - assert.False(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) - - assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) - assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) - assert.True(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) - -} diff --git a/vendor/github.com/stretchr/testify/doc.go b/vendor/github.com/stretchr/testify/doc.go deleted file mode 100644 index 377d5cc..0000000 --- a/vendor/github.com/stretchr/testify/doc.go +++ /dev/null @@ -1,22 +0,0 @@ -// Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend. -// -// testify contains the following packages: -// -// The assert package provides a comprehensive set of assertion functions that tie in to the Go testing system. -// -// The http package contains tools to make it easier to test http activity using the Go testing system. -// -// The mock package provides a system by which it is possible to mock your objects and verify calls are happening as expected. -// -// The suite package provides a basic structure for using structs as testing suites, and methods on those structs as tests. It includes setup/teardown functionality in the way of interfaces. -package testify - -// blank imports help docs. -import ( - // assert package - _ "github.com/stretchr/testify/assert" - // http package - _ "github.com/stretchr/testify/http" - // mock package - _ "github.com/stretchr/testify/mock" -) diff --git a/vendor/github.com/stretchr/testify/http/doc.go b/vendor/github.com/stretchr/testify/http/doc.go deleted file mode 100644 index 695167c..0000000 --- a/vendor/github.com/stretchr/testify/http/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package http DEPRECATED USE net/http/httptest -package http diff --git a/vendor/github.com/stretchr/testify/http/test_response_writer.go b/vendor/github.com/stretchr/testify/http/test_response_writer.go deleted file mode 100644 index 5c3f813..0000000 --- a/vendor/github.com/stretchr/testify/http/test_response_writer.go +++ /dev/null @@ -1,49 +0,0 @@ -package http - -import ( - "net/http" -) - -// TestResponseWriter DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. -type TestResponseWriter struct { - - // StatusCode is the last int written by the call to WriteHeader(int) - StatusCode int - - // Output is a string containing the written bytes using the Write([]byte) func. - Output string - - // header is the internal storage of the http.Header object - header http.Header -} - -// Header DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. -func (rw *TestResponseWriter) Header() http.Header { - - if rw.header == nil { - rw.header = make(http.Header) - } - - return rw.header -} - -// Write DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. -func (rw *TestResponseWriter) Write(bytes []byte) (int, error) { - - // assume 200 success if no header has been set - if rw.StatusCode == 0 { - rw.WriteHeader(200) - } - - // add these bytes to the output string - rw.Output = rw.Output + string(bytes) - - // return normal values - return 0, nil - -} - -// WriteHeader DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. -func (rw *TestResponseWriter) WriteHeader(i int) { - rw.StatusCode = i -} diff --git a/vendor/github.com/stretchr/testify/http/test_round_tripper.go b/vendor/github.com/stretchr/testify/http/test_round_tripper.go deleted file mode 100644 index b1e32f1..0000000 --- a/vendor/github.com/stretchr/testify/http/test_round_tripper.go +++ /dev/null @@ -1,17 +0,0 @@ -package http - -import ( - "github.com/stretchr/testify/mock" - "net/http" -) - -// TestRoundTripper DEPRECATED USE net/http/httptest -type TestRoundTripper struct { - mock.Mock -} - -// RoundTrip DEPRECATED USE net/http/httptest -func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - args := t.Called(req) - return args.Get(0).(*http.Response), args.Error(1) -} diff --git a/vendor/github.com/stretchr/testify/mock/doc.go b/vendor/github.com/stretchr/testify/mock/doc.go deleted file mode 100644 index 7324128..0000000 --- a/vendor/github.com/stretchr/testify/mock/doc.go +++ /dev/null @@ -1,44 +0,0 @@ -// Package mock provides a system by which it is possible to mock your objects -// and verify calls are happening as expected. -// -// Example Usage -// -// The mock package provides an object, Mock, that tracks activity on another object. It is usually -// embedded into a test object as shown below: -// -// type MyTestObject struct { -// // add a Mock object instance -// mock.Mock -// -// // other fields go here as normal -// } -// -// When implementing the methods of an interface, you wire your functions up -// to call the Mock.Called(args...) method, and return the appropriate values. -// -// For example, to mock a method that saves the name and age of a person and returns -// the year of their birth or an error, you might write this: -// -// func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { -// args := o.Called(firstname, lastname, age) -// return args.Int(0), args.Error(1) -// } -// -// The Int, Error and Bool methods are examples of strongly typed getters that take the argument -// index position. Given this argument list: -// -// (12, true, "Something") -// -// You could read them out strongly typed like this: -// -// args.Int(0) -// args.Bool(1) -// args.String(2) -// -// For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: -// -// return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) -// -// This may cause a panic if the object you are getting is nil (the type assertion will fail), in those -// cases you should check for nil first. -package mock diff --git a/vendor/github.com/stretchr/testify/mock/mock.go b/vendor/github.com/stretchr/testify/mock/mock.go deleted file mode 100644 index cc4f642..0000000 --- a/vendor/github.com/stretchr/testify/mock/mock.go +++ /dev/null @@ -1,885 +0,0 @@ -package mock - -import ( - "errors" - "fmt" - "reflect" - "regexp" - "runtime" - "strings" - "sync" - "time" - - "github.com/davecgh/go-spew/spew" - "github.com/pmezard/go-difflib/difflib" - "github.com/stretchr/objx" - "github.com/stretchr/testify/assert" -) - -// TestingT is an interface wrapper around *testing.T -type TestingT interface { - Logf(format string, args ...interface{}) - Errorf(format string, args ...interface{}) - FailNow() -} - -/* - Call -*/ - -// Call represents a method call and is used for setting expectations, -// as well as recording activity. -type Call struct { - Parent *Mock - - // The name of the method that was or will be called. - Method string - - // Holds the arguments of the method. - Arguments Arguments - - // Holds the arguments that should be returned when - // this method is called. - ReturnArguments Arguments - - // Holds the caller info for the On() call - callerInfo []string - - // The number of times to return the return arguments when setting - // expectations. 0 means to always return the value. - Repeatability int - - // Amount of times this call has been called - totalCalls int - - // Call to this method can be optional - optional bool - - // Holds a channel that will be used to block the Return until it either - // receives a message or is closed. nil means it returns immediately. - WaitFor <-chan time.Time - - waitTime time.Duration - - // Holds a handler used to manipulate arguments content that are passed by - // reference. It's useful when mocking methods such as unmarshalers or - // decoders. - RunFn func(Arguments) -} - -func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments ...interface{}) *Call { - return &Call{ - Parent: parent, - Method: methodName, - Arguments: methodArguments, - ReturnArguments: make([]interface{}, 0), - callerInfo: callerInfo, - Repeatability: 0, - WaitFor: nil, - RunFn: nil, - } -} - -func (c *Call) lock() { - c.Parent.mutex.Lock() -} - -func (c *Call) unlock() { - c.Parent.mutex.Unlock() -} - -// Return specifies the return arguments for the expectation. -// -// Mock.On("DoSomething").Return(errors.New("failed")) -func (c *Call) Return(returnArguments ...interface{}) *Call { - c.lock() - defer c.unlock() - - c.ReturnArguments = returnArguments - - return c -} - -// Once indicates that that the mock should only return the value once. -// -// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once() -func (c *Call) Once() *Call { - return c.Times(1) -} - -// Twice indicates that that the mock should only return the value twice. -// -// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice() -func (c *Call) Twice() *Call { - return c.Times(2) -} - -// Times indicates that that the mock should only return the indicated number -// of times. -// -// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5) -func (c *Call) Times(i int) *Call { - c.lock() - defer c.unlock() - c.Repeatability = i - return c -} - -// WaitUntil sets the channel that will block the mock's return until its closed -// or a message is received. -// -// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second)) -func (c *Call) WaitUntil(w <-chan time.Time) *Call { - c.lock() - defer c.unlock() - c.WaitFor = w - return c -} - -// After sets how long to block until the call returns -// -// Mock.On("MyMethod", arg1, arg2).After(time.Second) -func (c *Call) After(d time.Duration) *Call { - c.lock() - defer c.unlock() - c.waitTime = d - return c -} - -// Run sets a handler to be called before returning. It can be used when -// mocking a method such as unmarshalers that takes a pointer to a struct and -// sets properties in such struct -// -// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) { -// arg := args.Get(0).(*map[string]interface{}) -// arg["foo"] = "bar" -// }) -func (c *Call) Run(fn func(args Arguments)) *Call { - c.lock() - defer c.unlock() - c.RunFn = fn - return c -} - -// Maybe allows the method call to be optional. Not calling an optional method -// will not cause an error while asserting expectations -func (c *Call) Maybe() *Call { - c.lock() - defer c.unlock() - c.optional = true - return c -} - -// On chains a new expectation description onto the mocked interface. This -// allows syntax like. -// -// Mock. -// On("MyMethod", 1).Return(nil). -// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error")) -func (c *Call) On(methodName string, arguments ...interface{}) *Call { - return c.Parent.On(methodName, arguments...) -} - -// Mock is the workhorse used to track activity on another object. -// For an example of its usage, refer to the "Example Usage" section at the top -// of this document. -type Mock struct { - // Represents the calls that are expected of - // an object. - ExpectedCalls []*Call - - // Holds the calls that were made to this mocked object. - Calls []Call - - // test is An optional variable that holds the test struct, to be used when an - // invalid mock call was made. - test TestingT - - // TestData holds any data that might be useful for testing. Testify ignores - // this data completely allowing you to do whatever you like with it. - testData objx.Map - - mutex sync.Mutex -} - -// TestData holds any data that might be useful for testing. Testify ignores -// this data completely allowing you to do whatever you like with it. -func (m *Mock) TestData() objx.Map { - - if m.testData == nil { - m.testData = make(objx.Map) - } - - return m.testData -} - -/* - Setting expectations -*/ - -// Test sets the test struct variable of the mock object -func (m *Mock) Test(t TestingT) { - m.mutex.Lock() - defer m.mutex.Unlock() - m.test = t -} - -// fail fails the current test with the given formatted format and args. -// In case that a test was defined, it uses the test APIs for failing a test, -// otherwise it uses panic. -func (m *Mock) fail(format string, args ...interface{}) { - m.mutex.Lock() - defer m.mutex.Unlock() - - if m.test == nil { - panic(fmt.Sprintf(format, args...)) - } - m.test.Errorf(format, args...) - m.test.FailNow() -} - -// On starts a description of an expectation of the specified method -// being called. -// -// Mock.On("MyMethod", arg1, arg2) -func (m *Mock) On(methodName string, arguments ...interface{}) *Call { - for _, arg := range arguments { - if v := reflect.ValueOf(arg); v.Kind() == reflect.Func { - panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg)) - } - } - - m.mutex.Lock() - defer m.mutex.Unlock() - c := newCall(m, methodName, assert.CallerInfo(), arguments...) - m.ExpectedCalls = append(m.ExpectedCalls, c) - return c -} - -// /* -// Recording and responding to activity -// */ - -func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) { - for i, call := range m.ExpectedCalls { - if call.Method == method && call.Repeatability > -1 { - - _, diffCount := call.Arguments.Diff(arguments) - if diffCount == 0 { - return i, call - } - - } - } - return -1, nil -} - -func (m *Mock) findClosestCall(method string, arguments ...interface{}) (*Call, string) { - var diffCount int - var closestCall *Call - var err string - - for _, call := range m.expectedCalls() { - if call.Method == method { - - errInfo, tempDiffCount := call.Arguments.Diff(arguments) - if tempDiffCount < diffCount || diffCount == 0 { - diffCount = tempDiffCount - closestCall = call - err = errInfo - } - - } - } - - return closestCall, err -} - -func callString(method string, arguments Arguments, includeArgumentValues bool) string { - - var argValsString string - if includeArgumentValues { - var argVals []string - for argIndex, arg := range arguments { - argVals = append(argVals, fmt.Sprintf("%d: %#v", argIndex, arg)) - } - argValsString = fmt.Sprintf("\n\t\t%s", strings.Join(argVals, "\n\t\t")) - } - - return fmt.Sprintf("%s(%s)%s", method, arguments.String(), argValsString) -} - -// Called tells the mock object that a method has been called, and gets an array -// of arguments to return. Panics if the call is unexpected (i.e. not preceded by -// appropriate .On .Return() calls) -// If Call.WaitFor is set, blocks until the channel is closed or receives a message. -func (m *Mock) Called(arguments ...interface{}) Arguments { - // get the calling function's name - pc, _, _, ok := runtime.Caller(1) - if !ok { - panic("Couldn't get the caller information") - } - functionPath := runtime.FuncForPC(pc).Name() - //Next four lines are required to use GCCGO function naming conventions. - //For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock - //uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree - //With GCCGO we need to remove interface information starting from pN

. - re := regexp.MustCompile("\\.pN\\d+_") - if re.MatchString(functionPath) { - functionPath = re.Split(functionPath, -1)[0] - } - parts := strings.Split(functionPath, ".") - functionName := parts[len(parts)-1] - return m.MethodCalled(functionName, arguments...) -} - -// MethodCalled tells the mock object that the given method has been called, and gets -// an array of arguments to return. Panics if the call is unexpected (i.e. not preceded -// by appropriate .On .Return() calls) -// If Call.WaitFor is set, blocks until the channel is closed or receives a message. -func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments { - m.mutex.Lock() - //TODO: could combine expected and closes in single loop - found, call := m.findExpectedCall(methodName, arguments...) - - if found < 0 { - // we have to fail here - because we don't know what to do - // as the return arguments. This is because: - // - // a) this is a totally unexpected call to this method, - // b) the arguments are not what was expected, or - // c) the developer has forgotten to add an accompanying On...Return pair. - - closestCall, mismatch := m.findClosestCall(methodName, arguments...) - m.mutex.Unlock() - - if closestCall != nil { - m.fail("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\nDiff: %s", - callString(methodName, arguments, true), - callString(methodName, closestCall.Arguments, true), - diffArguments(closestCall.Arguments, arguments), - strings.TrimSpace(mismatch), - ) - } else { - m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo()) - } - } - - if call.Repeatability == 1 { - call.Repeatability = -1 - } else if call.Repeatability > 1 { - call.Repeatability-- - } - call.totalCalls++ - - // add the call - m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments...)) - m.mutex.Unlock() - - // block if specified - if call.WaitFor != nil { - <-call.WaitFor - } else { - time.Sleep(call.waitTime) - } - - m.mutex.Lock() - runFn := call.RunFn - m.mutex.Unlock() - - if runFn != nil { - runFn(arguments) - } - - m.mutex.Lock() - returnArgs := call.ReturnArguments - m.mutex.Unlock() - - return returnArgs -} - -/* - Assertions -*/ - -type assertExpectationser interface { - AssertExpectations(TestingT) bool -} - -// AssertExpectationsForObjects asserts that everything specified with On and Return -// of the specified objects was in fact called as expected. -// -// Calls may have occurred in any order. -func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - for _, obj := range testObjects { - if m, ok := obj.(Mock); ok { - t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)") - obj = &m - } - m := obj.(assertExpectationser) - if !m.AssertExpectations(t) { - t.Logf("Expectations didn't match for Mock: %+v", reflect.TypeOf(m)) - return false - } - } - return true -} - -// AssertExpectations asserts that everything specified with On and Return was -// in fact called as expected. Calls may have occurred in any order. -func (m *Mock) AssertExpectations(t TestingT) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - m.mutex.Lock() - defer m.mutex.Unlock() - var somethingMissing bool - var failedExpectations int - - // iterate through each expectation - expectedCalls := m.expectedCalls() - for _, expectedCall := range expectedCalls { - if !expectedCall.optional && !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) && expectedCall.totalCalls == 0 { - somethingMissing = true - failedExpectations++ - t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo) - } else { - if expectedCall.Repeatability > 0 { - somethingMissing = true - failedExpectations++ - t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo) - } else { - t.Logf("PASS:\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String()) - } - } - } - - if somethingMissing { - t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(expectedCalls)-failedExpectations, len(expectedCalls), failedExpectations, assert.CallerInfo()) - } - - return !somethingMissing -} - -// AssertNumberOfCalls asserts that the method was called expectedCalls times. -func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - m.mutex.Lock() - defer m.mutex.Unlock() - var actualCalls int - for _, call := range m.calls() { - if call.Method == methodName { - actualCalls++ - } - } - return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls)) -} - -// AssertCalled asserts that the method was called. -// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. -func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - m.mutex.Lock() - defer m.mutex.Unlock() - if !m.methodWasCalled(methodName, arguments) { - var calledWithArgs []string - for _, call := range m.calls() { - calledWithArgs = append(calledWithArgs, fmt.Sprintf("%v", call.Arguments)) - } - if len(calledWithArgs) == 0 { - return assert.Fail(t, "Should have called with given arguments", - fmt.Sprintf("Expected %q to have been called with:\n%v\nbut no actual calls happened", methodName, arguments)) - } - return assert.Fail(t, "Should have called with given arguments", - fmt.Sprintf("Expected %q to have been called with:\n%v\nbut actual calls were:\n %v", methodName, arguments, strings.Join(calledWithArgs, "\n"))) - } - return true -} - -// AssertNotCalled asserts that the method was not called. -// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. -func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - m.mutex.Lock() - defer m.mutex.Unlock() - if m.methodWasCalled(methodName, arguments) { - return assert.Fail(t, "Should not have called with given arguments", - fmt.Sprintf("Expected %q to not have been called with:\n%v\nbut actually it was.", methodName, arguments)) - } - return true -} - -func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool { - for _, call := range m.calls() { - if call.Method == methodName { - - _, differences := Arguments(expected).Diff(call.Arguments) - - if differences == 0 { - // found the expected call - return true - } - - } - } - // we didn't find the expected call - return false -} - -func (m *Mock) expectedCalls() []*Call { - return append([]*Call{}, m.ExpectedCalls...) -} - -func (m *Mock) calls() []Call { - return append([]Call{}, m.Calls...) -} - -/* - Arguments -*/ - -// Arguments holds an array of method arguments or return values. -type Arguments []interface{} - -const ( - // Anything is used in Diff and Assert when the argument being tested - // shouldn't be taken into consideration. - Anything = "mock.Anything" -) - -// AnythingOfTypeArgument is a string that contains the type of an argument -// for use when type checking. Used in Diff and Assert. -type AnythingOfTypeArgument string - -// AnythingOfType returns an AnythingOfTypeArgument object containing the -// name of the type to check for. Used in Diff and Assert. -// -// For example: -// Assert(t, AnythingOfType("string"), AnythingOfType("int")) -func AnythingOfType(t string) AnythingOfTypeArgument { - return AnythingOfTypeArgument(t) -} - -// argumentMatcher performs custom argument matching, returning whether or -// not the argument is matched by the expectation fixture function. -type argumentMatcher struct { - // fn is a function which accepts one argument, and returns a bool. - fn reflect.Value -} - -func (f argumentMatcher) Matches(argument interface{}) bool { - expectType := f.fn.Type().In(0) - expectTypeNilSupported := false - switch expectType.Kind() { - case reflect.Interface, reflect.Chan, reflect.Func, reflect.Map, reflect.Slice, reflect.Ptr: - expectTypeNilSupported = true - } - - argType := reflect.TypeOf(argument) - var arg reflect.Value - if argType == nil { - arg = reflect.New(expectType).Elem() - } else { - arg = reflect.ValueOf(argument) - } - - if argType == nil && !expectTypeNilSupported { - panic(errors.New("attempting to call matcher with nil for non-nil expected type")) - } - if argType == nil || argType.AssignableTo(expectType) { - result := f.fn.Call([]reflect.Value{arg}) - return result[0].Bool() - } - return false -} - -func (f argumentMatcher) String() string { - return fmt.Sprintf("func(%s) bool", f.fn.Type().In(0).Name()) -} - -// MatchedBy can be used to match a mock call based on only certain properties -// from a complex struct or some calculation. It takes a function that will be -// evaluated with the called argument and will return true when there's a match -// and false otherwise. -// -// Example: -// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" })) -// -// |fn|, must be a function accepting a single argument (of the expected type) -// which returns a bool. If |fn| doesn't match the required signature, -// MatchedBy() panics. -func MatchedBy(fn interface{}) argumentMatcher { - fnType := reflect.TypeOf(fn) - - if fnType.Kind() != reflect.Func { - panic(fmt.Sprintf("assert: arguments: %s is not a func", fn)) - } - if fnType.NumIn() != 1 { - panic(fmt.Sprintf("assert: arguments: %s does not take exactly one argument", fn)) - } - if fnType.NumOut() != 1 || fnType.Out(0).Kind() != reflect.Bool { - panic(fmt.Sprintf("assert: arguments: %s does not return a bool", fn)) - } - - return argumentMatcher{fn: reflect.ValueOf(fn)} -} - -// Get Returns the argument at the specified index. -func (args Arguments) Get(index int) interface{} { - if index+1 > len(args) { - panic(fmt.Sprintf("assert: arguments: Cannot call Get(%d) because there are %d argument(s).", index, len(args))) - } - return args[index] -} - -// Is gets whether the objects match the arguments specified. -func (args Arguments) Is(objects ...interface{}) bool { - for i, obj := range args { - if obj != objects[i] { - return false - } - } - return true -} - -// Diff gets a string describing the differences between the arguments -// and the specified objects. -// -// Returns the diff string and number of differences found. -func (args Arguments) Diff(objects []interface{}) (string, int) { - //TODO: could return string as error and nil for No difference - - var output = "\n" - var differences int - - var maxArgCount = len(args) - if len(objects) > maxArgCount { - maxArgCount = len(objects) - } - - for i := 0; i < maxArgCount; i++ { - var actual, expected interface{} - var actualFmt, expectedFmt string - - if len(objects) <= i { - actual = "(Missing)" - actualFmt = "(Missing)" - } else { - actual = objects[i] - actualFmt = fmt.Sprintf("(%[1]T=%[1]v)", actual) - } - - if len(args) <= i { - expected = "(Missing)" - expectedFmt = "(Missing)" - } else { - expected = args[i] - expectedFmt = fmt.Sprintf("(%[1]T=%[1]v)", expected) - } - - if matcher, ok := expected.(argumentMatcher); ok { - if matcher.Matches(actual) { - output = fmt.Sprintf("%s\t%d: PASS: %s matched by %s\n", output, i, actualFmt, matcher) - } else { - differences++ - output = fmt.Sprintf("%s\t%d: PASS: %s not matched by %s\n", output, i, actualFmt, matcher) - } - } else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() { - - // type checking - if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) { - // not match - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actualFmt) - } - - } else { - - // normal checking - - if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) { - // match - output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actualFmt, expectedFmt) - } else { - // not match - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actualFmt, expectedFmt) - } - } - - } - - if differences == 0 { - return "No differences.", differences - } - - return output, differences - -} - -// Assert compares the arguments with the specified objects and fails if -// they do not exactly match. -func (args Arguments) Assert(t TestingT, objects ...interface{}) bool { - if h, ok := t.(tHelper); ok { - h.Helper() - } - - // get the differences - diff, diffCount := args.Diff(objects) - - if diffCount == 0 { - return true - } - - // there are differences... report them... - t.Logf(diff) - t.Errorf("%sArguments do not match.", assert.CallerInfo()) - - return false - -} - -// String gets the argument at the specified index. Panics if there is no argument, or -// if the argument is of the wrong type. -// -// If no index is provided, String() returns a complete string representation -// of the arguments. -func (args Arguments) String(indexOrNil ...int) string { - - if len(indexOrNil) == 0 { - // normal String() method - return a string representation of the args - var argsStr []string - for _, arg := range args { - argsStr = append(argsStr, fmt.Sprintf("%s", reflect.TypeOf(arg))) - } - return strings.Join(argsStr, ",") - } else if len(indexOrNil) == 1 { - // Index has been specified - get the argument at that index - var index = indexOrNil[0] - var s string - var ok bool - if s, ok = args.Get(index).(string); !ok { - panic(fmt.Sprintf("assert: arguments: String(%d) failed because object wasn't correct type: %s", index, args.Get(index))) - } - return s - } - - panic(fmt.Sprintf("assert: arguments: Wrong number of arguments passed to String. Must be 0 or 1, not %d", len(indexOrNil))) - -} - -// Int gets the argument at the specified index. Panics if there is no argument, or -// if the argument is of the wrong type. -func (args Arguments) Int(index int) int { - var s int - var ok bool - if s, ok = args.Get(index).(int); !ok { - panic(fmt.Sprintf("assert: arguments: Int(%d) failed because object wasn't correct type: %v", index, args.Get(index))) - } - return s -} - -// Error gets the argument at the specified index. Panics if there is no argument, or -// if the argument is of the wrong type. -func (args Arguments) Error(index int) error { - obj := args.Get(index) - var s error - var ok bool - if obj == nil { - return nil - } - if s, ok = obj.(error); !ok { - panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, args.Get(index))) - } - return s -} - -// Bool gets the argument at the specified index. Panics if there is no argument, or -// if the argument is of the wrong type. -func (args Arguments) Bool(index int) bool { - var s bool - var ok bool - if s, ok = args.Get(index).(bool); !ok { - panic(fmt.Sprintf("assert: arguments: Bool(%d) failed because object wasn't correct type: %v", index, args.Get(index))) - } - return s -} - -func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { - t := reflect.TypeOf(v) - k := t.Kind() - - if k == reflect.Ptr { - t = t.Elem() - k = t.Kind() - } - return t, k -} - -func diffArguments(expected Arguments, actual Arguments) string { - if len(expected) != len(actual) { - return fmt.Sprintf("Provided %v arguments, mocked for %v arguments", len(expected), len(actual)) - } - - for x := range expected { - if diffString := diff(expected[x], actual[x]); diffString != "" { - return fmt.Sprintf("Difference found in argument %v:\n\n%s", x, diffString) - } - } - - return "" -} - -// diff returns a diff of both values as long as both are of the same type and -// are a struct, map, slice or array. Otherwise it returns an empty string. -func diff(expected interface{}, actual interface{}) string { - if expected == nil || actual == nil { - return "" - } - - et, ek := typeAndKind(expected) - at, _ := typeAndKind(actual) - - if et != at { - return "" - } - - if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array { - return "" - } - - e := spewConfig.Sdump(expected) - a := spewConfig.Sdump(actual) - - diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ - A: difflib.SplitLines(e), - B: difflib.SplitLines(a), - FromFile: "Expected", - FromDate: "", - ToFile: "Actual", - ToDate: "", - Context: 1, - }) - - return diff -} - -var spewConfig = spew.ConfigState{ - Indent: " ", - DisablePointerAddresses: true, - DisableCapacities: true, - SortKeys: true, -} - -type tHelper interface { - Helper() -} diff --git a/vendor/github.com/stretchr/testify/mock/mock_test.go b/vendor/github.com/stretchr/testify/mock/mock_test.go deleted file mode 100644 index 978eae2..0000000 --- a/vendor/github.com/stretchr/testify/mock/mock_test.go +++ /dev/null @@ -1,1497 +0,0 @@ -package mock - -import ( - "errors" - "fmt" - "regexp" - "runtime" - "sync" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -/* - Test objects -*/ - -// ExampleInterface represents an example interface. -type ExampleInterface interface { - TheExampleMethod(a, b, c int) (int, error) -} - -// TestExampleImplementation is a test implementation of ExampleInterface -type TestExampleImplementation struct { - Mock -} - -func (i *TestExampleImplementation) TheExampleMethod(a, b, c int) (int, error) { - args := i.Called(a, b, c) - return args.Int(0), errors.New("Whoops") -} - -func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) { - i.Called(yesorno) -} - -type ExampleType struct { - ran bool -} - -func (i *TestExampleImplementation) TheExampleMethod3(et *ExampleType) error { - args := i.Called(et) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethod4(v ExampleInterface) error { - args := i.Called(v) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethod5(ch chan struct{}) error { - args := i.Called(ch) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethod6(m map[string]bool) error { - args := i.Called(m) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethod7(slice []bool) error { - args := i.Called(slice) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethodFunc(fn func(string) error) error { - args := i.Called(fn) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethodVariadic(a ...int) error { - args := i.Called(a) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethodVariadicInterface(a ...interface{}) error { - args := i.Called(a) - return args.Error(0) -} - -func (i *TestExampleImplementation) TheExampleMethodMixedVariadic(a int, b ...int) error { - args := i.Called(a, b) - return args.Error(0) -} - -type ExampleFuncType func(string) error - -func (i *TestExampleImplementation) TheExampleMethodFuncType(fn ExampleFuncType) error { - args := i.Called(fn) - return args.Error(0) -} - -// MockTestingT mocks a test struct -type MockTestingT struct { - logfCount, errorfCount, failNowCount int -} - -const mockTestingTFailNowCalled = "FailNow was called" - -func (m *MockTestingT) Logf(string, ...interface{}) { - m.logfCount++ -} - -func (m *MockTestingT) Errorf(string, ...interface{}) { - m.errorfCount++ -} - -// FailNow mocks the FailNow call. -// It panics in order to mimic the FailNow behavior in the sense that -// the execution stops. -// When expecting this method, the call that invokes it should use the following code: -// -// assert.PanicsWithValue(t, mockTestingTFailNowCalled, func() {...}) -func (m *MockTestingT) FailNow() { - m.failNowCount++ - - // this function should panic now to stop the execution as expected - panic(mockTestingTFailNowCalled) -} - -/* - Mock -*/ - -func Test_Mock_TestData(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - if assert.NotNil(t, mockedService.TestData()) { - - mockedService.TestData().Set("something", 123) - assert.Equal(t, 123, mockedService.TestData().Get("something").Data()) - } -} - -func Test_Mock_On(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService.On("TheExampleMethod") - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, "TheExampleMethod", c.Method) -} - -func Test_Mock_Chained_On(t *testing.T) { - // make a test impl object - var mockedService = new(TestExampleImplementation) - - // determine our current line number so we can assert the expected calls callerInfo properly - _, _, line, _ := runtime.Caller(0) - mockedService. - On("TheExampleMethod", 1, 2, 3). - Return(0). - On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). - Return(nil) - - expectedCalls := []*Call{ - { - Parent: &mockedService.Mock, - Method: "TheExampleMethod", - Arguments: []interface{}{1, 2, 3}, - ReturnArguments: []interface{}{0}, - callerInfo: []string{fmt.Sprintf("mock_test.go:%d", line+2)}, - }, - { - Parent: &mockedService.Mock, - Method: "TheExampleMethod3", - Arguments: []interface{}{AnythingOfType("*mock.ExampleType")}, - ReturnArguments: []interface{}{nil}, - callerInfo: []string{fmt.Sprintf("mock_test.go:%d", line+4)}, - }, - } - assert.Equal(t, expectedCalls, mockedService.ExpectedCalls) -} - -func Test_Mock_On_WithArgs(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService.On("TheExampleMethod", 1, 2, 3, 4) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, "TheExampleMethod", c.Method) - assert.Equal(t, Arguments{1, 2, 3, 4}, c.Arguments) -} - -func Test_Mock_On_WithFuncArg(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethodFunc", AnythingOfType("func(string) error")). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, "TheExampleMethodFunc", c.Method) - assert.Equal(t, 1, len(c.Arguments)) - assert.Equal(t, AnythingOfType("func(string) error"), c.Arguments[0]) - - fn := func(string) error { return nil } - - assert.NotPanics(t, func() { - mockedService.TheExampleMethodFunc(fn) - }) -} - -func Test_Mock_On_WithIntArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod", - MatchedBy(func(a int) bool { - return a == 1 - }), MatchedBy(func(b int) bool { - return b == 2 - }), MatchedBy(func(c int) bool { - return c == 3 - })).Return(0, nil) - - assert.Panics(t, func() { - mockedService.TheExampleMethod(1, 2, 4) - }) - assert.Panics(t, func() { - mockedService.TheExampleMethod(2, 2, 3) - }) - assert.NotPanics(t, func() { - mockedService.TheExampleMethod(1, 2, 3) - }) -} - -func TestMock_WithTest(t *testing.T) { - var ( - mockedService TestExampleImplementation - mockedTest MockTestingT - ) - - mockedService.Test(&mockedTest) - mockedService.On("TheExampleMethod", 1, 2, 3).Return(0, nil) - - // Test that on an expected call, the test was not failed - - mockedService.TheExampleMethod(1, 2, 3) - - // Assert that Errorf and FailNow were not called - assert.Equal(t, 0, mockedTest.errorfCount) - assert.Equal(t, 0, mockedTest.failNowCount) - - // Test that on unexpected call, the mocked test was called to fail the test - - assert.PanicsWithValue(t, mockTestingTFailNowCalled, func() { - mockedService.TheExampleMethod(1, 1, 1) - }) - - // Assert that Errorf and FailNow were called once - assert.Equal(t, 1, mockedTest.errorfCount) - assert.Equal(t, 1, mockedTest.failNowCount) -} - -func Test_Mock_On_WithPtrArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod3", - MatchedBy(func(a *ExampleType) bool { return a != nil && a.ran == true }), - ).Return(nil) - - mockedService.On("TheExampleMethod3", - MatchedBy(func(a *ExampleType) bool { return a != nil && a.ran == false }), - ).Return(errors.New("error")) - - mockedService.On("TheExampleMethod3", - MatchedBy(func(a *ExampleType) bool { return a == nil }), - ).Return(errors.New("error2")) - - assert.Equal(t, mockedService.TheExampleMethod3(&ExampleType{true}), nil) - assert.EqualError(t, mockedService.TheExampleMethod3(&ExampleType{false}), "error") - assert.EqualError(t, mockedService.TheExampleMethod3(nil), "error2") -} - -func Test_Mock_On_WithFuncArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - fixture1, fixture2 := errors.New("fixture1"), errors.New("fixture2") - - mockedService.On("TheExampleMethodFunc", - MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture1 }), - ).Return(errors.New("fixture1")) - - mockedService.On("TheExampleMethodFunc", - MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture2 }), - ).Return(errors.New("fixture2")) - - mockedService.On("TheExampleMethodFunc", - MatchedBy(func(a func(string) error) bool { return a == nil }), - ).Return(errors.New("fixture3")) - - assert.EqualError(t, mockedService.TheExampleMethodFunc( - func(string) error { return fixture1 }), "fixture1") - assert.EqualError(t, mockedService.TheExampleMethodFunc( - func(string) error { return fixture2 }), "fixture2") - assert.EqualError(t, mockedService.TheExampleMethodFunc(nil), "fixture3") -} - -func Test_Mock_On_WithInterfaceArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod4", - MatchedBy(func(a ExampleInterface) bool { return a == nil }), - ).Return(errors.New("fixture1")) - - assert.EqualError(t, mockedService.TheExampleMethod4(nil), "fixture1") -} - -func Test_Mock_On_WithChannelArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod5", - MatchedBy(func(ch chan struct{}) bool { return ch == nil }), - ).Return(errors.New("fixture1")) - - assert.EqualError(t, mockedService.TheExampleMethod5(nil), "fixture1") -} - -func Test_Mock_On_WithMapArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod6", - MatchedBy(func(m map[string]bool) bool { return m == nil }), - ).Return(errors.New("fixture1")) - - assert.EqualError(t, mockedService.TheExampleMethod6(nil), "fixture1") -} - -func Test_Mock_On_WithSliceArgMatcher(t *testing.T) { - var mockedService TestExampleImplementation - - mockedService.On("TheExampleMethod7", - MatchedBy(func(slice []bool) bool { return slice == nil }), - ).Return(errors.New("fixture1")) - - assert.EqualError(t, mockedService.TheExampleMethod7(nil), "fixture1") -} - -func Test_Mock_On_WithVariadicFunc(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethodVariadic", []int{1, 2, 3}). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, 1, len(c.Arguments)) - assert.Equal(t, []int{1, 2, 3}, c.Arguments[0]) - - assert.NotPanics(t, func() { - mockedService.TheExampleMethodVariadic(1, 2, 3) - }) - assert.Panics(t, func() { - mockedService.TheExampleMethodVariadic(1, 2) - }) - -} - -func Test_Mock_On_WithMixedVariadicFunc(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethodMixedVariadic", 1, []int{2, 3, 4}). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, 2, len(c.Arguments)) - assert.Equal(t, 1, c.Arguments[0]) - assert.Equal(t, []int{2, 3, 4}, c.Arguments[1]) - - assert.NotPanics(t, func() { - mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 4) - }) - assert.Panics(t, func() { - mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 5) - }) - -} - -func Test_Mock_On_WithVariadicFuncWithInterface(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService.On("TheExampleMethodVariadicInterface", []interface{}{1, 2, 3}). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, 1, len(c.Arguments)) - assert.Equal(t, []interface{}{1, 2, 3}, c.Arguments[0]) - - assert.NotPanics(t, func() { - mockedService.TheExampleMethodVariadicInterface(1, 2, 3) - }) - assert.Panics(t, func() { - mockedService.TheExampleMethodVariadicInterface(1, 2) - }) - -} - -func Test_Mock_On_WithVariadicFuncWithEmptyInterfaceArray(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - var expected []interface{} - c := mockedService. - On("TheExampleMethodVariadicInterface", expected). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, 1, len(c.Arguments)) - assert.Equal(t, expected, c.Arguments[0]) - - assert.NotPanics(t, func() { - mockedService.TheExampleMethodVariadicInterface() - }) - assert.Panics(t, func() { - mockedService.TheExampleMethodVariadicInterface(1, 2) - }) - -} - -func Test_Mock_On_WithFuncPanics(t *testing.T) { - // make a test impl object - var mockedService = new(TestExampleImplementation) - - assert.Panics(t, func() { - mockedService.On("TheExampleMethodFunc", func(string) error { return nil }) - }) -} - -func Test_Mock_On_WithFuncTypeArg(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethodFuncType", AnythingOfType("mock.ExampleFuncType")). - Return(nil) - - assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - assert.Equal(t, 1, len(c.Arguments)) - assert.Equal(t, AnythingOfType("mock.ExampleFuncType"), c.Arguments[0]) - - fn := func(string) error { return nil } - assert.NotPanics(t, func() { - mockedService.TheExampleMethodFuncType(fn) - }) -} - -func Test_Mock_Return(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethod", "A", "B", true). - Return(1, "two", true) - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 0, call.Repeatability) - assert.Nil(t, call.WaitFor) -} - -func Test_Mock_Return_WaitUntil(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - ch := time.After(time.Second) - - c := mockedService.Mock. - On("TheExampleMethod", "A", "B", true). - WaitUntil(ch). - Return(1, "two", true) - - // assert that the call was created - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 0, call.Repeatability) - assert.Equal(t, ch, call.WaitFor) -} - -func Test_Mock_Return_After(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService.Mock. - On("TheExampleMethod", "A", "B", true). - Return(1, "two", true). - After(time.Second) - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.Mock.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 0, call.Repeatability) - assert.NotEqual(t, nil, call.WaitFor) - -} - -func Test_Mock_Return_Run(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - fn := func(args Arguments) { - arg := args.Get(0).(*ExampleType) - arg.ran = true - } - - c := mockedService.Mock. - On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). - Return(nil). - Run(fn) - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.Mock.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod3", call.Method) - assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0]) - assert.Equal(t, nil, call.ReturnArguments[0]) - assert.Equal(t, 0, call.Repeatability) - assert.NotEqual(t, nil, call.WaitFor) - assert.NotNil(t, call.Run) - - et := ExampleType{} - assert.Equal(t, false, et.ran) - mockedService.TheExampleMethod3(&et) - assert.Equal(t, true, et.ran) -} - -func Test_Mock_Return_Run_Out_Of_Order(t *testing.T) { - // make a test impl object - var mockedService = new(TestExampleImplementation) - f := func(args Arguments) { - arg := args.Get(0).(*ExampleType) - arg.ran = true - } - - c := mockedService.Mock. - On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). - Run(f). - Return(nil) - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.Mock.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod3", call.Method) - assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0]) - assert.Equal(t, nil, call.ReturnArguments[0]) - assert.Equal(t, 0, call.Repeatability) - assert.NotEqual(t, nil, call.WaitFor) - assert.NotNil(t, call.Run) -} - -func Test_Mock_Return_Once(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService.On("TheExampleMethod", "A", "B", true). - Return(1, "two", true). - Once() - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 1, call.Repeatability) - assert.Nil(t, call.WaitFor) -} - -func Test_Mock_Return_Twice(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethod", "A", "B", true). - Return(1, "two", true). - Twice() - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 2, call.Repeatability) - assert.Nil(t, call.WaitFor) -} - -func Test_Mock_Return_Times(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethod", "A", "B", true). - Return(1, "two", true). - Times(5) - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 1, call.ReturnArguments[0]) - assert.Equal(t, "two", call.ReturnArguments[1]) - assert.Equal(t, true, call.ReturnArguments[2]) - assert.Equal(t, 5, call.Repeatability) - assert.Nil(t, call.WaitFor) -} - -func Test_Mock_Return_Nothing(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - c := mockedService. - On("TheExampleMethod", "A", "B", true). - Return() - - require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) - - call := mockedService.ExpectedCalls[0] - - assert.Equal(t, "TheExampleMethod", call.Method) - assert.Equal(t, "A", call.Arguments[0]) - assert.Equal(t, "B", call.Arguments[1]) - assert.Equal(t, true, call.Arguments[2]) - assert.Equal(t, 0, len(call.ReturnArguments)) -} - -func Test_Mock_findExpectedCall(t *testing.T) { - - m := new(Mock) - m.On("One", 1).Return("one") - m.On("Two", 2).Return("two") - m.On("Two", 3).Return("three") - - f, c := m.findExpectedCall("Two", 3) - - if assert.Equal(t, 2, f) { - if assert.NotNil(t, c) { - assert.Equal(t, "Two", c.Method) - assert.Equal(t, 3, c.Arguments[0]) - assert.Equal(t, "three", c.ReturnArguments[0]) - } - } - -} - -func Test_Mock_findExpectedCall_For_Unknown_Method(t *testing.T) { - - m := new(Mock) - m.On("One", 1).Return("one") - m.On("Two", 2).Return("two") - m.On("Two", 3).Return("three") - - f, _ := m.findExpectedCall("Two") - - assert.Equal(t, -1, f) - -} - -func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) { - - m := new(Mock) - m.On("One", 1).Return("one") - m.On("Two", 2).Return("two").Once() - m.On("Two", 3).Return("three").Twice() - m.On("Two", 3).Return("three").Times(8) - - f, c := m.findExpectedCall("Two", 3) - - if assert.Equal(t, 2, f) { - if assert.NotNil(t, c) { - assert.Equal(t, "Two", c.Method) - assert.Equal(t, 3, c.Arguments[0]) - assert.Equal(t, "three", c.ReturnArguments[0]) - } - } - -} - -func Test_callString(t *testing.T) { - - assert.Equal(t, `Method(int,bool,string)`, callString("Method", []interface{}{1, true, "something"}, false)) - -} - -func Test_Mock_Called(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_Called", 1, 2, 3).Return(5, "6", true) - - returnArguments := mockedService.Called(1, 2, 3) - - if assert.Equal(t, 1, len(mockedService.Calls)) { - assert.Equal(t, "Test_Mock_Called", mockedService.Calls[0].Method) - assert.Equal(t, 1, mockedService.Calls[0].Arguments[0]) - assert.Equal(t, 2, mockedService.Calls[0].Arguments[1]) - assert.Equal(t, 3, mockedService.Calls[0].Arguments[2]) - } - - if assert.Equal(t, 3, len(returnArguments)) { - assert.Equal(t, 5, returnArguments[0]) - assert.Equal(t, "6", returnArguments[1]) - assert.Equal(t, true, returnArguments[2]) - } - -} - -func asyncCall(m *Mock, ch chan Arguments) { - ch <- m.Called(1, 2, 3) -} - -func Test_Mock_Called_blocks(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.Mock.On("asyncCall", 1, 2, 3).Return(5, "6", true).After(2 * time.Millisecond) - - ch := make(chan Arguments) - - go asyncCall(&mockedService.Mock, ch) - - select { - case <-ch: - t.Fatal("should have waited") - case <-time.After(1 * time.Millisecond): - } - - returnArguments := <-ch - - if assert.Equal(t, 1, len(mockedService.Mock.Calls)) { - assert.Equal(t, "asyncCall", mockedService.Mock.Calls[0].Method) - assert.Equal(t, 1, mockedService.Mock.Calls[0].Arguments[0]) - assert.Equal(t, 2, mockedService.Mock.Calls[0].Arguments[1]) - assert.Equal(t, 3, mockedService.Mock.Calls[0].Arguments[2]) - } - - if assert.Equal(t, 3, len(returnArguments)) { - assert.Equal(t, 5, returnArguments[0]) - assert.Equal(t, "6", returnArguments[1]) - assert.Equal(t, true, returnArguments[2]) - } - -} - -func Test_Mock_Called_For_Bounded_Repeatability(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService. - On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3). - Return(5, "6", true). - Once() - mockedService. - On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3). - Return(-1, "hi", false) - - returnArguments1 := mockedService.Called(1, 2, 3) - returnArguments2 := mockedService.Called(1, 2, 3) - - if assert.Equal(t, 2, len(mockedService.Calls)) { - assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[0].Method) - assert.Equal(t, 1, mockedService.Calls[0].Arguments[0]) - assert.Equal(t, 2, mockedService.Calls[0].Arguments[1]) - assert.Equal(t, 3, mockedService.Calls[0].Arguments[2]) - - assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[1].Method) - assert.Equal(t, 1, mockedService.Calls[1].Arguments[0]) - assert.Equal(t, 2, mockedService.Calls[1].Arguments[1]) - assert.Equal(t, 3, mockedService.Calls[1].Arguments[2]) - } - - if assert.Equal(t, 3, len(returnArguments1)) { - assert.Equal(t, 5, returnArguments1[0]) - assert.Equal(t, "6", returnArguments1[1]) - assert.Equal(t, true, returnArguments1[2]) - } - - if assert.Equal(t, 3, len(returnArguments2)) { - assert.Equal(t, -1, returnArguments2[0]) - assert.Equal(t, "hi", returnArguments2[1]) - assert.Equal(t, false, returnArguments2[2]) - } - -} - -func Test_Mock_Called_For_SetTime_Expectation(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("TheExampleMethod", 1, 2, 3).Return(5, "6", true).Times(4) - - mockedService.TheExampleMethod(1, 2, 3) - mockedService.TheExampleMethod(1, 2, 3) - mockedService.TheExampleMethod(1, 2, 3) - mockedService.TheExampleMethod(1, 2, 3) - assert.Panics(t, func() { - mockedService.TheExampleMethod(1, 2, 3) - }) - -} - -func Test_Mock_Called_Unexpected(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - // make sure it panics if no expectation was made - assert.Panics(t, func() { - mockedService.Called(1, 2, 3) - }, "Calling unexpected method should panic") - -} - -func Test_AssertExpectationsForObjects_Helper(t *testing.T) { - - var mockedService1 = new(TestExampleImplementation) - var mockedService2 = new(TestExampleImplementation) - var mockedService3 = new(TestExampleImplementation) - - mockedService1.On("Test_AssertExpectationsForObjects_Helper", 1).Return() - mockedService2.On("Test_AssertExpectationsForObjects_Helper", 2).Return() - mockedService3.On("Test_AssertExpectationsForObjects_Helper", 3).Return() - - mockedService1.Called(1) - mockedService2.Called(2) - mockedService3.Called(3) - - assert.True(t, AssertExpectationsForObjects(t, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock)) - assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3)) - -} - -func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) { - - var mockedService1 = new(TestExampleImplementation) - var mockedService2 = new(TestExampleImplementation) - var mockedService3 = new(TestExampleImplementation) - - mockedService1.On("Test_AssertExpectationsForObjects_Helper_Failed", 1).Return() - mockedService2.On("Test_AssertExpectationsForObjects_Helper_Failed", 2).Return() - mockedService3.On("Test_AssertExpectationsForObjects_Helper_Failed", 3).Return() - - mockedService1.Called(1) - mockedService3.Called(3) - - tt := new(testing.T) - assert.False(t, AssertExpectationsForObjects(tt, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock)) - assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3)) - -} - -func Test_Mock_AssertExpectations(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertExpectations", 1, 2, 3).Return(5, 6, 7) - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - // make the call now - mockedService.Called(1, 2, 3) - - // now assert expectations - assert.True(t, mockedService.AssertExpectations(tt)) - -} - -func Test_Mock_AssertExpectations_Placeholder_NoArgs(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(5, 6, 7).Once() - mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(7, 6, 5) - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - // make the call now - mockedService.Called() - - // now assert expectations - assert.True(t, mockedService.AssertExpectations(tt)) - -} - -func Test_Mock_AssertExpectations_Placeholder(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertExpectations_Placeholder", 1, 2, 3).Return(5, 6, 7).Once() - mockedService.On("Test_Mock_AssertExpectations_Placeholder", 3, 2, 1).Return(7, 6, 5) - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - // make the call now - mockedService.Called(1, 2, 3) - - // now assert expectations - assert.False(t, mockedService.AssertExpectations(tt)) - - // make call to the second expectation - mockedService.Called(3, 2, 1) - - // now assert expectations again - assert.True(t, mockedService.AssertExpectations(tt)) -} - -func Test_Mock_AssertExpectations_With_Pointers(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{1}).Return(1) - mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{2}).Return(2) - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - s := struct{ Foo int }{1} - // make the calls now - mockedService.Called(&s) - s.Foo = 2 - mockedService.Called(&s) - - // now assert expectations - assert.True(t, mockedService.AssertExpectations(tt)) - -} - -func Test_Mock_AssertExpectationsCustomType(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Once() - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - // make the call now - mockedService.TheExampleMethod3(&ExampleType{}) - - // now assert expectations - assert.True(t, mockedService.AssertExpectations(tt)) - -} - -func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Twice() - - tt := new(testing.T) - assert.False(t, mockedService.AssertExpectations(tt)) - - // make the call now - mockedService.Called(1, 2, 3) - - assert.False(t, mockedService.AssertExpectations(tt)) - - mockedService.Called(1, 2, 3) - - // now assert expectations - assert.True(t, mockedService.AssertExpectations(tt)) - -} - -func Test_Mock_TwoCallsWithDifferentArguments(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 1, 2, 3).Return(5, 6, 7) - mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 4, 5, 6).Return(5, 6, 7) - - args1 := mockedService.Called(1, 2, 3) - assert.Equal(t, 5, args1.Int(0)) - assert.Equal(t, 6, args1.Int(1)) - assert.Equal(t, 7, args1.Int(2)) - - args2 := mockedService.Called(4, 5, 6) - assert.Equal(t, 5, args2.Int(0)) - assert.Equal(t, 6, args2.Int(1)) - assert.Equal(t, 7, args2.Int(2)) - -} - -func Test_Mock_AssertNumberOfCalls(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertNumberOfCalls", 1, 2, 3).Return(5, 6, 7) - - mockedService.Called(1, 2, 3) - assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 1)) - - mockedService.Called(1, 2, 3) - assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 2)) - -} - -func Test_Mock_AssertCalled(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertCalled", 1, 2, 3).Return(5, 6, 7) - - mockedService.Called(1, 2, 3) - - assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled", 1, 2, 3)) - -} - -func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService. - On("Test_Mock_AssertCalled_WithAnythingOfTypeArgument", Anything, Anything, Anything). - Return() - - mockedService.Called(1, "two", []uint8("three")) - - assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled_WithAnythingOfTypeArgument", AnythingOfType("int"), AnythingOfType("string"), AnythingOfType("[]uint8"))) - -} - -func Test_Mock_AssertCalled_WithArguments(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertCalled_WithArguments", 1, 2, 3).Return(5, 6, 7) - - mockedService.Called(1, 2, 3) - - tt := new(testing.T) - assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 1, 2, 3)) - assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 2, 3, 4)) - -} - -func Test_Mock_AssertCalled_WithArguments_With_Repeatability(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Once() - mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4).Return(5, 6, 7).Once() - - mockedService.Called(1, 2, 3) - mockedService.Called(2, 3, 4) - - tt := new(testing.T) - assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3)) - assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4)) - assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 3, 4, 5)) - -} - -func Test_Mock_AssertNotCalled(t *testing.T) { - - var mockedService = new(TestExampleImplementation) - - mockedService.On("Test_Mock_AssertNotCalled", 1, 2, 3).Return(5, 6, 7) - - mockedService.Called(1, 2, 3) - - assert.True(t, mockedService.AssertNotCalled(t, "Test_Mock_NotCalled")) - -} - -func Test_Mock_AssertOptional(t *testing.T) { - // Optional called - var ms1 = new(TestExampleImplementation) - ms1.On("TheExampleMethod", 1, 2, 3).Maybe().Return(4, nil) - ms1.TheExampleMethod(1, 2, 3) - - tt1 := new(testing.T) - assert.Equal(t, true, ms1.AssertExpectations(tt1)) - - // Optional not called - var ms2 = new(TestExampleImplementation) - ms2.On("TheExampleMethod", 1, 2, 3).Maybe().Return(4, nil) - - tt2 := new(testing.T) - assert.Equal(t, true, ms2.AssertExpectations(tt2)) - - // Non-optional called - var ms3 = new(TestExampleImplementation) - ms3.On("TheExampleMethod", 1, 2, 3).Return(4, nil) - ms3.TheExampleMethod(1, 2, 3) - - tt3 := new(testing.T) - assert.Equal(t, true, ms3.AssertExpectations(tt3)) -} - -/* - Arguments helper methods -*/ -func Test_Arguments_Get(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - - assert.Equal(t, "string", args.Get(0).(string)) - assert.Equal(t, 123, args.Get(1).(int)) - assert.Equal(t, true, args.Get(2).(bool)) - -} - -func Test_Arguments_Is(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - - assert.True(t, args.Is("string", 123, true)) - assert.False(t, args.Is("wrong", 456, false)) - -} - -func Test_Arguments_Diff(t *testing.T) { - - var args = Arguments([]interface{}{"Hello World", 123, true}) - var diff string - var count int - diff, count = args.Diff([]interface{}{"Hello World", 456, "false"}) - - assert.Equal(t, 2, count) - assert.Contains(t, diff, `(int=456) != (int=123)`) - assert.Contains(t, diff, `(string=false) != (bool=true)`) - -} - -func Test_Arguments_Diff_DifferentNumberOfArgs(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - var diff string - var count int - diff, count = args.Diff([]interface{}{"string", 456, "false", "extra"}) - - assert.Equal(t, 3, count) - assert.Contains(t, diff, `(string=extra) != (Missing)`) - -} - -func Test_Arguments_Diff_WithAnythingArgument(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - var count int - _, count = args.Diff([]interface{}{"string", Anything, true}) - - assert.Equal(t, 0, count) - -} - -func Test_Arguments_Diff_WithAnythingArgument_InActualToo(t *testing.T) { - - var args = Arguments([]interface{}{"string", Anything, true}) - var count int - _, count = args.Diff([]interface{}{"string", 123, true}) - - assert.Equal(t, 0, count) - -} - -func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) { - - var args = Arguments([]interface{}{"string", AnythingOfType("int"), true}) - var count int - _, count = args.Diff([]interface{}{"string", 123, true}) - - assert.Equal(t, 0, count) - -} - -func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) { - - var args = Arguments([]interface{}{"string", AnythingOfType("string"), true}) - var count int - var diff string - diff, count = args.Diff([]interface{}{"string", 123, true}) - - assert.Equal(t, 1, count) - assert.Contains(t, diff, `string != type int - (int=123)`) - -} - -func Test_Arguments_Diff_WithArgMatcher(t *testing.T) { - matchFn := func(a int) bool { - return a == 123 - } - var args = Arguments([]interface{}{"string", MatchedBy(matchFn), true}) - - diff, count := args.Diff([]interface{}{"string", 124, true}) - assert.Equal(t, 1, count) - assert.Contains(t, diff, `(int=124) not matched by func(int) bool`) - - diff, count = args.Diff([]interface{}{"string", false, true}) - assert.Equal(t, 1, count) - assert.Contains(t, diff, `(bool=false) not matched by func(int) bool`) - - diff, count = args.Diff([]interface{}{"string", 123, false}) - assert.Contains(t, diff, `(int=123) matched by func(int) bool`) - - diff, count = args.Diff([]interface{}{"string", 123, true}) - assert.Equal(t, 0, count) - assert.Contains(t, diff, `No differences.`) -} - -func Test_Arguments_Assert(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - - assert.True(t, args.Assert(t, "string", 123, true)) - -} - -func Test_Arguments_String_Representation(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - assert.Equal(t, `string,int,bool`, args.String()) - -} - -func Test_Arguments_String(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - assert.Equal(t, "string", args.String(0)) - -} - -func Test_Arguments_Error(t *testing.T) { - - var err = errors.New("An Error") - var args = Arguments([]interface{}{"string", 123, true, err}) - assert.Equal(t, err, args.Error(3)) - -} - -func Test_Arguments_Error_Nil(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true, nil}) - assert.Equal(t, nil, args.Error(3)) - -} - -func Test_Arguments_Int(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - assert.Equal(t, 123, args.Int(1)) - -} - -func Test_Arguments_Bool(t *testing.T) { - - var args = Arguments([]interface{}{"string", 123, true}) - assert.Equal(t, true, args.Bool(2)) - -} - -func Test_WaitUntil_Parallel(t *testing.T) { - - // make a test impl object - var mockedService = new(TestExampleImplementation) - - ch1 := make(chan time.Time) - ch2 := make(chan time.Time) - - mockedService.Mock.On("TheExampleMethod2", true).Return().WaitUntil(ch2).Run(func(args Arguments) { - ch1 <- time.Now() - }) - - mockedService.Mock.On("TheExampleMethod2", false).Return().WaitUntil(ch1) - - // Lock both goroutines on the .WaitUntil method - go func() { - mockedService.TheExampleMethod2(false) - }() - go func() { - mockedService.TheExampleMethod2(true) - }() - - // Allow the first call to execute, so the second one executes afterwards - ch2 <- time.Now() -} - -func Test_MockMethodCalled(t *testing.T) { - m := new(Mock) - m.On("foo", "hello").Return("world") - - retArgs := m.MethodCalled("foo", "hello") - require.True(t, len(retArgs) == 1) - require.Equal(t, "world", retArgs[0]) - m.AssertExpectations(t) -} - -// Test to validate fix for racy concurrent call access in MethodCalled() -func Test_MockReturnAndCalledConcurrent(t *testing.T) { - iterations := 1000 - m := &Mock{} - call := m.On("ConcurrencyTestMethod") - - wg := sync.WaitGroup{} - wg.Add(2) - - go func() { - for i := 0; i < iterations; i++ { - call.Return(10) - } - wg.Done() - }() - go func() { - for i := 0; i < iterations; i++ { - ConcurrencyTestMethod(m) - } - wg.Done() - }() - wg.Wait() -} - -type timer struct{ Mock } - -func (s *timer) GetTime(i int) string { - return s.Called(i).Get(0).(string) -} - -type tCustomLogger struct { - *testing.T - logs []string - errs []string -} - -func (tc *tCustomLogger) Logf(format string, args ...interface{}) { - tc.T.Logf(format, args...) - tc.logs = append(tc.logs, fmt.Sprintf(format, args...)) -} - -func (tc *tCustomLogger) Errorf(format string, args ...interface{}) { - tc.errs = append(tc.errs, fmt.Sprintf(format, args...)) -} - -func (tc *tCustomLogger) FailNow() {} - -func TestLoggingAssertExpectations(t *testing.T) { - m := new(timer) - m.On("GetTime", 0).Return("") - tcl := &tCustomLogger{t, []string{}, []string{}} - - AssertExpectationsForObjects(tcl, m, new(TestExampleImplementation)) - - require.Equal(t, 1, len(tcl.errs)) - assert.Regexp(t, regexp.MustCompile("(?s)FAIL: 0 out of 1 expectation\\(s\\) were met.*The code you are testing needs to make 1 more call\\(s\\).*"), tcl.errs[0]) - require.Equal(t, 2, len(tcl.logs)) - assert.Regexp(t, regexp.MustCompile("(?s)FAIL:\tGetTime\\(int\\).*"), tcl.logs[0]) - require.Equal(t, "Expectations didn't match for Mock: *mock.timer", tcl.logs[1]) -} - -func TestAfterTotalWaitTimeWhileExecution(t *testing.T) { - waitDuration := 1 - total, waitMs := 5, time.Millisecond*time.Duration(waitDuration) - aTimer := new(timer) - for i := 0; i < total; i++ { - aTimer.On("GetTime", i).After(waitMs).Return(fmt.Sprintf("Time%d", i)).Once() - } - time.Sleep(waitMs) - start := time.Now() - var results []string - - for i := 0; i < total; i++ { - results = append(results, aTimer.GetTime(i)) - } - - end := time.Now() - elapsedTime := end.Sub(start) - assert.True(t, elapsedTime > waitMs, fmt.Sprintf("Total elapsed time:%v should be atleast greater than %v", elapsedTime, waitMs)) - assert.Equal(t, total, len(results)) - for i := range results { - assert.Equal(t, fmt.Sprintf("Time%d", i), results[i], "Return value of method should be same") - } -} - -func TestArgumentMatcherToPrintMismatch(t *testing.T) { - defer func() { - if r := recover(); r != nil { - matchingExp := regexp.MustCompile( - `\s+mock: Unexpected Method Call\s+-*\s+GetTime\(int\)\s+0: 1\s+The closest call I have is:\s+GetTime\(mock.argumentMatcher\)\s+0: mock.argumentMatcher\{.*?\}\s+Diff:.*\(int=1\) not matched by func\(int\) bool`) - assert.Regexp(t, matchingExp, r) - } - }() - - m := new(timer) - m.On("GetTime", MatchedBy(func(i int) bool { return false })).Return("SomeTime").Once() - - res := m.GetTime(1) - require.Equal(t, "SomeTime", res) - m.AssertExpectations(t) -} - -func TestClosestCallMismatchedArgumentInformationShowsTheClosest(t *testing.T) { - defer func() { - if r := recover(); r != nil { - matchingExp := regexp.MustCompile(unexpectedCallRegex(`TheExampleMethod(int,int,int)`, `0: 1\s+1: 1\s+2: 2`, `0: 1\s+1: 1\s+2: 1`, `0: PASS: \(int=1\) == \(int=1\)\s+1: PASS: \(int=1\) == \(int=1\)\s+2: FAIL: \(int=2\) != \(int=1\)`)) - assert.Regexp(t, matchingExp, r) - } - }() - - m := new(TestExampleImplementation) - m.On("TheExampleMethod", 1, 1, 1).Return(1, nil).Once() - m.On("TheExampleMethod", 2, 2, 2).Return(2, nil).Once() - - m.TheExampleMethod(1, 1, 2) -} - -func TestClosestCallMismatchedArgumentValueInformation(t *testing.T) { - defer func() { - if r := recover(); r != nil { - matchingExp := regexp.MustCompile(unexpectedCallRegex(`GetTime(int)`, "0: 1", "0: 999", `0: FAIL: \(int=1\) != \(int=999\)`)) - assert.Regexp(t, matchingExp, r) - } - }() - - m := new(timer) - m.On("GetTime", 999).Return("SomeTime").Once() - - _ = m.GetTime(1) -} - -func unexpectedCallRegex(method, calledArg, expectedArg, diff string) string { - rMethod := regexp.QuoteMeta(method) - return fmt.Sprintf(`\s+mock: Unexpected Method Call\s+-*\s+%s\s+%s\s+The closest call I have is:\s+%s\s+%s\s+Diff: %s`, - rMethod, calledArg, rMethod, expectedArg, diff) -} - -func ConcurrencyTestMethod(m *Mock) { - m.Called() -} diff --git a/vendor/github.com/stretchr/testify/package_test.go b/vendor/github.com/stretchr/testify/package_test.go deleted file mode 100644 index 7ac5d6d..0000000 --- a/vendor/github.com/stretchr/testify/package_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package testify - -import ( - "github.com/stretchr/testify/assert" - "testing" -) - -func TestImports(t *testing.T) { - if assert.Equal(t, 1, 1) != true { - t.Error("Something is wrong.") - } -} diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go deleted file mode 100644 index 169de39..0000000 --- a/vendor/github.com/stretchr/testify/require/doc.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package require implements the same assertions as the `assert` package but -// stops test execution when a test fails. -// -// Example Usage -// -// The following is a complete example using require in a standard test function: -// import ( -// "testing" -// "github.com/stretchr/testify/require" -// ) -// -// func TestSomething(t *testing.T) { -// -// var a string = "Hello" -// var b string = "Hello" -// -// require.Equal(t, a, b, "The two words should be the same.") -// -// } -// -// Assertions -// -// The `require` package have same global functions as in the `assert` package, -// but instead of returning a boolean result they call `t.FailNow()`. -// -// Every assertion function also takes an optional string message as the final argument, -// allowing custom error messages to be appended to the message the assertion method outputs. -package require diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements.go b/vendor/github.com/stretchr/testify/require/forward_requirements.go deleted file mode 100644 index ac71d40..0000000 --- a/vendor/github.com/stretchr/testify/require/forward_requirements.go +++ /dev/null @@ -1,16 +0,0 @@ -package require - -// Assertions provides assertion methods around the -// TestingT interface. -type Assertions struct { - t TestingT -} - -// New makes a new Assertions object for the specified TestingT. -func New(t TestingT) *Assertions { - return &Assertions{ - t: t, - } -} - -//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements_test.go b/vendor/github.com/stretchr/testify/require/forward_requirements_test.go deleted file mode 100644 index b120ae3..0000000 --- a/vendor/github.com/stretchr/testify/require/forward_requirements_test.go +++ /dev/null @@ -1,385 +0,0 @@ -package require - -import ( - "errors" - "testing" - "time" -) - -func TestImplementsWrapper(t *testing.T) { - require := New(t) - - require.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestIsTypeWrapper(t *testing.T) { - require := New(t) - require.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEqualWrapper(t *testing.T) { - require := New(t) - require.Equal(1, 1) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Equal(1, 2) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotEqualWrapper(t *testing.T) { - require := New(t) - require.NotEqual(1, 2) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotEqual(2, 2) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestExactlyWrapper(t *testing.T) { - require := New(t) - - a := float32(1) - b := float32(1) - c := float64(1) - - require.Exactly(a, b) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Exactly(a, c) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotNilWrapper(t *testing.T) { - require := New(t) - require.NotNil(t, new(AssertionTesterConformingObject)) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotNil(nil) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNilWrapper(t *testing.T) { - require := New(t) - require.Nil(nil) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Nil(new(AssertionTesterConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestTrueWrapper(t *testing.T) { - require := New(t) - require.True(true) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.True(false) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestFalseWrapper(t *testing.T) { - require := New(t) - require.False(false) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.False(true) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestContainsWrapper(t *testing.T) { - require := New(t) - require.Contains("Hello World", "Hello") - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Contains("Hello World", "Salut") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotContainsWrapper(t *testing.T) { - require := New(t) - require.NotContains("Hello World", "Hello!") - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotContains("Hello World", "Hello") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestPanicsWrapper(t *testing.T) { - require := New(t) - require.Panics(func() { - panic("Panic!") - }) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Panics(func() {}) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotPanicsWrapper(t *testing.T) { - require := New(t) - require.NotPanics(func() {}) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotPanics(func() { - panic("Panic!") - }) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNoErrorWrapper(t *testing.T) { - require := New(t) - require.NoError(nil) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NoError(errors.New("some error")) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestErrorWrapper(t *testing.T) { - require := New(t) - require.Error(errors.New("some error")) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Error(nil) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEqualErrorWrapper(t *testing.T) { - require := New(t) - require.EqualError(errors.New("some error"), "some error") - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.EqualError(errors.New("some error"), "Not some error") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEmptyWrapper(t *testing.T) { - require := New(t) - require.Empty("") - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Empty("x") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotEmptyWrapper(t *testing.T) { - require := New(t) - require.NotEmpty("x") - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotEmpty("") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestWithinDurationWrapper(t *testing.T) { - require := New(t) - a := time.Now() - b := a.Add(10 * time.Second) - - require.WithinDuration(a, b, 15*time.Second) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.WithinDuration(a, b, 5*time.Second) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestInDeltaWrapper(t *testing.T) { - require := New(t) - require.InDelta(1.001, 1, 0.01) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.InDelta(1, 2, 0.5) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestZeroWrapper(t *testing.T) { - require := New(t) - require.Zero(0) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.Zero(1) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotZeroWrapper(t *testing.T) { - require := New(t) - require.NotZero(1) - - mockT := new(MockT) - mockRequire := New(mockT) - mockRequire.NotZero(0) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_EqualSONString(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", - "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEqWrapper_Array(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`{"foo": "bar"}`, "Not JSON") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq("Not JSON", "Not JSON") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) { - mockT := new(MockT) - mockRequire := New(mockT) - - mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) - if !mockT.Failed { - t.Error("Check should fail") - } -} diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go deleted file mode 100644 index 535f293..0000000 --- a/vendor/github.com/stretchr/testify/require/require.go +++ /dev/null @@ -1,1227 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package require - -import ( - assert "github.com/stretchr/testify/assert" - http "net/http" - url "net/url" - time "time" -) - -// Condition uses a Comparison to assert a complex condition. -func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) { - if assert.Condition(t, comp, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Conditionf uses a Comparison to assert a complex condition. -func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) { - if assert.Conditionf(t, comp, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Contains(t, "Hello World", "World") -// assert.Contains(t, ["Hello", "World"], "World") -// assert.Contains(t, {"Hello": "World"}, "Hello") -func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if assert.Contains(t, s, contains, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") -// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") -// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") -func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { - if assert.Containsf(t, s, contains, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExists(t TestingT, path string, msgAndArgs ...interface{}) { - if assert.DirExists(t, path, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func DirExistsf(t TestingT, path string, msg string, args ...interface{}) { - if assert.DirExistsf(t, path, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) -func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) { - if assert.ElementsMatch(t, listA, listB, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) { - if assert.ElementsMatchf(t, listA, listB, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Empty(t, obj) -func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.Empty(t, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// assert.Emptyf(t, obj, "error message %s", "formatted") -func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.Emptyf(t, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Equal asserts that two objects are equal. -// -// assert.Equal(t, 123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.Equal(t, expected, actual, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualError(t, err, expectedErrorString) -func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { - if assert.EqualError(t, theError, errString, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") -func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) { - if assert.EqualErrorf(t, theError, errString, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValues(t, uint32(123), int32(123)) -func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.EqualValues(t, expected, actual, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) -func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.EqualValuesf(t, expected, actual, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Equalf asserts that two objects are equal. -// -// assert.Equalf(t, 123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.Equalf(t, expected, actual, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } -func Error(t TestingT, err error, msgAndArgs ...interface{}) { - if assert.Error(t, err, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func Errorf(t TestingT, err error, msg string, args ...interface{}) { - if assert.Errorf(t, err, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Exactly asserts that two objects are equal in value and type. -// -// assert.Exactly(t, int32(123), int64(123)) -func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.Exactly(t, expected, actual, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) -func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.Exactlyf(t, expected, actual, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Fail reports a failure through -func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) { - if assert.Fail(t, failureMessage, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// FailNow fails test -func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) { - if assert.FailNow(t, failureMessage, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// FailNowf fails test -func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) { - if assert.FailNowf(t, failureMessage, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Failf reports a failure through -func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { - if assert.Failf(t, failureMessage, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// False asserts that the specified value is false. -// -// assert.False(t, myBool) -func False(t TestingT, value bool, msgAndArgs ...interface{}) { - if assert.False(t, value, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Falsef asserts that the specified value is false. -// -// assert.Falsef(t, myBool, "error message %s", "formatted") -func Falsef(t TestingT, value bool, msg string, args ...interface{}) { - if assert.Falsef(t, value, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExists(t TestingT, path string, msgAndArgs ...interface{}) { - if assert.FileExists(t, path, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { - if assert.FileExistsf(t, path, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Implements asserts that an object is implemented by the specified interface. -// -// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) -func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { - if assert.Implements(t, interfaceObject, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { - if assert.Implementsf(t, interfaceObject, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) -func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if assert.InDeltaf(t, expected, actual, delta, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// IsType asserts that the specified objects are of the same type. -func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { - if assert.IsType(t, expectedType, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// IsTypef asserts that the specified objects are of the same type. -func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) { - if assert.IsTypef(t, expectedType, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { - if assert.JSONEq(t, expected, actual, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { - if assert.JSONEqf(t, expected, actual, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// assert.Len(t, mySlice, 3) -func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { - if assert.Len(t, object, length, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") -func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { - if assert.Lenf(t, object, length, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Nil asserts that the specified object is nil. -// -// assert.Nil(t, err) -func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.Nil(t, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Nilf asserts that the specified object is nil. -// -// assert.Nilf(t, err, "error message %s", "formatted") -func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.Nilf(t, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoError(t, err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoError(t TestingT, err error, msgAndArgs ...interface{}) { - if assert.NoError(t, err, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if assert.NoErrorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { - if assert.NoErrorf(t, err, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContains(t, "Hello World", "Earth") -// assert.NotContains(t, ["Hello", "World"], "Earth") -// assert.NotContains(t, {"Hello": "World"}, "Earth") -func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if assert.NotContains(t, s, contains, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") -func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { - if assert.NotContainsf(t, s, contains, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmpty(t, obj) { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.NotEmpty(t, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.NotEmptyf(t, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotEqual asserts that the specified values are NOT equal. -// -// assert.NotEqual(t, obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if assert.NotEqual(t, expected, actual, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { - if assert.NotEqualf(t, expected, actual, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotNil asserts that the specified object is not nil. -// -// assert.NotNil(t, err) -func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { - if assert.NotNil(t, object, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotNilf asserts that the specified object is not nil. -// -// assert.NotNilf(t, err, "error message %s", "formatted") -func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { - if assert.NotNilf(t, object, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanics(t, func(){ RemainCalm() }) -func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.NotPanics(t, f, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") -func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.NotPanicsf(t, f, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") -// assert.NotRegexp(t, "^start", "it's not starting") -func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if assert.NotRegexp(t, rx, str, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") -func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { - if assert.NotRegexpf(t, rx, str, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if assert.NotSubset(t, list, subset, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { - if assert.NotSubsetf(t, list, subset, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotZero asserts that i is not the zero value for its type. -func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) { - if assert.NotZero(t, i, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// NotZerof asserts that i is not the zero value for its type. -func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { - if assert.NotZerof(t, i, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panics(t, func(){ GoCrazy() }) -func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.Panics(t, f, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) -func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.PanicsWithValuef(t, expected, f, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") -func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { - if assert.Panicsf(t, f, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Regexp asserts that a specified regexp matches a string. -// -// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") -// assert.Regexp(t, "start...$", "it's not starting") -func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if assert.Regexp(t, rx, str, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Regexpf asserts that a specified regexp matches a string. -// -// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") -func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { - if assert.Regexpf(t, rx, str, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if assert.Subset(t, list, subset, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { - if assert.Subsetf(t, list, subset, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// True asserts that the specified value is true. -// -// assert.True(t, myBool) -func True(t TestingT, value bool, msgAndArgs ...interface{}) { - if assert.True(t, value, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Truef asserts that the specified value is true. -// -// assert.Truef(t, myBool, "error message %s", "formatted") -func Truef(t TestingT, value bool, msg string, args ...interface{}) { - if assert.Truef(t, value, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) -func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { - if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { - if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Zero asserts that i is the zero value for its type. -func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) { - if assert.Zero(t, i, msgAndArgs...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} - -// Zerof asserts that i is the zero value for its type. -func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) { - if assert.Zerof(t, i, msg, args...) { - return - } - if h, ok := t.(tHelper); ok { - h.Helper() - } - t.FailNow() -} diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl deleted file mode 100644 index 6ffc751..0000000 --- a/vendor/github.com/stretchr/testify/require/require.go.tmpl +++ /dev/null @@ -1,6 +0,0 @@ -{{.Comment}} -func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { - if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } - if h, ok := t.(tHelper); ok { h.Helper() } - t.FailNow() -} diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go deleted file mode 100644 index 9fe41db..0000000 --- a/vendor/github.com/stretchr/testify/require/require_forward.go +++ /dev/null @@ -1,957 +0,0 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ - -package require - -import ( - assert "github.com/stretchr/testify/assert" - http "net/http" - url "net/url" - time "time" -) - -// Condition uses a Comparison to assert a complex condition. -func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Condition(a.t, comp, msgAndArgs...) -} - -// Conditionf uses a Comparison to assert a complex condition. -func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Conditionf(a.t, comp, msg, args...) -} - -// Contains asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Contains("Hello World", "World") -// a.Contains(["Hello", "World"], "World") -// a.Contains({"Hello": "World"}, "Hello") -func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Contains(a.t, s, contains, msgAndArgs...) -} - -// Containsf asserts that the specified string, list(array, slice...) or map contains the -// specified substring or element. -// -// a.Containsf("Hello World", "World", "error message %s", "formatted") -// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") -// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") -func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Containsf(a.t, s, contains, msg, args...) -} - -// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - DirExists(a.t, path, msgAndArgs...) -} - -// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. -func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - DirExistsf(a.t, path, msg, args...) -} - -// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) -func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - ElementsMatch(a.t, listA, listB, msgAndArgs...) -} - -// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified -// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, -// the number of appearances of each of them in both lists should match. -// -// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") -func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - ElementsMatchf(a.t, listA, listB, msg, args...) -} - -// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Empty(obj) -func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Empty(a.t, object, msgAndArgs...) -} - -// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// a.Emptyf(obj, "error message %s", "formatted") -func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Emptyf(a.t, object, msg, args...) -} - -// Equal asserts that two objects are equal. -// -// a.Equal(123, 123) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Equal(a.t, expected, actual, msgAndArgs...) -} - -// EqualError asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualError(err, expectedErrorString) -func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - EqualError(a.t, theError, errString, msgAndArgs...) -} - -// EqualErrorf asserts that a function returned an error (i.e. not `nil`) -// and that it is equal to the provided error. -// -// actualObj, err := SomeFunction() -// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") -func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - EqualErrorf(a.t, theError, errString, msg, args...) -} - -// EqualValues asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValues(uint32(123), int32(123)) -func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - EqualValues(a.t, expected, actual, msgAndArgs...) -} - -// EqualValuesf asserts that two objects are equal or convertable to the same types -// and equal. -// -// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123)) -func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - EqualValuesf(a.t, expected, actual, msg, args...) -} - -// Equalf asserts that two objects are equal. -// -// a.Equalf(123, 123, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). Function equality -// cannot be determined and will always fail. -func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Equalf(a.t, expected, actual, msg, args...) -} - -// Error asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } -func (a *Assertions) Error(err error, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Error(a.t, err, msgAndArgs...) -} - -// Errorf asserts that a function returned an error (i.e. not `nil`). -// -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } -func (a *Assertions) Errorf(err error, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Errorf(a.t, err, msg, args...) -} - -// Exactly asserts that two objects are equal in value and type. -// -// a.Exactly(int32(123), int64(123)) -func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Exactly(a.t, expected, actual, msgAndArgs...) -} - -// Exactlyf asserts that two objects are equal in value and type. -// -// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) -func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Exactlyf(a.t, expected, actual, msg, args...) -} - -// Fail reports a failure through -func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Fail(a.t, failureMessage, msgAndArgs...) -} - -// FailNow fails test -func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - FailNow(a.t, failureMessage, msgAndArgs...) -} - -// FailNowf fails test -func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - FailNowf(a.t, failureMessage, msg, args...) -} - -// Failf reports a failure through -func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Failf(a.t, failureMessage, msg, args...) -} - -// False asserts that the specified value is false. -// -// a.False(myBool) -func (a *Assertions) False(value bool, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - False(a.t, value, msgAndArgs...) -} - -// Falsef asserts that the specified value is false. -// -// a.Falsef(myBool, "error message %s", "formatted") -func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Falsef(a.t, value, msg, args...) -} - -// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - FileExists(a.t, path, msgAndArgs...) -} - -// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. -func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - FileExistsf(a.t, path, msg, args...) -} - -// HTTPBodyContains asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyContainsf asserts that a specified handler returns a -// body that contains a string. -// -// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPBodyNotContains asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...) -} - -// HTTPBodyNotContainsf asserts that a specified handler returns a -// body that does not contain a string. -// -// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...) -} - -// HTTPError asserts that a specified handler returns an error status code. -// -// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPError(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPErrorf asserts that a specified handler returns an error status code. -// -// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPErrorf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPRedirect asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPRedirectf asserts that a specified handler returns a redirect status code. -// -// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} -// -// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). -func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPRedirectf(a.t, handler, method, url, values, msg, args...) -} - -// HTTPSuccess asserts that a specified handler returns a success status code. -// -// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...) -} - -// HTTPSuccessf asserts that a specified handler returns a success status code. -// -// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") -// -// Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - HTTPSuccessf(a.t, handler, method, url, values, msg, args...) -} - -// Implements asserts that an object is implemented by the specified interface. -// -// a.Implements((*MyInterface)(nil), new(MyObject)) -func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Implements(a.t, interfaceObject, object, msgAndArgs...) -} - -// Implementsf asserts that an object is implemented by the specified interface. -// -// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) -func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Implementsf(a.t, interfaceObject, object, msg, args...) -} - -// InDelta asserts that the two numerals are within delta of each other. -// -// a.InDelta(math.Pi, (22 / 7.0), 0.01) -func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDelta(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. -func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaSlice is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...) -} - -// InDeltaSlicef is the same as InDelta, except it compares two slices. -func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDeltaSlicef(a.t, expected, actual, delta, msg, args...) -} - -// InDeltaf asserts that the two numerals are within delta of each other. -// -// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) -func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InDeltaf(a.t, expected, actual, delta, msg, args...) -} - -// InEpsilon asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...) -} - -// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. -func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...) -} - -// InEpsilonf asserts that expected and actual have a relative error less than epsilon -func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - InEpsilonf(a.t, expected, actual, epsilon, msg, args...) -} - -// IsType asserts that the specified objects are of the same type. -func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - IsType(a.t, expectedType, object, msgAndArgs...) -} - -// IsTypef asserts that the specified objects are of the same type. -func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - IsTypef(a.t, expectedType, object, msg, args...) -} - -// JSONEq asserts that two JSON strings are equivalent. -// -// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - JSONEq(a.t, expected, actual, msgAndArgs...) -} - -// JSONEqf asserts that two JSON strings are equivalent. -// -// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") -func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - JSONEqf(a.t, expected, actual, msg, args...) -} - -// Len asserts that the specified object has specific length. -// Len also fails if the object has a type that len() not accept. -// -// a.Len(mySlice, 3) -func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Len(a.t, object, length, msgAndArgs...) -} - -// Lenf asserts that the specified object has specific length. -// Lenf also fails if the object has a type that len() not accept. -// -// a.Lenf(mySlice, 3, "error message %s", "formatted") -func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Lenf(a.t, object, length, msg, args...) -} - -// Nil asserts that the specified object is nil. -// -// a.Nil(err) -func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Nil(a.t, object, msgAndArgs...) -} - -// Nilf asserts that the specified object is nil. -// -// a.Nilf(err, "error message %s", "formatted") -func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Nilf(a.t, object, msg, args...) -} - -// NoError asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NoError(a.t, err, msgAndArgs...) -} - -// NoErrorf asserts that a function returned no error (i.e. `nil`). -// -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } -func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NoErrorf(a.t, err, msg, args...) -} - -// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContains("Hello World", "Earth") -// a.NotContains(["Hello", "World"], "Earth") -// a.NotContains({"Hello": "World"}, "Earth") -func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotContains(a.t, s, contains, msgAndArgs...) -} - -// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the -// specified substring or element. -// -// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") -// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") -// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") -func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotContainsf(a.t, s, contains, msg, args...) -} - -// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotEmpty(a.t, object, msgAndArgs...) -} - -// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either -// a slice or a channel with len == 0. -// -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } -func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotEmptyf(a.t, object, msg, args...) -} - -// NotEqual asserts that the specified values are NOT equal. -// -// a.NotEqual(obj1, obj2) -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotEqual(a.t, expected, actual, msgAndArgs...) -} - -// NotEqualf asserts that the specified values are NOT equal. -// -// a.NotEqualf(obj1, obj2, "error message %s", "formatted") -// -// Pointer variable equality is determined based on the equality of the -// referenced values (as opposed to the memory addresses). -func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotEqualf(a.t, expected, actual, msg, args...) -} - -// NotNil asserts that the specified object is not nil. -// -// a.NotNil(err) -func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotNil(a.t, object, msgAndArgs...) -} - -// NotNilf asserts that the specified object is not nil. -// -// a.NotNilf(err, "error message %s", "formatted") -func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotNilf(a.t, object, msg, args...) -} - -// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanics(func(){ RemainCalm() }) -func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotPanics(a.t, f, msgAndArgs...) -} - -// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. -// -// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") -func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotPanicsf(a.t, f, msg, args...) -} - -// NotRegexp asserts that a specified regexp does not match a string. -// -// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") -// a.NotRegexp("^start", "it's not starting") -func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotRegexp(a.t, rx, str, msgAndArgs...) -} - -// NotRegexpf asserts that a specified regexp does not match a string. -// -// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") -// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") -func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotRegexpf(a.t, rx, str, msg, args...) -} - -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") -func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotSubset(a.t, list, subset, msgAndArgs...) -} - -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). -// -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotSubsetf(a.t, list, subset, msg, args...) -} - -// NotZero asserts that i is not the zero value for its type. -func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotZero(a.t, i, msgAndArgs...) -} - -// NotZerof asserts that i is not the zero value for its type. -func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - NotZerof(a.t, i, msg, args...) -} - -// Panics asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panics(func(){ GoCrazy() }) -func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Panics(a.t, f, msgAndArgs...) -} - -// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) -func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - PanicsWithValue(a.t, expected, f, msgAndArgs...) -} - -// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that -// the recovered panic value equals the expected panic value. -// -// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - PanicsWithValuef(a.t, expected, f, msg, args...) -} - -// Panicsf asserts that the code inside the specified PanicTestFunc panics. -// -// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") -func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Panicsf(a.t, f, msg, args...) -} - -// Regexp asserts that a specified regexp matches a string. -// -// a.Regexp(regexp.MustCompile("start"), "it's starting") -// a.Regexp("start...$", "it's not starting") -func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Regexp(a.t, rx, str, msgAndArgs...) -} - -// Regexpf asserts that a specified regexp matches a string. -// -// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") -// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") -func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Regexpf(a.t, rx, str, msg, args...) -} - -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") -func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Subset(a.t, list, subset, msgAndArgs...) -} - -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). -// -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") -func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Subsetf(a.t, list, subset, msg, args...) -} - -// True asserts that the specified value is true. -// -// a.True(myBool) -func (a *Assertions) True(value bool, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - True(a.t, value, msgAndArgs...) -} - -// Truef asserts that the specified value is true. -// -// a.Truef(myBool, "error message %s", "formatted") -func (a *Assertions) Truef(value bool, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Truef(a.t, value, msg, args...) -} - -// WithinDuration asserts that the two times are within duration delta of each other. -// -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) -func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - WithinDuration(a.t, expected, actual, delta, msgAndArgs...) -} - -// WithinDurationf asserts that the two times are within duration delta of each other. -// -// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") -func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - WithinDurationf(a.t, expected, actual, delta, msg, args...) -} - -// Zero asserts that i is the zero value for its type. -func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Zero(a.t, i, msgAndArgs...) -} - -// Zerof asserts that i is the zero value for its type. -func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) { - if h, ok := a.t.(tHelper); ok { - h.Helper() - } - Zerof(a.t, i, msg, args...) -} diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl deleted file mode 100644 index 54124df..0000000 --- a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{.CommentWithoutT "a"}} -func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { - if h, ok := a.t.(tHelper); ok { h.Helper() } - {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) -} diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go deleted file mode 100644 index 690583a..0000000 --- a/vendor/github.com/stretchr/testify/require/requirements.go +++ /dev/null @@ -1,29 +0,0 @@ -package require - -// TestingT is an interface wrapper around *testing.T -type TestingT interface { - Errorf(format string, args ...interface{}) - FailNow() -} - -type tHelper interface { - Helper() -} - -// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful -// for table driven tests. -type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) - -// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful -// for table driven tests. -type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) - -// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful -// for table driven tests. -type BoolAssertionFunc func(TestingT, bool, ...interface{}) - -// ValuesAssertionFunc is a common function prototype when validating an error value. Can be useful -// for table driven tests. -type ErrorAssertionFunc func(TestingT, error, ...interface{}) - -//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/require/requirements_test.go b/vendor/github.com/stretchr/testify/require/requirements_test.go deleted file mode 100644 index 39467d9..0000000 --- a/vendor/github.com/stretchr/testify/require/requirements_test.go +++ /dev/null @@ -1,566 +0,0 @@ -package require - -import ( - "encoding/json" - "errors" - "testing" - "time" -) - -// AssertionTesterInterface defines an interface to be used for testing assertion methods -type AssertionTesterInterface interface { - TestMethod() -} - -// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface -type AssertionTesterConformingObject struct { -} - -func (a *AssertionTesterConformingObject) TestMethod() { -} - -// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface -type AssertionTesterNonConformingObject struct { -} - -type MockT struct { - Failed bool -} - -func (t *MockT) FailNow() { - t.Failed = true -} - -func (t *MockT) Errorf(format string, args ...interface{}) { - _, _ = format, args -} - -func TestImplements(t *testing.T) { - - Implements(t, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) - - mockT := new(MockT) - Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestIsType(t *testing.T) { - - IsType(t, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) - - mockT := new(MockT) - IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEqual(t *testing.T) { - - Equal(t, 1, 1) - - mockT := new(MockT) - Equal(mockT, 1, 2) - if !mockT.Failed { - t.Error("Check should fail") - } - -} - -func TestNotEqual(t *testing.T) { - - NotEqual(t, 1, 2) - mockT := new(MockT) - NotEqual(mockT, 2, 2) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestExactly(t *testing.T) { - - a := float32(1) - b := float32(1) - c := float64(1) - - Exactly(t, a, b) - - mockT := new(MockT) - Exactly(mockT, a, c) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotNil(t *testing.T) { - - NotNil(t, new(AssertionTesterConformingObject)) - - mockT := new(MockT) - NotNil(mockT, nil) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNil(t *testing.T) { - - Nil(t, nil) - - mockT := new(MockT) - Nil(mockT, new(AssertionTesterConformingObject)) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestTrue(t *testing.T) { - - True(t, true) - - mockT := new(MockT) - True(mockT, false) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestFalse(t *testing.T) { - - False(t, false) - - mockT := new(MockT) - False(mockT, true) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestContains(t *testing.T) { - - Contains(t, "Hello World", "Hello") - - mockT := new(MockT) - Contains(mockT, "Hello World", "Salut") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotContains(t *testing.T) { - - NotContains(t, "Hello World", "Hello!") - - mockT := new(MockT) - NotContains(mockT, "Hello World", "Hello") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestPanics(t *testing.T) { - - Panics(t, func() { - panic("Panic!") - }) - - mockT := new(MockT) - Panics(mockT, func() {}) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotPanics(t *testing.T) { - - NotPanics(t, func() {}) - - mockT := new(MockT) - NotPanics(mockT, func() { - panic("Panic!") - }) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNoError(t *testing.T) { - - NoError(t, nil) - - mockT := new(MockT) - NoError(mockT, errors.New("some error")) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestError(t *testing.T) { - - Error(t, errors.New("some error")) - - mockT := new(MockT) - Error(mockT, nil) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEqualError(t *testing.T) { - - EqualError(t, errors.New("some error"), "some error") - - mockT := new(MockT) - EqualError(mockT, errors.New("some error"), "Not some error") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestEmpty(t *testing.T) { - - Empty(t, "") - - mockT := new(MockT) - Empty(mockT, "x") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotEmpty(t *testing.T) { - - NotEmpty(t, "x") - - mockT := new(MockT) - NotEmpty(mockT, "") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestWithinDuration(t *testing.T) { - - a := time.Now() - b := a.Add(10 * time.Second) - - WithinDuration(t, a, b, 15*time.Second) - - mockT := new(MockT) - WithinDuration(mockT, a, b, 5*time.Second) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestInDelta(t *testing.T) { - - InDelta(t, 1.001, 1, 0.01) - - mockT := new(MockT) - InDelta(mockT, 1, 2, 0.5) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestZero(t *testing.T) { - - Zero(t, "") - - mockT := new(MockT) - Zero(mockT, "x") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestNotZero(t *testing.T) { - - NotZero(t, "x") - - mockT := new(MockT) - NotZero(mockT, "") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_EqualSONString(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEq_EquivalentButNotEqual(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEq_HashOfArraysAndHashes(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, "{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", - "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEq_Array(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) - if mockT.Failed { - t.Error("Check should pass") - } -} - -func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_HashesNotEquivalent(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_ActualIsNotJSON(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `{"foo": "bar"}`, "Not JSON") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_ExpectedIsNotJSON(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, "Not JSON", `{"foo": "bar", "hello": "world"}`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, "Not JSON", "Not JSON") - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) { - mockT := new(MockT) - JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) - if !mockT.Failed { - t.Error("Check should fail") - } -} - -func ExampleComparisonAssertionFunc() { - t := &testing.T{} // provided by test - - adder := func(x, y int) int { - return x + y - } - - type args struct { - x int - y int - } - - tests := []struct { - name string - args args - expect int - assertion ComparisonAssertionFunc - }{ - {"2+2=4", args{2, 2}, 4, Equal}, - {"2+2!=5", args{2, 2}, 5, NotEqual}, - {"2+3==5", args{2, 3}, 5, Exactly}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y)) - }) - } -} - -func TestComparisonAssertionFunc(t *testing.T) { - type iface interface { - Name() string - } - - tests := []struct { - name string - expect interface{} - got interface{} - assertion ComparisonAssertionFunc - }{ - {"implements", (*iface)(nil), t, Implements}, - {"isType", (*testing.T)(nil), t, IsType}, - {"equal", t, t, Equal}, - {"equalValues", t, t, EqualValues}, - {"exactly", t, t, Exactly}, - {"notEqual", t, nil, NotEqual}, - {"notContains", []int{1, 2, 3}, 4, NotContains}, - {"subset", []int{1, 2, 3, 4}, []int{2, 3}, Subset}, - {"notSubset", []int{1, 2, 3, 4}, []int{0, 3}, NotSubset}, - {"elementsMatch", []byte("abc"), []byte("bac"), ElementsMatch}, - {"regexp", "^t.*y$", "testify", Regexp}, - {"notRegexp", "^t.*y$", "Testify", NotRegexp}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.expect, tt.got) - }) - } -} - -func ExampleValueAssertionFunc() { - t := &testing.T{} // provided by test - - dumbParse := func(input string) interface{} { - var x interface{} - json.Unmarshal([]byte(input), &x) - return x - } - - tests := []struct { - name string - arg string - assertion ValueAssertionFunc - }{ - {"true is not nil", "true", NotNil}, - {"empty string is nil", "", Nil}, - {"zero is not nil", "0", NotNil}, - {"zero is zero", "0", Zero}, - {"false is zero", "false", Zero}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, dumbParse(tt.arg)) - }) - } -} - -func TestValueAssertionFunc(t *testing.T) { - tests := []struct { - name string - value interface{} - assertion ValueAssertionFunc - }{ - {"notNil", true, NotNil}, - {"nil", nil, Nil}, - {"empty", []int{}, Empty}, - {"notEmpty", []int{1}, NotEmpty}, - {"zero", false, Zero}, - {"notZero", 42, NotZero}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.value) - }) - } -} - -func ExampleBoolAssertionFunc() { - t := &testing.T{} // provided by test - - isOkay := func(x int) bool { - return x >= 42 - } - - tests := []struct { - name string - arg int - assertion BoolAssertionFunc - }{ - {"-1 is bad", -1, False}, - {"42 is good", 42, True}, - {"41 is bad", 41, False}, - {"45 is cool", 45, True}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, isOkay(tt.arg)) - }) - } -} - -func TestBoolAssertionFunc(t *testing.T) { - tests := []struct { - name string - value bool - assertion BoolAssertionFunc - }{ - {"true", true, True}, - {"false", false, False}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.value) - }) - } -} - -func ExampleErrorAssertionFunc() { - t := &testing.T{} // provided by test - - dumbParseNum := func(input string, v interface{}) error { - return json.Unmarshal([]byte(input), v) - } - - tests := []struct { - name string - arg string - assertion ErrorAssertionFunc - }{ - {"1.2 is number", "1.2", NoError}, - {"1.2.3 not number", "1.2.3", Error}, - {"true is not number", "true", Error}, - {"3 is number", "3", NoError}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var x float64 - tt.assertion(t, dumbParseNum(tt.arg, &x)) - }) - } -} - -func TestErrorAssertionFunc(t *testing.T) { - tests := []struct { - name string - err error - assertion ErrorAssertionFunc - }{ - {"noError", nil, NoError}, - {"error", errors.New("whoops"), Error}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.assertion(t, tt.err) - }) - } -} diff --git a/vendor/github.com/stretchr/testify/suite/doc.go b/vendor/github.com/stretchr/testify/suite/doc.go deleted file mode 100644 index f91a245..0000000 --- a/vendor/github.com/stretchr/testify/suite/doc.go +++ /dev/null @@ -1,65 +0,0 @@ -// Package suite contains logic for creating testing suite structs -// and running the methods on those structs as tests. The most useful -// piece of this package is that you can create setup/teardown methods -// on your testing suites, which will run before/after the whole suite -// or individual tests (depending on which interface(s) you -// implement). -// -// A testing suite is usually built by first extending the built-in -// suite functionality from suite.Suite in testify. Alternatively, -// you could reproduce that logic on your own if you wanted (you -// just need to implement the TestingSuite interface from -// suite/interfaces.go). -// -// After that, you can implement any of the interfaces in -// suite/interfaces.go to add setup/teardown functionality to your -// suite, and add any methods that start with "Test" to add tests. -// Methods that do not match any suite interfaces and do not begin -// with "Test" will not be run by testify, and can safely be used as -// helper methods. -// -// Once you've built your testing suite, you need to run the suite -// (using suite.Run from testify) inside any function that matches the -// identity that "go test" is already looking for (i.e. -// func(*testing.T)). -// -// Regular expression to select test suites specified command-line -// argument "-run". Regular expression to select the methods -// of test suites specified command-line argument "-m". -// Suite object has assertion methods. -// -// A crude example: -// // Basic imports -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// "github.com/stretchr/testify/suite" -// ) -// -// // Define the suite, and absorb the built-in basic suite -// // functionality from testify - including a T() method which -// // returns the current testing context -// type ExampleTestSuite struct { -// suite.Suite -// VariableThatShouldStartAtFive int -// } -// -// // Make sure that VariableThatShouldStartAtFive is set to five -// // before each test -// func (suite *ExampleTestSuite) SetupTest() { -// suite.VariableThatShouldStartAtFive = 5 -// } -// -// // All methods that begin with "Test" are run as tests within a -// // suite. -// func (suite *ExampleTestSuite) TestExample() { -// assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) -// suite.Equal(5, suite.VariableThatShouldStartAtFive) -// } -// -// // In order for 'go test' to run this suite, we need to create -// // a normal test function and pass our suite to suite.Run -// func TestExampleTestSuite(t *testing.T) { -// suite.Run(t, new(ExampleTestSuite)) -// } -package suite diff --git a/vendor/github.com/stretchr/testify/suite/interfaces.go b/vendor/github.com/stretchr/testify/suite/interfaces.go deleted file mode 100644 index b37cb04..0000000 --- a/vendor/github.com/stretchr/testify/suite/interfaces.go +++ /dev/null @@ -1,46 +0,0 @@ -package suite - -import "testing" - -// TestingSuite can store and return the current *testing.T context -// generated by 'go test'. -type TestingSuite interface { - T() *testing.T - SetT(*testing.T) -} - -// SetupAllSuite has a SetupSuite method, which will run before the -// tests in the suite are run. -type SetupAllSuite interface { - SetupSuite() -} - -// SetupTestSuite has a SetupTest method, which will run before each -// test in the suite. -type SetupTestSuite interface { - SetupTest() -} - -// TearDownAllSuite has a TearDownSuite method, which will run after -// all the tests in the suite have been run. -type TearDownAllSuite interface { - TearDownSuite() -} - -// TearDownTestSuite has a TearDownTest method, which will run after -// each test in the suite. -type TearDownTestSuite interface { - TearDownTest() -} - -// BeforeTest has a function to be executed right before the test -// starts and receives the suite and test names as input -type BeforeTest interface { - BeforeTest(suiteName, testName string) -} - -// AfterTest has a function to be executed right after the test -// finishes and receives the suite and test names as input -type AfterTest interface { - AfterTest(suiteName, testName string) -} diff --git a/vendor/github.com/stretchr/testify/suite/suite.go b/vendor/github.com/stretchr/testify/suite/suite.go deleted file mode 100644 index e20afbc..0000000 --- a/vendor/github.com/stretchr/testify/suite/suite.go +++ /dev/null @@ -1,136 +0,0 @@ -package suite - -import ( - "flag" - "fmt" - "os" - "reflect" - "regexp" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -var allTestsFilter = func(_, _ string) (bool, error) { return true, nil } -var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run") - -// Suite is a basic testing suite with methods for storing and -// retrieving the current *testing.T context. -type Suite struct { - *assert.Assertions - require *require.Assertions - t *testing.T -} - -// T retrieves the current *testing.T context. -func (suite *Suite) T() *testing.T { - return suite.t -} - -// SetT sets the current *testing.T context. -func (suite *Suite) SetT(t *testing.T) { - suite.t = t - suite.Assertions = assert.New(t) - suite.require = require.New(t) -} - -// Require returns a require context for suite. -func (suite *Suite) Require() *require.Assertions { - if suite.require == nil { - suite.require = require.New(suite.T()) - } - return suite.require -} - -// Assert returns an assert context for suite. Normally, you can call -// `suite.NoError(expected, actual)`, but for situations where the embedded -// methods are overridden (for example, you might want to override -// assert.Assertions with require.Assertions), this method is provided so you -// can call `suite.Assert().NoError()`. -func (suite *Suite) Assert() *assert.Assertions { - if suite.Assertions == nil { - suite.Assertions = assert.New(suite.T()) - } - return suite.Assertions -} - -// Run takes a testing suite and runs all of the tests attached -// to it. -func Run(t *testing.T, suite TestingSuite) { - suite.SetT(t) - - if setupAllSuite, ok := suite.(SetupAllSuite); ok { - setupAllSuite.SetupSuite() - } - defer func() { - if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok { - tearDownAllSuite.TearDownSuite() - } - }() - - methodFinder := reflect.TypeOf(suite) - tests := []testing.InternalTest{} - for index := 0; index < methodFinder.NumMethod(); index++ { - method := methodFinder.Method(index) - ok, err := methodFilter(method.Name) - if err != nil { - fmt.Fprintf(os.Stderr, "testify: invalid regexp for -m: %s\n", err) - os.Exit(1) - } - if ok { - test := testing.InternalTest{ - Name: method.Name, - F: func(t *testing.T) { - parentT := suite.T() - suite.SetT(t) - if setupTestSuite, ok := suite.(SetupTestSuite); ok { - setupTestSuite.SetupTest() - } - if beforeTestSuite, ok := suite.(BeforeTest); ok { - beforeTestSuite.BeforeTest(methodFinder.Elem().Name(), method.Name) - } - defer func() { - if afterTestSuite, ok := suite.(AfterTest); ok { - afterTestSuite.AfterTest(methodFinder.Elem().Name(), method.Name) - } - if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok { - tearDownTestSuite.TearDownTest() - } - suite.SetT(parentT) - }() - method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) - }, - } - tests = append(tests, test) - } - } - runTests(t, tests) -} - -func runTests(t testing.TB, tests []testing.InternalTest) { - r, ok := t.(runner) - if !ok { // backwards compatibility with Go 1.6 and below - if !testing.RunTests(allTestsFilter, tests) { - t.Fail() - } - return - } - - for _, test := range tests { - r.Run(test.Name, test.F) - } -} - -// Filtering method according to set regular expression -// specified command-line argument -m -func methodFilter(name string) (bool, error) { - if ok, _ := regexp.MatchString("^Test", name); !ok { - return false, nil - } - return regexp.MatchString(*matchMethod, name) -} - -type runner interface { - Run(name string, f func(t *testing.T)) bool -} diff --git a/vendor/github.com/stretchr/testify/suite/suite_test.go b/vendor/github.com/stretchr/testify/suite/suite_test.go deleted file mode 100644 index b75fa4a..0000000 --- a/vendor/github.com/stretchr/testify/suite/suite_test.go +++ /dev/null @@ -1,294 +0,0 @@ -package suite - -import ( - "errors" - "io/ioutil" - "os" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -// SuiteRequireTwice is intended to test the usage of suite.Require in two -// different tests -type SuiteRequireTwice struct{ Suite } - -// TestSuiteRequireTwice checks for regressions of issue #149 where -// suite.requirements was not initialised in suite.SetT() -// A regression would result on these tests panicking rather than failing. -func TestSuiteRequireTwice(t *testing.T) { - ok := testing.RunTests( - allTestsFilter, - []testing.InternalTest{{ - Name: "TestSuiteRequireTwice", - F: func(t *testing.T) { - suite := new(SuiteRequireTwice) - Run(t, suite) - }, - }}, - ) - assert.Equal(t, false, ok) -} - -func (s *SuiteRequireTwice) TestRequireOne() { - r := s.Require() - r.Equal(1, 2) -} - -func (s *SuiteRequireTwice) TestRequireTwo() { - r := s.Require() - r.Equal(1, 2) -} - -// This suite is intended to store values to make sure that only -// testing-suite-related methods are run. It's also a fully -// functional example of a testing suite, using setup/teardown methods -// and a helper method that is ignored by testify. To make this look -// more like a real world example, all tests in the suite perform some -// type of assertion. -type SuiteTester struct { - // Include our basic suite logic. - Suite - - // Keep counts of how many times each method is run. - SetupSuiteRunCount int - TearDownSuiteRunCount int - SetupTestRunCount int - TearDownTestRunCount int - TestOneRunCount int - TestTwoRunCount int - NonTestMethodRunCount int - - SuiteNameBefore []string - TestNameBefore []string - - SuiteNameAfter []string - TestNameAfter []string - - TimeBefore []time.Time - TimeAfter []time.Time -} - -type SuiteSkipTester struct { - // Include our basic suite logic. - Suite - - // Keep counts of how many times each method is run. - SetupSuiteRunCount int - TearDownSuiteRunCount int -} - -// The SetupSuite method will be run by testify once, at the very -// start of the testing suite, before any tests are run. -func (suite *SuiteTester) SetupSuite() { - suite.SetupSuiteRunCount++ -} - -func (suite *SuiteTester) BeforeTest(suiteName, testName string) { - suite.SuiteNameBefore = append(suite.SuiteNameBefore, suiteName) - suite.TestNameBefore = append(suite.TestNameBefore, testName) - suite.TimeBefore = append(suite.TimeBefore, time.Now()) -} - -func (suite *SuiteTester) AfterTest(suiteName, testName string) { - suite.SuiteNameAfter = append(suite.SuiteNameAfter, suiteName) - suite.TestNameAfter = append(suite.TestNameAfter, testName) - suite.TimeAfter = append(suite.TimeAfter, time.Now()) -} - -func (suite *SuiteSkipTester) SetupSuite() { - suite.SetupSuiteRunCount++ - suite.T().Skip() -} - -// The TearDownSuite method will be run by testify once, at the very -// end of the testing suite, after all tests have been run. -func (suite *SuiteTester) TearDownSuite() { - suite.TearDownSuiteRunCount++ -} - -func (suite *SuiteSkipTester) TearDownSuite() { - suite.TearDownSuiteRunCount++ -} - -// The SetupTest method will be run before every test in the suite. -func (suite *SuiteTester) SetupTest() { - suite.SetupTestRunCount++ -} - -// The TearDownTest method will be run after every test in the suite. -func (suite *SuiteTester) TearDownTest() { - suite.TearDownTestRunCount++ -} - -// Every method in a testing suite that begins with "Test" will be run -// as a test. TestOne is an example of a test. For the purposes of -// this example, we've included assertions in the tests, since most -// tests will issue assertions. -func (suite *SuiteTester) TestOne() { - beforeCount := suite.TestOneRunCount - suite.TestOneRunCount++ - assert.Equal(suite.T(), suite.TestOneRunCount, beforeCount+1) - suite.Equal(suite.TestOneRunCount, beforeCount+1) -} - -// TestTwo is another example of a test. -func (suite *SuiteTester) TestTwo() { - beforeCount := suite.TestTwoRunCount - suite.TestTwoRunCount++ - assert.NotEqual(suite.T(), suite.TestTwoRunCount, beforeCount) - suite.NotEqual(suite.TestTwoRunCount, beforeCount) -} - -func (suite *SuiteTester) TestSkip() { - suite.T().Skip() -} - -// NonTestMethod does not begin with "Test", so it will not be run by -// testify as a test in the suite. This is useful for creating helper -// methods for your tests. -func (suite *SuiteTester) NonTestMethod() { - suite.NonTestMethodRunCount++ -} - -// TestRunSuite will be run by the 'go test' command, so within it, we -// can run our suite using the Run(*testing.T, TestingSuite) function. -func TestRunSuite(t *testing.T) { - suiteTester := new(SuiteTester) - Run(t, suiteTester) - - // Normally, the test would end here. The following are simply - // some assertions to ensure that the Run function is working as - // intended - they are not part of the example. - - // The suite was only run once, so the SetupSuite and TearDownSuite - // methods should have each been run only once. - assert.Equal(t, suiteTester.SetupSuiteRunCount, 1) - assert.Equal(t, suiteTester.TearDownSuiteRunCount, 1) - - assert.Equal(t, len(suiteTester.SuiteNameAfter), 3) - assert.Equal(t, len(suiteTester.SuiteNameBefore), 3) - assert.Equal(t, len(suiteTester.TestNameAfter), 3) - assert.Equal(t, len(suiteTester.TestNameBefore), 3) - - assert.Contains(t, suiteTester.TestNameAfter, "TestOne") - assert.Contains(t, suiteTester.TestNameAfter, "TestTwo") - assert.Contains(t, suiteTester.TestNameAfter, "TestSkip") - - assert.Contains(t, suiteTester.TestNameBefore, "TestOne") - assert.Contains(t, suiteTester.TestNameBefore, "TestTwo") - assert.Contains(t, suiteTester.TestNameBefore, "TestSkip") - - for _, suiteName := range suiteTester.SuiteNameAfter { - assert.Equal(t, "SuiteTester", suiteName) - } - - for _, suiteName := range suiteTester.SuiteNameBefore { - assert.Equal(t, "SuiteTester", suiteName) - } - - for _, when := range suiteTester.TimeAfter { - assert.False(t, when.IsZero()) - } - - for _, when := range suiteTester.TimeBefore { - assert.False(t, when.IsZero()) - } - - // There are three test methods (TestOne, TestTwo, and TestSkip), so - // the SetupTest and TearDownTest methods (which should be run once for - // each test) should have been run three times. - assert.Equal(t, suiteTester.SetupTestRunCount, 3) - assert.Equal(t, suiteTester.TearDownTestRunCount, 3) - - // Each test should have been run once. - assert.Equal(t, suiteTester.TestOneRunCount, 1) - assert.Equal(t, suiteTester.TestTwoRunCount, 1) - - // Methods that don't match the test method identifier shouldn't - // have been run at all. - assert.Equal(t, suiteTester.NonTestMethodRunCount, 0) - - suiteSkipTester := new(SuiteSkipTester) - Run(t, suiteSkipTester) - - // The suite was only run once, so the SetupSuite and TearDownSuite - // methods should have each been run only once, even though SetupSuite - // called Skip() - assert.Equal(t, suiteSkipTester.SetupSuiteRunCount, 1) - assert.Equal(t, suiteSkipTester.TearDownSuiteRunCount, 1) - -} - -func TestSuiteGetters(t *testing.T) { - suite := new(SuiteTester) - suite.SetT(t) - assert.NotNil(t, suite.Assert()) - assert.Equal(t, suite.Assertions, suite.Assert()) - assert.NotNil(t, suite.Require()) - assert.Equal(t, suite.require, suite.Require()) -} - -type SuiteLoggingTester struct { - Suite -} - -func (s *SuiteLoggingTester) TestLoggingPass() { - s.T().Log("TESTLOGPASS") -} - -func (s *SuiteLoggingTester) TestLoggingFail() { - s.T().Log("TESTLOGFAIL") - assert.NotNil(s.T(), nil) // expected to fail -} - -type StdoutCapture struct { - oldStdout *os.File - readPipe *os.File -} - -func (sc *StdoutCapture) StartCapture() { - sc.oldStdout = os.Stdout - sc.readPipe, os.Stdout, _ = os.Pipe() -} - -func (sc *StdoutCapture) StopCapture() (string, error) { - if sc.oldStdout == nil || sc.readPipe == nil { - return "", errors.New("StartCapture not called before StopCapture") - } - os.Stdout.Close() - os.Stdout = sc.oldStdout - bytes, err := ioutil.ReadAll(sc.readPipe) - if err != nil { - return "", err - } - return string(bytes), nil -} - -func TestSuiteLogging(t *testing.T) { - suiteLoggingTester := new(SuiteLoggingTester) - capture := StdoutCapture{} - internalTest := testing.InternalTest{ - Name: "SomeTest", - F: func(subT *testing.T) { - Run(subT, suiteLoggingTester) - }, - } - capture.StartCapture() - testing.RunTests(allTestsFilter, []testing.InternalTest{internalTest}) - output, err := capture.StopCapture() - require.NoError(t, err, "Got an error trying to capture stdout and stderr!") - require.NotEmpty(t, output, "output content must not be empty") - - // Failed tests' output is always printed - assert.Contains(t, output, "TESTLOGFAIL") - - if testing.Verbose() { - // In verbose mode, output from successful tests is also printed - assert.Contains(t, output, "TESTLOGPASS") - } else { - assert.NotContains(t, output, "TESTLOGPASS") - } -} From 851f9686b67d87b8f36be2d3c37c9b6fc1f3df25 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 7 May 2020 11:35:22 -0700 Subject: [PATCH 03/23] Bumping up version. --- realis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/realis.go b/realis.go index da31a2c..6299986 100644 --- a/realis.go +++ b/realis.go @@ -36,7 +36,7 @@ import ( "github.com/pkg/errors" ) -const VERSION = "2.0.1" +const VERSION = "2.22.1" type Client struct { config *clientConfig From 34a950306d60b59f8112f5917bae0bb38e520fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Wed, 20 May 2020 18:21:47 -0700 Subject: [PATCH 04/23] Update developing.md Updating documentation for developing gorealis --- docs/developing.md | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/docs/developing.md b/docs/developing.md index 895ad1e..affbb32 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -19,25 +19,18 @@ This also allows us to delete and recreate our development cluster very quickly. To install docker-compose please follow the instructions for your platform [here](https://docs.docker.com/compose/install/). - ### Getting the source code -As of go 1.10.x, GOPATH is still relevant. This may change in the future but -for the sake of making development less error prone, it is suggested that the following -directories be created: +`$ git clone https://github.com/aurora-scheduler/gorealis` -`$ mkdir -p $GOPATH/src/github.com/paypal` +Inside of the newly cloned repo you may download dependencies to the local cache using go mod -And then clone the master branch into the newly created folder: - -`$ cd $GOPATH/src/github.com/paypal; git clone git@github.com:paypal/gorealis.git` - -Since we check in our vendor folder, gorealis no further set up is needed. +`$ go mod download` ### Bringing up the cluster -To develop gorealis, you will need a fully functioning Mesos cluster along with -Apache Aurora. +To develop gorealis, you will need a fully functioning Mesos cluster along with +the Aurora Scheduler. In order to bring up our docker-compose set up execute the following command from the root of the git repository: @@ -62,14 +55,14 @@ environment but not when running under MacOS. To run code involving the ZK leade For example, running the tests in a container can be done through the following command from the root of the git repository: -`$ docker run -t -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine go test github.com/paypal/gorealis` +`$ docker run -t -v $(pwd):/go/src/github.com/aurora-scheduler/gorealis --network gorealis_aurora_cluster golang:1.14.3-alpine go test github.com/paypal/gorealis` Or `$ ./runTestsMac.sh` Alternatively, if an interactive shell is necessary, the following command may be used: -`$ docker run -it -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine /bin/sh` +`$ docker run -it -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.14.3-alpine /bin/sh` ### Cleaning up the cluster @@ -85,6 +78,3 @@ Once development is done, the environment may be torn down by executing (from th git directory): `$ docker-compose down` - - - From e5d63579e874c3ca6ec682dcfc1240d9e3c41320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Wed, 20 May 2020 18:26:05 -0700 Subject: [PATCH 05/23] Update using-the-sample-client.md Updating instructions for using the sample client. --- docs/using-the-sample-client.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/using-the-sample-client.md b/docs/using-the-sample-client.md index f2de6d9..cbc2246 100644 --- a/docs/using-the-sample-client.md +++ b/docs/using-the-sample-client.md @@ -22,28 +22,25 @@ Usage of ./client: ``` ## Sample commands: -These commands are set to run on a vagrant box. To be able to run the docker compose -executor examples, the vagrant box must be configured properly to use the docker compose executor. ### Thermos #### Creating a Thermos job ``` -$ cd $GOPATH/src/github.com/paypal/gorealis/examples -$ go run client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=create +$ go run examples/client.go -url=http://localhost:8081 -executor=thermos -cmd=create ``` #### Kill a Thermos job ``` -$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=kill +$ go run examples/client.gon -url=http://localhost:8081 -executor=thermos -cmd=kill ``` ### Docker Compose executor (custom executor) #### Creating Docker Compose executor job ``` -$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=create +$ go run examples/client.go -url=http://192.168.33.7:8081 -executor=compose -cmd=create ``` #### Kill a Docker Compose executor job ``` -$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill +$ go run examples/client.go -url=http://192.168.33.7:8081 -executor=compose -cmd=kill ``` From 30f804bc53c0e4da295216021ebb628c39fc50a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Wed, 20 May 2020 18:26:33 -0700 Subject: [PATCH 06/23] Update using-the-sample-client.md Fixing typo on doc. --- docs/using-the-sample-client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/using-the-sample-client.md b/docs/using-the-sample-client.md index cbc2246..441650c 100644 --- a/docs/using-the-sample-client.md +++ b/docs/using-the-sample-client.md @@ -31,7 +31,7 @@ $ go run examples/client.go -url=http://localhost:8081 -executor=thermos -cmd=cr ``` #### Kill a Thermos job ``` -$ go run examples/client.gon -url=http://localhost:8081 -executor=thermos -cmd=kill +$ go run examples/client.go -url=http://localhost:8081 -executor=thermos -cmd=kill ``` ### Docker Compose executor (custom executor) From 4cf60775f57fdf241836d6109cd625d4e5c1c4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Tue, 26 May 2020 20:32:51 -0700 Subject: [PATCH 07/23] Bumping up thrift go library version to v0.13.2 (#6) Thrift v0.13.2 is a forked version of v0.13.0 with a patch to not panic when trying to write to a closed buffer. Instead we get an error back and we can handle it appropriately. --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 09f4e2a..f59797d 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/aurora-scheduler/gorealis/v2 require ( - github.com/apache/thrift v0.12.0 + github.com/apache/thrift v0.13.0 github.com/pkg/errors v0.9.1 github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a github.com/stretchr/testify v1.5.0 ) -replace github.com/apache/thrift v0.13.0 => github.com/ridv/thrift v0.13.1 +replace github.com/apache/thrift v0.13.0 => github.com/ridv/thrift v0.13.2 go 1.13 From 6c639362c8540690fcc0d894b9211a1eeb122680 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Mon, 27 Jul 2020 21:44:35 -0700 Subject: [PATCH 08/23] Bumping up go tests time to 30m. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 229360f..44dd2e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,5 +22,5 @@ jobs: - name: Create aurora/mesos docker cluster run: docker-compose up -d - name: Run tests - run: go test -timeout 20m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/aurora-scheduler/gorealis/v2 + run: go test -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/aurora-scheduler/gorealis/v2 From c3dbeba2bd42c198b4ce45c3e99c1cea9774343d Mon Sep 17 00:00:00 2001 From: lenhattan86 Date: Sun, 15 Nov 2020 16:44:21 -0800 Subject: [PATCH 09/23] Adds ability to fetch Mesos Master leader (#7) * Adds ability to fetch Mesos Master leader from Zookeeper --- zk.go | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/zk.go b/zk.go index bc60a97..9d5b659 100644 --- a/zk.go +++ b/zk.go @@ -16,6 +16,7 @@ package realis import ( "encoding/json" + "math" "strconv" "strings" "time" @@ -35,6 +36,18 @@ type ServiceInstance struct { Status string `json:"status"` } +type MesosAddress struct { + Hostname string `json:"hostname"` + IP string `json:"ip"` + Port uint16 `json:"port"` +} + +// MesosInstance is defined for mesos json stored in ZK. +type MesosInstance struct { + Address MesosAddress `json:"address"` + Version string `json:"version"` +} + type zkConfig struct { endpoints []string path string @@ -176,3 +189,100 @@ func LeaderFromZKOpts(options ...ZKOpt) (string, error) { return leaderURL, nil } + +// Retrieves current mesos leader from ZK with a custom configuration. +func MesosFromZKOpts(options ...ZKOpt) (string, error) { + var mesosURL string + + // Load the default configuration for Zookeeper followed by overriding values with those provided by the caller. + config := &zkConfig{backoff: defaultBackoff, timeout: time.Second * 10, logger: NoopLogger{}} + for _, opt := range options { + opt(config) + } + + if len(config.endpoints) == 0 { + return "", errors.New("no Zookeeper endpoints supplied") + } + + if config.path == "" { + return "", errors.New("no Zookeeper path supplied") + } + + // Create a closure that allows us to use the ExponentialBackoff function. + retryErr := ExponentialBackoff(config.backoff, config.logger, func() (bool, error) { + + c, _, err := zk.Connect(config.endpoints, config.timeout, func(c *zk.Conn) { c.SetLogger(config.logger) }) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "Failed to connect to Zookeeper")) + } + + defer c.Close() + + // Open up descriptor for the ZK path given + children, _, _, err := c.ChildrenW(config.path) + if err != nil { + + // Sentinel error check as there is no other way to check. + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", config.path) + } + + return false, + NewTemporaryError(errors.Wrapf(err, "path %s doesn't exist on Zookeeper ", config.path)) + } + + // Search for the leader through all the children in the given path + minScore := math.MaxInt64 + var mesosInstance MesosInstance + for _, child := range children { + // Only the leader will start with json.info_ + if strings.HasPrefix(child, "json.info_") { + strs := strings.Split(child, "_") + if len(strs) < 2 { + config.logger.Printf("Zk node %v/%v's name is malformed.", config.path, child) + continue + } + score, err := strconv.Atoi(strs[1]) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "unable to read the zk node for Mesos.")) + } + + // get the leader from the child with the smallest score. + if score < minScore { + minScore = score + childPath := config.path + "/" + child + data, _, err := c.Get(childPath) + if err != nil { + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", childPath) + } + + return false, NewTemporaryError(errors.Wrap(err, "error fetching contents of leader")) + } + + err = json.Unmarshal([]byte(data), &mesosInstance) + if err != nil { + config.logger.Printf("%s", err) + return false, + NewTemporaryError(errors.Wrap(err, "unable to unmarshal contents of leader")) + } + + mesosURL = mesosInstance.Address.IP + ":" + strconv.Itoa(int(mesosInstance.Address.Port)) + } + } + } + if len(mesosURL) > 0 { + return true, nil + } + + // Leader data might not be available yet, try to fetch again. + return false, NewTemporaryError(errors.New("no leader found")) + }) + + if retryErr != nil { + config.logger.Printf("Failed to determine leader after %v attempts", config.backoff.Steps) + return "", retryErr + } + + return mesosURL, nil +} From caf1444250097e8eaaf790a473fa3603fd9b9348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Mon, 16 Nov 2020 21:45:00 -0800 Subject: [PATCH 10/23] Removes variables from github actions Github Actions deprecated support for using env files without previously setting them. Adjusting CI scripts accordingly. --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44dd2e3..665cbd8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,17 +10,17 @@ jobs: steps: - uses: actions/checkout@v2 - name: Setup Go for use with actions - uses: actions/setup-go@v1.0.0 + uses: actions/setup-go@v2 with: - version: 1.13 + go-version: 1.15 - name: Install goimports run: go get golang.org/x/tools/cmd/goimports + - name: Set env with list of directories in repo containin go code + run: echo GO_USR_DIRS=$(go list -f {{.Dir}} ./... | grep -E -v "/gen-go/|/vendor/") >> $GITHUB_ENV - name: Run goimports check run: test -z "`for d in $GO_USR_DIRS; do goimports -d $d/*.go | tee /dev/stderr; done`" - env: - GO_USR_DIRS: $(go list -f {{.Dir}} ./... | grep -E -v "/gen-go/|/vendor/") - name: Create aurora/mesos docker cluster run: docker-compose up -d - name: Run tests - run: go test -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/aurora-scheduler/gorealis/v2 + run: go test -timeout 35m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/aurora-scheduler/gorealis/v2 From 755f99fb765532eb2f2f5979487f204657bacb89 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Mon, 16 Nov 2020 21:51:02 -0800 Subject: [PATCH 11/23] Fixes style issue with jobupdate file. --- jobUpdate.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobUpdate.go b/jobUpdate.go index cc2cd7f..3ef2cb4 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -137,10 +137,11 @@ func (j *JobUpdate) SlaAware(slaAware bool) *JobUpdate { j.request.Settings.SlaAware = &slaAware return j } + // AddInstanceRange allows updates to only touch a certain specific range of instances func (j *JobUpdate) AddInstanceRange(first, last int32) *JobUpdate { j.request.Settings.UpdateOnlyTheseInstances = append(j.request.Settings.UpdateOnlyTheseInstances, - &aurora.Range{First: first, Last: last}) + &aurora.Range{First: first, Last: last}) return j } From b1661698c299c60a23b0f0f136355710e06570ac Mon Sep 17 00:00:00 2001 From: lenhattan86 Date: Tue, 12 Jan 2021 16:18:09 -0800 Subject: [PATCH 12/23] GetJobSummary API (#8) * Adds GetJobSummary API --- realis.go | 13 +++++++++++++ realis_e2e_test.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/realis.go b/realis.go index 6299986..a7c536e 100644 --- a/realis.go +++ b/realis.go @@ -348,6 +348,19 @@ func (c *Client) GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (* return resp.GetResult_().GetGetJobUpdateSummariesResult_(), nil } +func (c *Client) GetJobSummary(role string) (*aurora.JobSummaryResult_, error) { + + resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { + return c.readonlyClient.GetJobSummary(context.TODO(), role) + }) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error getting job summaries from Aurora Scheduler") + } + + return resp.GetResult_().GetJobSummaryResult_(), nil +} + func (c *Client) GetJobs(role string) (*aurora.GetJobsResult_, error) { var result *aurora.GetJobsResult_ diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 38e39e7..884a485 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -823,3 +823,51 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { } assert.NoError(t, r.KillJob(strategy.JobKey())) } + +// Test configuring an executor that doesn't exist for CreateJob API +func TestRealisClient_GetJobSummary(t *testing.T) { + role := "vagrant" + // Create a single job + job := realis.NewJobUpdate(). + Environment("prod"). + Role(role). + Name("TestGetJobSummary"). + ThermosExecutor(thermosExec). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(3). + WatchTime(20 * time.Second). + IsService(true). + BatchSize(2) + + result, err := r.CreateService(job) + + assert.NoError(t, err) + assert.NotNil(t, result) + + var ok bool + var mErr error + + if ok, mErr = r.MonitorJobUpdate(*result.GetKey(), 5*time.Second, 4*time.Minute); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") + + err = r.KillJob(job.JobKey()) + + assert.NoError(t, err) + } + + assert.True(t, ok) + assert.NoError(t, mErr) + // get job summary of the role + summary, mErr := r.GetJobSummary(role) + assert.NoError(t, mErr) + assert.NotNil(t, summary) + assert.Equal(t, len(summary.Summaries), 1) + + // Kill task test task after confirming it came up fine + err = r.KillJob(job.JobKey()) + + assert.NoError(t, err) +} From d0be43b8ac7aca8662a0e00a0fbb7b15be69b064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Mon, 1 Mar 2021 15:36:28 -0800 Subject: [PATCH 13/23] Dropping support for dep (#10) Dep files are no longer necessary. --- Gopkg.lock | 60 ------------------------------------------------------ Gopkg.toml | 16 --------------- 2 files changed, 76 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 4b34e9d..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,60 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - branch = "0.12.0" - digest = "1:89696c38cec777120b8b1bb5e2d363d655cf2e1e7d8c851919aaa0fd576d9b86" - name = "github.com/apache/thrift" - packages = ["lib/go/thrift"] - pruneopts = "" - revision = "384647d290e2e4a55a14b1b7ef1b7e66293a2c33" - -[[projects]] - digest = "1:0deddd908b6b4b768cfc272c16ee61e7088a60f7fe2f06c547bd3d8e1f8b8e77" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "" - revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - version = "v1.1.1" - -[[projects]] - digest = "1:df48fb76fb2a40edea0c9b3d960bc95e326660d82ff1114e1f88001f7a236b40" - name = "github.com/pkg/errors" - packages = ["."] - pruneopts = "" - revision = "e881fd58d78e04cf6d0de1217f8707c8cc2249bc" - -[[projects]] - digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - digest = "1:78bea5e26e82826dacc5fd64a1013a6711b7075ec8072819b89e6ad76cb8196d" - name = "github.com/samuel/go-zookeeper" - packages = ["zk"] - pruneopts = "" - revision = "471cd4e61d7a78ece1791fa5faa0345dc8c7d5a5" - -[[projects]] - digest = "1:c587772fb8ad29ad4db67575dad25ba17a51f072ff18a22b4f0257a4d9c24f75" - name = "github.com/stretchr/testify" - packages = ["assert"] - pruneopts = "" - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/apache/thrift/lib/go/thrift", - "github.com/pkg/errors", - "github.com/samuel/go-zookeeper/zk", - "github.com/stretchr/testify/assert", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 92a82d1..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,16 +0,0 @@ -[[constraint]] - name = "github.com/apache/thrift" - branch = "0.12.0" - -[[constraint]] - name = "github.com/pkg/errors" - revision = "e881fd58d78e04cf6d0de1217f8707c8cc2249bc" - -[[constraint]] - name = "github.com/samuel/go-zookeeper" - revision = "471cd4e61d7a78ece1791fa5faa0345dc8c7d5a5" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.2.0" - From 983bf44b9f0923dd63a7f65b54cfd2b8342a77f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Mon, 1 Mar 2021 16:52:25 -0800 Subject: [PATCH 14/23] Update thrift to 0.14.0 (#9) Generated thrift stubs using 0.14.0 compiler version. Script now tells user to use version 0.14.0 of thrift compiler. --- gen-go/apache/aurora/GoUnusedProtection__.go | 3 +- gen-go/apache/aurora/auroraAPI-consts.go | 7 +- gen-go/apache/aurora/auroraAPI.go | 16464 +++++++++------- .../aurora_admin-remote.go | 645 +- .../aurora_scheduler_manager-remote.go | 439 +- .../read_only_scheduler-remote.go | 147 +- generateBindings.sh | 2 +- go.mod | 6 +- 8 files changed, 10384 insertions(+), 7329 deletions(-) diff --git a/gen-go/apache/aurora/GoUnusedProtection__.go b/gen-go/apache/aurora/GoUnusedProtection__.go index 7ac5b29..462b3b4 100644 --- a/gen-go/apache/aurora/GoUnusedProtection__.go +++ b/gen-go/apache/aurora/GoUnusedProtection__.go @@ -1,5 +1,4 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package aurora diff --git a/gen-go/apache/aurora/auroraAPI-consts.go b/gen-go/apache/aurora/auroraAPI-consts.go index 3db5138..d4a319e 100644 --- a/gen-go/apache/aurora/auroraAPI-consts.go +++ b/gen-go/apache/aurora/auroraAPI-consts.go @@ -1,13 +1,12 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package aurora import( "bytes" "context" - "reflect" "fmt" + "time" "github.com/apache/thrift/lib/go/thrift" ) @@ -15,7 +14,7 @@ import( var _ = thrift.ZERO var _ = fmt.Printf var _ = context.Background -var _ = reflect.DeepEqual +var _ = time.Now var _ = bytes.Equal const AURORA_EXECUTOR_NAME = "AuroraExecutor" diff --git a/gen-go/apache/aurora/auroraAPI.go b/gen-go/apache/aurora/auroraAPI.go index cf0b088..914d268 100644 --- a/gen-go/apache/aurora/auroraAPI.go +++ b/gen-go/apache/aurora/auroraAPI.go @@ -1,15 +1,14 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package aurora import( "bytes" "context" - "reflect" "database/sql/driver" "errors" "fmt" + "time" "github.com/apache/thrift/lib/go/thrift" ) @@ -17,7 +16,7 @@ import( var _ = thrift.ZERO var _ = fmt.Printf var _ = context.Background -var _ = reflect.DeepEqual +var _ = time.Now var _ = bytes.Equal type ResponseCode int64 @@ -567,14 +566,14 @@ func NewIdentity() *Identity { func (p *Identity) GetUser() string { return p.User } -func (p *Identity) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Identity) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -582,31 +581,31 @@ func (p *Identity) Read(iprot thrift.TProtocol) error { switch fieldId { case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Identity) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Identity) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.User = v @@ -614,29 +613,39 @@ func (p *Identity) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Identity) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Identity"); err != nil { +func (p *Identity) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Identity"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Identity) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 2); err != nil { +func (p *Identity) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:user: ", p), err) } - if err := oprot.WriteString(string(p.User)); err != nil { + if err := oprot.WriteString(ctx, string(p.User)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.user (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:user: ", p), err) } return err } +func (p *Identity) Equals(other *Identity) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.User != other.User { return false } + return true +} + func (p *Identity) String() string { if p == nil { return "" @@ -666,14 +675,14 @@ func (p *Attribute) GetName() string { func (p *Attribute) GetValues() []string { return p.Values } -func (p *Attribute) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Attribute) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -681,41 +690,41 @@ func (p *Attribute) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Attribute) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Attribute) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -723,8 +732,8 @@ func (p *Attribute) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Attribute) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *Attribute) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } @@ -732,68 +741,86 @@ func (p *Attribute) ReadField2(iprot thrift.TProtocol) error { p.Values = tSet for i := 0; i < size; i ++ { var _elem0 string - if v, err := iprot.ReadString(); err != nil { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { _elem0 = v } p.Values = append(p.Values, _elem0) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *Attribute) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Attribute"); err != nil { +func (p *Attribute) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Attribute"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Attribute) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *Attribute) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *Attribute) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("values", thrift.SET, 2); err != nil { +func (p *Attribute) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "values", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Values)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -849,14 +876,14 @@ func (p *HostAttributes) IsSetSlaveId() bool { return p.SlaveId != nil } -func (p *HostAttributes) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *HostAttributes) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -864,61 +891,61 @@ func (p *HostAttributes) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *HostAttributes) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *HostAttributes) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Host = v @@ -926,28 +953,28 @@ func (p *HostAttributes) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *HostAttributes) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *HostAttributes) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Attribute, 0, size) p.Attributes = tSet for i := 0; i < size; i ++ { - _elem1 := &Attribute{} - if err := _elem1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem1), err) + _elem2 := &Attribute{} + if err := _elem2.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) } - p.Attributes = append(p.Attributes, _elem1) + p.Attributes = append(p.Attributes, _elem2) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *HostAttributes) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *HostAttributes) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { temp := MaintenanceMode(v) @@ -956,8 +983,8 @@ func (p *HostAttributes) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *HostAttributes) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *HostAttributes) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.SlaveId = &v @@ -965,82 +992,112 @@ func (p *HostAttributes) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *HostAttributes) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HostAttributes"); err != nil { +func (p *HostAttributes) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostAttributes"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *HostAttributes) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("host", thrift.STRING, 1); err != nil { +func (p *HostAttributes) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } - if err := oprot.WriteString(string(p.Host)); err != nil { + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } return err } -func (p *HostAttributes) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.SET, 2); err != nil { +func (p *HostAttributes) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "attributes", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:attributes: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Attributes)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Attributes)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -1071,14 +1128,14 @@ func (p *ValueConstraint) GetNegated() bool { func (p *ValueConstraint) GetValues() []string { return p.Values } -func (p *ValueConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ValueConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1086,41 +1143,41 @@ func (p *ValueConstraint) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.BOOL { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ValueConstraint) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *ValueConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Negated = v @@ -1128,77 +1185,95 @@ func (p *ValueConstraint) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *ValueConstraint) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *ValueConstraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]string, 0, size) p.Values = tSet for i := 0; i < size; i ++ { -var _elem2 string - if v, err := iprot.ReadString(); err != nil { +var _elem4 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem2 = v + _elem4 = v } - p.Values = append(p.Values, _elem2) + p.Values = append(p.Values, _elem4) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *ValueConstraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ValueConstraint"); err != nil { +func (p *ValueConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ValueConstraint"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ValueConstraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("negated", thrift.BOOL, 1); err != nil { +func (p *ValueConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "negated", thrift.BOOL, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:negated: ", p), err) } - if err := oprot.WriteBool(bool(p.Negated)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.Negated)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.negated (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:negated: ", p), err) } return err } -func (p *ValueConstraint) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("values", thrift.SET, 2); err != nil { +func (p *ValueConstraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "values", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Values)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -1223,14 +1298,14 @@ func NewLimitConstraint() *LimitConstraint { func (p *LimitConstraint) GetLimit() int32 { return p.Limit } -func (p *LimitConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *LimitConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1238,31 +1313,31 @@ func (p *LimitConstraint) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *LimitConstraint) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *LimitConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Limit = v @@ -1270,29 +1345,39 @@ func (p *LimitConstraint) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *LimitConstraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("LimitConstraint"); err != nil { +func (p *LimitConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "LimitConstraint"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *LimitConstraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("limit", thrift.I32, 1); err != nil { +func (p *LimitConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "limit", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:limit: ", p), err) } - if err := oprot.WriteI32(int32(p.Limit)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Limit)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.limit (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:limit: ", p), err) } return err } +func (p *LimitConstraint) Equals(other *LimitConstraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Limit != other.Limit { return false } + return true +} + func (p *LimitConstraint) String() string { if p == nil { return "" @@ -1348,14 +1433,14 @@ func (p *TaskConstraint) IsSetLimit() bool { return p.Limit != nil } -func (p *TaskConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *TaskConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1363,98 +1448,109 @@ func (p *TaskConstraint) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *TaskConstraint) ReadField1(iprot thrift.TProtocol) error { +func (p *TaskConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Value = &ValueConstraint{} - if err := p.Value.Read(iprot); err != nil { + if err := p.Value.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Value), err) } return nil } -func (p *TaskConstraint) ReadField2(iprot thrift.TProtocol) error { +func (p *TaskConstraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Limit = &LimitConstraint{} - if err := p.Limit.Read(iprot); err != nil { + if err := p.Limit.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Limit), err) } return nil } -func (p *TaskConstraint) Write(oprot thrift.TProtocol) error { +func (p *TaskConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsTaskConstraint(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("TaskConstraint"); err != nil { + if err := oprot.WriteStructBegin(ctx, "TaskConstraint"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *TaskConstraint) writeField1(oprot thrift.TProtocol) (err error) { +func (p *TaskConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetValue() { - if err := oprot.WriteFieldBegin("value", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := p.Value.Write(oprot); err != nil { + if err := p.Value.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Value), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } } return err } -func (p *TaskConstraint) writeField2(oprot thrift.TProtocol) (err error) { +func (p *TaskConstraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetLimit() { - if err := oprot.WriteFieldBegin("limit", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "limit", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:limit: ", p), err) } - if err := p.Limit.Write(oprot); err != nil { + if err := p.Limit.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Limit), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:limit: ", p), err) } } return err } +func (p *TaskConstraint) Equals(other *TaskConstraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Value.Equals(other.Value) { return false } + if !p.Limit.Equals(other.Limit) { return false } + return true +} + func (p *TaskConstraint) String() string { if p == nil { return "" @@ -1491,14 +1587,14 @@ func (p *Constraint) IsSetConstraint() bool { return p.Constraint != nil } -func (p *Constraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Constraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1506,41 +1602,41 @@ func (p *Constraint) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Constraint) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Constraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -1548,49 +1644,60 @@ func (p *Constraint) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Constraint) ReadField2(iprot thrift.TProtocol) error { +func (p *Constraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Constraint = &TaskConstraint{} - if err := p.Constraint.Read(iprot); err != nil { + if err := p.Constraint.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Constraint), err) } return nil } -func (p *Constraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Constraint"); err != nil { +func (p *Constraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Constraint"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Constraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *Constraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *Constraint) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("constraint", thrift.STRUCT, 2); err != nil { +func (p *Constraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "constraint", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:constraint: ", p), err) } - if err := p.Constraint.Write(oprot); err != nil { + if err := p.Constraint.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Constraint), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:constraint: ", p), err) } return err } +func (p *Constraint) Equals(other *Constraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if !p.Constraint.Equals(other.Constraint) { return false } + return true +} + func (p *Constraint) String() string { if p == nil { return "" @@ -1624,14 +1731,14 @@ func (p *Package) GetName() string { func (p *Package) GetVersion() int32 { return p.Version } -func (p *Package) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Package) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1639,51 +1746,51 @@ func (p *Package) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Package) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Package) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Role = v @@ -1691,8 +1798,8 @@ func (p *Package) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Package) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Package) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Name = v @@ -1700,8 +1807,8 @@ func (p *Package) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Package) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *Package) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.Version = v @@ -1709,51 +1816,63 @@ func (p *Package) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *Package) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Package"); err != nil { +func (p *Package) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Package"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Package) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { +func (p *Package) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } - if err := oprot.WriteString(string(p.Role)); err != nil { + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } return err } -func (p *Package) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 2); err != nil { +func (p *Package) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) } return err } -func (p *Package) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("version", thrift.I32, 3); err != nil { +func (p *Package) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "version", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:version: ", p), err) } - if err := oprot.WriteI32(int32(p.Version)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Version)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.version (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:version: ", p), err) } return err } +func (p *Package) Equals(other *Package) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.Name != other.Name { return false } + if p.Version != other.Version { return false } + return true +} + func (p *Package) String() string { if p == nil { return "" @@ -1783,14 +1902,14 @@ func (p *Metadata) GetKey() string { func (p *Metadata) GetValue() string { return p.Value } -func (p *Metadata) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Metadata) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1798,41 +1917,41 @@ func (p *Metadata) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Metadata) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Metadata) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Key = v @@ -1840,8 +1959,8 @@ func (p *Metadata) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Metadata) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Metadata) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Value = v @@ -1849,40 +1968,51 @@ func (p *Metadata) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Metadata) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Metadata"); err != nil { +func (p *Metadata) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Metadata"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Metadata) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { +func (p *Metadata) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := oprot.WriteString(string(p.Key)); err != nil { + if err := oprot.WriteString(ctx, string(p.Key)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } return err } -func (p *Metadata) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { +func (p *Metadata) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) } return err } +func (p *Metadata) Equals(other *Metadata) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Key != other.Key { return false } + if p.Value != other.Value { return false } + return true +} + func (p *Metadata) String() string { if p == nil { return "" @@ -1918,14 +2048,14 @@ func (p *JobKey) GetEnvironment() string { func (p *JobKey) GetName() string { return p.Name } -func (p *JobKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -1933,51 +2063,51 @@ func (p *JobKey) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobKey) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Role = v @@ -1985,8 +2115,8 @@ func (p *JobKey) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobKey) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Environment = v @@ -1994,8 +2124,8 @@ func (p *JobKey) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobKey) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobKey) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.Name = v @@ -2003,51 +2133,63 @@ func (p *JobKey) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobKey"); err != nil { +func (p *JobKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobKey"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { +func (p *JobKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } - if err := oprot.WriteString(string(p.Role)); err != nil { + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } return err } -func (p *JobKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("environment", thrift.STRING, 2); err != nil { +func (p *JobKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "environment", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:environment: ", p), err) } - if err := oprot.WriteString(string(p.Environment)); err != nil { + if err := oprot.WriteString(ctx, string(p.Environment)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.environment (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:environment: ", p), err) } return err } -func (p *JobKey) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 3); err != nil { +func (p *JobKey) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:name: ", p), err) } return err } +func (p *JobKey) Equals(other *JobKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.Environment != other.Environment { return false } + if p.Name != other.Name { return false } + return true +} + func (p *JobKey) String() string { if p == nil { return "" @@ -2087,14 +2229,14 @@ func (p *LockKey) IsSetJob() bool { return p.Job != nil } -func (p *LockKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *LockKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2102,66 +2244,76 @@ func (p *LockKey) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *LockKey) ReadField1(iprot thrift.TProtocol) error { +func (p *LockKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *LockKey) Write(oprot thrift.TProtocol) error { +func (p *LockKey) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsLockKey(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("LockKey"); err != nil { + if err := oprot.WriteStructBegin(ctx, "LockKey"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *LockKey) writeField1(oprot thrift.TProtocol) (err error) { +func (p *LockKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetJob() { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } } return err } +func (p *LockKey) Equals(other *LockKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + return true +} + func (p *LockKey) String() string { if p == nil { return "" @@ -2223,14 +2375,14 @@ func (p *Lock) IsSetMessage() bool { return p.Message != nil } -func (p *Lock) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Lock) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2238,79 +2390,79 @@ func (p *Lock) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.I64 { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.STRING { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Lock) ReadField1(iprot thrift.TProtocol) error { +func (p *Lock) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &LockKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *Lock) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Lock) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Token = v @@ -2318,8 +2470,8 @@ func (p *Lock) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Lock) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Lock) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.User = v @@ -2327,8 +2479,8 @@ func (p *Lock) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *Lock) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *Lock) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.TimestampMs = v @@ -2336,8 +2488,8 @@ func (p *Lock) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *Lock) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Lock) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 5: ", err) } else { p.Message = &v @@ -2345,76 +2497,95 @@ func (p *Lock) ReadField5(iprot thrift.TProtocol) error { return nil } -func (p *Lock) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Lock"); err != nil { +func (p *Lock) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Lock"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Lock) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { +func (p *Lock) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := p.Key.Write(oprot); err != nil { + if err := p.Key.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } return err } -func (p *Lock) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("token", thrift.STRING, 2); err != nil { +func (p *Lock) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "token", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:token: ", p), err) } - if err := oprot.WriteString(string(p.Token)); err != nil { + if err := oprot.WriteString(ctx, string(p.Token)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.token (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:token: ", p), err) } return err } -func (p *Lock) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { +func (p *Lock) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } - if err := oprot.WriteString(string(p.User)); err != nil { + if err := oprot.WriteString(ctx, string(p.User)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } return err } -func (p *Lock) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 4); err != nil { +func (p *Lock) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:timestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timestampMs (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:timestampMs: ", p), err) } return err } -func (p *Lock) writeField5(oprot thrift.TProtocol) (err error) { +func (p *Lock) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 5); err != nil { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:message: ", p), err) } - if err := oprot.WriteString(string(*p.Message)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.message (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:message: ", p), err) } } return err } +func (p *Lock) Equals(other *Lock) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Key.Equals(other.Key) { return false } + if p.Token != other.Token { return false } + if p.User != other.User { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + func (p *Lock) String() string { if p == nil { return "" @@ -2451,14 +2622,14 @@ func (p *InstanceKey) IsSetJobKey() bool { return p.JobKey != nil } -func (p *InstanceKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *InstanceKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2466,49 +2637,49 @@ func (p *InstanceKey) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *InstanceKey) ReadField1(iprot thrift.TProtocol) error { +func (p *InstanceKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.JobKey = &JobKey{} - if err := p.JobKey.Read(iprot); err != nil { + if err := p.JobKey.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) } return nil } -func (p *InstanceKey) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *InstanceKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.InstanceId = v @@ -2516,41 +2687,52 @@ func (p *InstanceKey) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *InstanceKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("InstanceKey"); err != nil { +func (p *InstanceKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "InstanceKey"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *InstanceKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobKey", thrift.STRUCT, 1); err != nil { +func (p *InstanceKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobKey", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobKey: ", p), err) } - if err := p.JobKey.Write(oprot); err != nil { + if err := p.JobKey.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobKey: ", p), err) } return err } -func (p *InstanceKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 2); err != nil { +func (p *InstanceKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceId: ", p), err) } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.instanceId (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceId: ", p), err) } return err } +func (p *InstanceKey) Equals(other *InstanceKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.JobKey.Equals(other.JobKey) { return false } + if p.InstanceId != other.InstanceId { return false } + return true +} + func (p *InstanceKey) String() string { if p == nil { return "" @@ -2600,14 +2782,14 @@ func (p *MesosFetcherURI) IsSetCache() bool { return p.Cache != nil } -func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *MesosFetcherURI) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2615,51 +2797,51 @@ func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.BOOL { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.BOOL { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *MesosFetcherURI) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *MesosFetcherURI) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Value = v @@ -2667,8 +2849,8 @@ func (p *MesosFetcherURI) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *MesosFetcherURI) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *MesosFetcherURI) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Extract = &v @@ -2676,8 +2858,8 @@ func (p *MesosFetcherURI) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *MesosFetcherURI) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *MesosFetcherURI) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.Cache = &v @@ -2685,55 +2867,77 @@ func (p *MesosFetcherURI) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *MesosFetcherURI) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MesosFetcherURI"); err != nil { +func (p *MesosFetcherURI) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MesosFetcherURI"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *MesosFetcherURI) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { +func (p *MesosFetcherURI) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } return err } -func (p *MesosFetcherURI) writeField2(oprot thrift.TProtocol) (err error) { +func (p *MesosFetcherURI) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetExtract() { - if err := oprot.WriteFieldBegin("extract", thrift.BOOL, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "extract", thrift.BOOL, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:extract: ", p), err) } - if err := oprot.WriteBool(bool(*p.Extract)); err != nil { + if err := oprot.WriteBool(ctx, bool(*p.Extract)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.extract (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:extract: ", p), err) } } return err } -func (p *MesosFetcherURI) writeField3(oprot thrift.TProtocol) (err error) { +func (p *MesosFetcherURI) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetCache() { - if err := oprot.WriteFieldBegin("cache", thrift.BOOL, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "cache", thrift.BOOL, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cache: ", p), err) } - if err := oprot.WriteBool(bool(*p.Cache)); err != nil { + if err := oprot.WriteBool(ctx, bool(*p.Cache)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.cache (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cache: ", p), err) } } return err } +func (p *MesosFetcherURI) Equals(other *MesosFetcherURI) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Value != other.Value { return false } + if p.Extract != other.Extract { + if p.Extract == nil || other.Extract == nil { + return false + } + if (*p.Extract) != (*other.Extract) { return false } + } + if p.Cache != other.Cache { + if p.Cache == nil || other.Cache == nil { + return false + } + if (*p.Cache) != (*other.Cache) { return false } + } + return true +} + func (p *MesosFetcherURI) String() string { if p == nil { return "" @@ -2761,14 +2965,14 @@ func (p *ExecutorConfig) GetName() string { func (p *ExecutorConfig) GetData() string { return p.Data } -func (p *ExecutorConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ExecutorConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2776,41 +2980,41 @@ func (p *ExecutorConfig) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ExecutorConfig) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ExecutorConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -2818,8 +3022,8 @@ func (p *ExecutorConfig) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *ExecutorConfig) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ExecutorConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Data = v @@ -2827,40 +3031,51 @@ func (p *ExecutorConfig) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *ExecutorConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ExecutorConfig"); err != nil { +func (p *ExecutorConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ExecutorConfig"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ExecutorConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *ExecutorConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *ExecutorConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { +func (p *ExecutorConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "data", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } - if err := oprot.WriteString(string(p.Data)); err != nil { + if err := oprot.WriteString(ctx, string(p.Data)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } return err } +func (p *ExecutorConfig) Equals(other *ExecutorConfig) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Data != other.Data { return false } + return true +} + func (p *ExecutorConfig) String() string { if p == nil { return "" @@ -2896,14 +3111,14 @@ func (p *Volume) GetHostPath() string { func (p *Volume) GetMode() Mode { return p.Mode } -func (p *Volume) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Volume) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -2911,51 +3126,51 @@ func (p *Volume) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Volume) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Volume) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.ContainerPath = v @@ -2963,8 +3178,8 @@ func (p *Volume) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Volume) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Volume) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.HostPath = v @@ -2972,8 +3187,8 @@ func (p *Volume) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Volume) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *Volume) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { temp := Mode(v) @@ -2982,51 +3197,63 @@ func (p *Volume) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *Volume) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Volume"); err != nil { +func (p *Volume) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Volume"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Volume) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("containerPath", thrift.STRING, 1); err != nil { +func (p *Volume) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "containerPath", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:containerPath: ", p), err) } - if err := oprot.WriteString(string(p.ContainerPath)); err != nil { + if err := oprot.WriteString(ctx, string(p.ContainerPath)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.containerPath (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:containerPath: ", p), err) } return err } -func (p *Volume) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hostPath", thrift.STRING, 2); err != nil { +func (p *Volume) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hostPath", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:hostPath: ", p), err) } - if err := oprot.WriteString(string(p.HostPath)); err != nil { + if err := oprot.WriteString(ctx, string(p.HostPath)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.hostPath (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:hostPath: ", p), err) } return err } -func (p *Volume) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("mode", thrift.I32, 3); err != nil { +func (p *Volume) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "mode", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:mode: ", p), err) } - if err := oprot.WriteI32(int32(p.Mode)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Mode)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.mode (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:mode: ", p), err) } return err } +func (p *Volume) Equals(other *Volume) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ContainerPath != other.ContainerPath { return false } + if p.HostPath != other.HostPath { return false } + if p.Mode != other.Mode { return false } + return true +} + func (p *Volume) String() string { if p == nil { return "" @@ -3056,14 +3283,14 @@ func (p *DockerImage) GetName() string { func (p *DockerImage) GetTag() string { return p.Tag } -func (p *DockerImage) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *DockerImage) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3071,41 +3298,41 @@ func (p *DockerImage) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *DockerImage) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *DockerImage) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -3113,8 +3340,8 @@ func (p *DockerImage) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *DockerImage) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *DockerImage) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Tag = v @@ -3122,40 +3349,51 @@ func (p *DockerImage) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *DockerImage) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerImage"); err != nil { +func (p *DockerImage) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerImage"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *DockerImage) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *DockerImage) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *DockerImage) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tag", thrift.STRING, 2); err != nil { +func (p *DockerImage) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tag", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tag: ", p), err) } - if err := oprot.WriteString(string(p.Tag)); err != nil { + if err := oprot.WriteString(ctx, string(p.Tag)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.tag (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:tag: ", p), err) } return err } +func (p *DockerImage) Equals(other *DockerImage) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Tag != other.Tag { return false } + return true +} + func (p *DockerImage) String() string { if p == nil { return "" @@ -3185,14 +3423,14 @@ func (p *AppcImage) GetName() string { func (p *AppcImage) GetImageId() string { return p.ImageId } -func (p *AppcImage) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AppcImage) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3200,41 +3438,41 @@ func (p *AppcImage) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AppcImage) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AppcImage) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -3242,8 +3480,8 @@ func (p *AppcImage) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *AppcImage) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AppcImage) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.ImageId = v @@ -3251,40 +3489,51 @@ func (p *AppcImage) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *AppcImage) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("AppcImage"); err != nil { +func (p *AppcImage) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "AppcImage"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AppcImage) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *AppcImage) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *AppcImage) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("imageId", thrift.STRING, 2); err != nil { +func (p *AppcImage) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "imageId", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:imageId: ", p), err) } - if err := oprot.WriteString(string(p.ImageId)); err != nil { + if err := oprot.WriteString(ctx, string(p.ImageId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.imageId (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:imageId: ", p), err) } return err } +func (p *AppcImage) Equals(other *AppcImage) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.ImageId != other.ImageId { return false } + return true +} + func (p *AppcImage) String() string { if p == nil { return "" @@ -3340,14 +3589,14 @@ func (p *Image) IsSetAppc() bool { return p.Appc != nil } -func (p *Image) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Image) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3355,98 +3604,109 @@ func (p *Image) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Image) ReadField1(iprot thrift.TProtocol) error { +func (p *Image) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Docker = &DockerImage{} - if err := p.Docker.Read(iprot); err != nil { + if err := p.Docker.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) } return nil } -func (p *Image) ReadField2(iprot thrift.TProtocol) error { +func (p *Image) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Appc = &AppcImage{} - if err := p.Appc.Read(iprot); err != nil { + if err := p.Appc.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Appc), err) } return nil } -func (p *Image) Write(oprot thrift.TProtocol) error { +func (p *Image) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsImage(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("Image"); err != nil { + if err := oprot.WriteStructBegin(ctx, "Image"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Image) writeField1(oprot thrift.TProtocol) (err error) { +func (p *Image) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetDocker() { - if err := oprot.WriteFieldBegin("docker", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "docker", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:docker: ", p), err) } - if err := p.Docker.Write(oprot); err != nil { + if err := p.Docker.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:docker: ", p), err) } } return err } -func (p *Image) writeField2(oprot thrift.TProtocol) (err error) { +func (p *Image) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetAppc() { - if err := oprot.WriteFieldBegin("appc", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "appc", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:appc: ", p), err) } - if err := p.Appc.Write(oprot); err != nil { + if err := p.Appc.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Appc), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:appc: ", p), err) } } return err } +func (p *Image) Equals(other *Image) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Docker.Equals(other.Docker) { return false } + if !p.Appc.Equals(other.Appc) { return false } + return true +} + func (p *Image) String() string { if p == nil { return "" @@ -3488,14 +3748,14 @@ func (p *MesosContainer) IsSetVolumes() bool { return p.Volumes != nil } -func (p *MesosContainer) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *MesosContainer) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3503,115 +3763,130 @@ func (p *MesosContainer) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.LIST { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *MesosContainer) ReadField1(iprot thrift.TProtocol) error { +func (p *MesosContainer) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Image = &Image{} - if err := p.Image.Read(iprot); err != nil { + if err := p.Image.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Image), err) } return nil } -func (p *MesosContainer) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *MesosContainer) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*Volume, 0, size) p.Volumes = tSlice for i := 0; i < size; i ++ { - _elem3 := &Volume{} - if err := _elem3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem3), err) + _elem6 := &Volume{} + if err := _elem6.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem6), err) } - p.Volumes = append(p.Volumes, _elem3) + p.Volumes = append(p.Volumes, _elem6) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *MesosContainer) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MesosContainer"); err != nil { +func (p *MesosContainer) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MesosContainer"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *MesosContainer) writeField1(oprot thrift.TProtocol) (err error) { +func (p *MesosContainer) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetImage() { - if err := oprot.WriteFieldBegin("image", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "image", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) } - if err := p.Image.Write(oprot); err != nil { + if err := p.Image.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Image), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) } } return err } -func (p *MesosContainer) writeField2(oprot thrift.TProtocol) (err error) { +func (p *MesosContainer) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetVolumes() { - if err := oprot.WriteFieldBegin("volumes", thrift.LIST, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "volumes", thrift.LIST, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:volumes: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Volumes)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Volumes)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.Volumes { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:volumes: ", p), err) } } return err } +func (p *MesosContainer) Equals(other *MesosContainer) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Image.Equals(other.Image) { return false } + if len(p.Volumes) != len(other.Volumes) { return false } + for i, _tgt := range p.Volumes { + _src7 := other.Volumes[i] + if !_tgt.Equals(_src7) { return false } + } + return true +} + func (p *MesosContainer) String() string { if p == nil { return "" @@ -3641,14 +3916,14 @@ func (p *DockerParameter) GetName() string { func (p *DockerParameter) GetValue() string { return p.Value } -func (p *DockerParameter) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *DockerParameter) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3656,41 +3931,41 @@ func (p *DockerParameter) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *DockerParameter) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *DockerParameter) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -3698,8 +3973,8 @@ func (p *DockerParameter) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *DockerParameter) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *DockerParameter) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Value = v @@ -3707,40 +3982,51 @@ func (p *DockerParameter) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *DockerParameter) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerParameter"); err != nil { +func (p *DockerParameter) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerParameter"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *DockerParameter) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *DockerParameter) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *DockerParameter) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { +func (p *DockerParameter) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) } - if err := oprot.WriteString(string(p.Value)); err != nil { + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) } return err } +func (p *DockerParameter) Equals(other *DockerParameter) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Value != other.Value { return false } + return true +} + func (p *DockerParameter) String() string { if p == nil { return "" @@ -3775,14 +4061,14 @@ func (p *DockerContainer) IsSetParameters() bool { return p.Parameters != nil } -func (p *DockerContainer) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *DockerContainer) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3790,41 +4076,41 @@ func (p *DockerContainer) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.LIST { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *DockerContainer) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *DockerContainer) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Image = v @@ -3832,71 +4118,86 @@ func (p *DockerContainer) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *DockerContainer) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *DockerContainer) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*DockerParameter, 0, size) p.Parameters = tSlice for i := 0; i < size; i ++ { - _elem4 := &DockerParameter{} - if err := _elem4.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err) + _elem8 := &DockerParameter{} + if err := _elem8.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem8), err) } - p.Parameters = append(p.Parameters, _elem4) + p.Parameters = append(p.Parameters, _elem8) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *DockerContainer) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerContainer"); err != nil { +func (p *DockerContainer) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerContainer"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *DockerContainer) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("image", thrift.STRING, 1); err != nil { +func (p *DockerContainer) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "image", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) } - if err := oprot.WriteString(string(p.Image)); err != nil { + if err := oprot.WriteString(ctx, string(p.Image)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.image (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) } return err } -func (p *DockerContainer) writeField2(oprot thrift.TProtocol) (err error) { +func (p *DockerContainer) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetParameters() { - if err := oprot.WriteFieldBegin("parameters", thrift.LIST, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "parameters", thrift.LIST, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:parameters: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Parameters)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Parameters)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.Parameters { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:parameters: ", p), err) } } return err } +func (p *DockerContainer) Equals(other *DockerContainer) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Image != other.Image { return false } + if len(p.Parameters) != len(other.Parameters) { return false } + for i, _tgt := range p.Parameters { + _src9 := other.Parameters[i] + if !_tgt.Equals(_src9) { return false } + } + return true +} + func (p *DockerContainer) String() string { if p == nil { return "" @@ -3952,14 +4253,14 @@ func (p *Container) IsSetDocker() bool { return p.Docker != nil } -func (p *Container) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Container) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -3967,98 +4268,109 @@ func (p *Container) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Container) ReadField1(iprot thrift.TProtocol) error { +func (p *Container) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Mesos = &MesosContainer{} - if err := p.Mesos.Read(iprot); err != nil { + if err := p.Mesos.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Mesos), err) } return nil } -func (p *Container) ReadField2(iprot thrift.TProtocol) error { +func (p *Container) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Docker = &DockerContainer{} - if err := p.Docker.Read(iprot); err != nil { + if err := p.Docker.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) } return nil } -func (p *Container) Write(oprot thrift.TProtocol) error { +func (p *Container) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsContainer(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("Container"); err != nil { + if err := oprot.WriteStructBegin(ctx, "Container"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Container) writeField1(oprot thrift.TProtocol) (err error) { +func (p *Container) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMesos() { - if err := oprot.WriteFieldBegin("mesos", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "mesos", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:mesos: ", p), err) } - if err := p.Mesos.Write(oprot); err != nil { + if err := p.Mesos.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Mesos), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:mesos: ", p), err) } } return err } -func (p *Container) writeField2(oprot thrift.TProtocol) (err error) { +func (p *Container) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetDocker() { - if err := oprot.WriteFieldBegin("docker", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "docker", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:docker: ", p), err) } - if err := p.Docker.Write(oprot); err != nil { + if err := p.Docker.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:docker: ", p), err) } } return err } +func (p *Container) Equals(other *Container) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Mesos.Equals(other.Mesos) { return false } + if !p.Docker.Equals(other.Docker) { return false } + return true +} + func (p *Container) String() string { if p == nil { return "" @@ -4162,14 +4474,14 @@ func (p *Resource) IsSetNumGpus() bool { return p.NumGpus != nil } -func (p *Resource) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Resource) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4177,71 +4489,71 @@ func (p *Resource) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.DOUBLE { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.I64 { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Resource) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { +func (p *Resource) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.NumCpus = &v @@ -4249,8 +4561,8 @@ func (p *Resource) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Resource) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *Resource) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.RamMb = &v @@ -4258,8 +4570,8 @@ func (p *Resource) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Resource) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *Resource) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.DiskMb = &v @@ -4267,8 +4579,8 @@ func (p *Resource) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *Resource) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *Resource) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.NamedPort = &v @@ -4276,8 +4588,8 @@ func (p *Resource) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *Resource) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *Resource) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 5: ", err) } else { p.NumGpus = &v @@ -4285,86 +4597,125 @@ func (p *Resource) ReadField5(iprot thrift.TProtocol) error { return nil } -func (p *Resource) Write(oprot thrift.TProtocol) error { +func (p *Resource) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsResource(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("Resource"); err != nil { + if err := oprot.WriteStructBegin(ctx, "Resource"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Resource) writeField1(oprot thrift.TProtocol) (err error) { +func (p *Resource) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNumCpus() { - if err := oprot.WriteFieldBegin("numCpus", thrift.DOUBLE, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "numCpus", thrift.DOUBLE, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:numCpus: ", p), err) } - if err := oprot.WriteDouble(float64(*p.NumCpus)); err != nil { + if err := oprot.WriteDouble(ctx, float64(*p.NumCpus)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.numCpus (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:numCpus: ", p), err) } } return err } -func (p *Resource) writeField2(oprot thrift.TProtocol) (err error) { +func (p *Resource) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetRamMb() { - if err := oprot.WriteFieldBegin("ramMb", thrift.I64, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "ramMb", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ramMb: ", p), err) } - if err := oprot.WriteI64(int64(*p.RamMb)); err != nil { + if err := oprot.WriteI64(ctx, int64(*p.RamMb)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.ramMb (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ramMb: ", p), err) } } return err } -func (p *Resource) writeField3(oprot thrift.TProtocol) (err error) { +func (p *Resource) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetDiskMb() { - if err := oprot.WriteFieldBegin("diskMb", thrift.I64, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "diskMb", thrift.I64, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:diskMb: ", p), err) } - if err := oprot.WriteI64(int64(*p.DiskMb)); err != nil { + if err := oprot.WriteI64(ctx, int64(*p.DiskMb)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.diskMb (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:diskMb: ", p), err) } } return err } -func (p *Resource) writeField4(oprot thrift.TProtocol) (err error) { +func (p *Resource) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNamedPort() { - if err := oprot.WriteFieldBegin("namedPort", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "namedPort", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:namedPort: ", p), err) } - if err := oprot.WriteString(string(*p.NamedPort)); err != nil { + if err := oprot.WriteString(ctx, string(*p.NamedPort)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.namedPort (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:namedPort: ", p), err) } } return err } -func (p *Resource) writeField5(oprot thrift.TProtocol) (err error) { +func (p *Resource) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNumGpus() { - if err := oprot.WriteFieldBegin("numGpus", thrift.I64, 5); err != nil { + if err := oprot.WriteFieldBegin(ctx, "numGpus", thrift.I64, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:numGpus: ", p), err) } - if err := oprot.WriteI64(int64(*p.NumGpus)); err != nil { + if err := oprot.WriteI64(ctx, int64(*p.NumGpus)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.numGpus (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:numGpus: ", p), err) } } return err } +func (p *Resource) Equals(other *Resource) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.NumCpus != other.NumCpus { + if p.NumCpus == nil || other.NumCpus == nil { + return false + } + if (*p.NumCpus) != (*other.NumCpus) { return false } + } + if p.RamMb != other.RamMb { + if p.RamMb == nil || other.RamMb == nil { + return false + } + if (*p.RamMb) != (*other.RamMb) { return false } + } + if p.DiskMb != other.DiskMb { + if p.DiskMb == nil || other.DiskMb == nil { + return false + } + if (*p.DiskMb) != (*other.DiskMb) { return false } + } + if p.NamedPort != other.NamedPort { + if p.NamedPort == nil || other.NamedPort == nil { + return false + } + if (*p.NamedPort) != (*other.NamedPort) { return false } + } + if p.NumGpus != other.NumGpus { + if p.NumGpus == nil || other.NumGpus == nil { + return false + } + if (*p.NumGpus) != (*other.NumGpus) { return false } + } + return true +} + func (p *Resource) String() string { if p == nil { return "" @@ -4399,14 +4750,14 @@ func (p *PartitionPolicy) IsSetDelaySecs() bool { return p.DelaySecs != nil } -func (p *PartitionPolicy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *PartitionPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4414,41 +4765,41 @@ func (p *PartitionPolicy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.BOOL { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *PartitionPolicy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *PartitionPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Reschedule = v @@ -4456,8 +4807,8 @@ func (p *PartitionPolicy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *PartitionPolicy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *PartitionPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.DelaySecs = &v @@ -4465,42 +4816,58 @@ func (p *PartitionPolicy) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *PartitionPolicy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PartitionPolicy"); err != nil { +func (p *PartitionPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PartitionPolicy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *PartitionPolicy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("reschedule", thrift.BOOL, 1); err != nil { +func (p *PartitionPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reschedule", thrift.BOOL, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reschedule: ", p), err) } - if err := oprot.WriteBool(bool(p.Reschedule)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.Reschedule)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.reschedule (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reschedule: ", p), err) } return err } -func (p *PartitionPolicy) writeField2(oprot thrift.TProtocol) (err error) { +func (p *PartitionPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetDelaySecs() { - if err := oprot.WriteFieldBegin("delaySecs", thrift.I64, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "delaySecs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:delaySecs: ", p), err) } - if err := oprot.WriteI64(int64(*p.DelaySecs)); err != nil { + if err := oprot.WriteI64(ctx, int64(*p.DelaySecs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.delaySecs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:delaySecs: ", p), err) } } return err } +func (p *PartitionPolicy) Equals(other *PartitionPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Reschedule != other.Reschedule { return false } + if p.DelaySecs != other.DelaySecs { + if p.DelaySecs == nil || other.DelaySecs == nil { + return false + } + if (*p.DelaySecs) != (*other.DelaySecs) { return false } + } + return true +} + func (p *PartitionPolicy) String() string { if p == nil { return "" @@ -4530,14 +4897,14 @@ func (p *PercentageSlaPolicy) GetPercentage() float64 { func (p *PercentageSlaPolicy) GetDurationSecs() int64 { return p.DurationSecs } -func (p *PercentageSlaPolicy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *PercentageSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4545,41 +4912,41 @@ func (p *PercentageSlaPolicy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.DOUBLE { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *PercentageSlaPolicy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { +func (p *PercentageSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Percentage = v @@ -4587,8 +4954,8 @@ func (p *PercentageSlaPolicy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *PercentageSlaPolicy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *PercentageSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.DurationSecs = v @@ -4596,40 +4963,51 @@ func (p *PercentageSlaPolicy) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *PercentageSlaPolicy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PercentageSlaPolicy"); err != nil { +func (p *PercentageSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PercentageSlaPolicy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *PercentageSlaPolicy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("percentage", thrift.DOUBLE, 1); err != nil { +func (p *PercentageSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "percentage", thrift.DOUBLE, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:percentage: ", p), err) } - if err := oprot.WriteDouble(float64(p.Percentage)); err != nil { + if err := oprot.WriteDouble(ctx, float64(p.Percentage)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.percentage (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:percentage: ", p), err) } return err } -func (p *PercentageSlaPolicy) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("durationSecs", thrift.I64, 2); err != nil { +func (p *PercentageSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "durationSecs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:durationSecs: ", p), err) } - if err := oprot.WriteI64(int64(p.DurationSecs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.DurationSecs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.durationSecs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:durationSecs: ", p), err) } return err } +func (p *PercentageSlaPolicy) Equals(other *PercentageSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Percentage != other.Percentage { return false } + if p.DurationSecs != other.DurationSecs { return false } + return true +} + func (p *PercentageSlaPolicy) String() string { if p == nil { return "" @@ -4659,14 +5037,14 @@ func (p *CountSlaPolicy) GetCount() int64 { func (p *CountSlaPolicy) GetDurationSecs() int64 { return p.DurationSecs } -func (p *CountSlaPolicy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *CountSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4674,41 +5052,41 @@ func (p *CountSlaPolicy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I64 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *CountSlaPolicy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *CountSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Count = v @@ -4716,8 +5094,8 @@ func (p *CountSlaPolicy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *CountSlaPolicy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *CountSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.DurationSecs = v @@ -4725,40 +5103,51 @@ func (p *CountSlaPolicy) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *CountSlaPolicy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("CountSlaPolicy"); err != nil { +func (p *CountSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "CountSlaPolicy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *CountSlaPolicy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("count", thrift.I64, 1); err != nil { +func (p *CountSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "count", thrift.I64, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:count: ", p), err) } - if err := oprot.WriteI64(int64(p.Count)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.Count)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.count (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:count: ", p), err) } return err } -func (p *CountSlaPolicy) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("durationSecs", thrift.I64, 2); err != nil { +func (p *CountSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "durationSecs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:durationSecs: ", p), err) } - if err := oprot.WriteI64(int64(p.DurationSecs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.DurationSecs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.durationSecs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:durationSecs: ", p), err) } return err } +func (p *CountSlaPolicy) Equals(other *CountSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Count != other.Count { return false } + if p.DurationSecs != other.DurationSecs { return false } + return true +} + func (p *CountSlaPolicy) String() string { if p == nil { return "" @@ -4788,14 +5177,14 @@ func (p *CoordinatorSlaPolicy) GetCoordinatorUrl() string { func (p *CoordinatorSlaPolicy) GetStatusKey() string { return p.StatusKey } -func (p *CoordinatorSlaPolicy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *CoordinatorSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4803,41 +5192,41 @@ func (p *CoordinatorSlaPolicy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *CoordinatorSlaPolicy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *CoordinatorSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.CoordinatorUrl = v @@ -4845,8 +5234,8 @@ func (p *CoordinatorSlaPolicy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *CoordinatorSlaPolicy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *CoordinatorSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.StatusKey = v @@ -4854,40 +5243,51 @@ func (p *CoordinatorSlaPolicy) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *CoordinatorSlaPolicy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("CoordinatorSlaPolicy"); err != nil { +func (p *CoordinatorSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "CoordinatorSlaPolicy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *CoordinatorSlaPolicy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("coordinatorUrl", thrift.STRING, 1); err != nil { +func (p *CoordinatorSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "coordinatorUrl", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:coordinatorUrl: ", p), err) } - if err := oprot.WriteString(string(p.CoordinatorUrl)); err != nil { + if err := oprot.WriteString(ctx, string(p.CoordinatorUrl)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.coordinatorUrl (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:coordinatorUrl: ", p), err) } return err } -func (p *CoordinatorSlaPolicy) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statusKey", thrift.STRING, 2); err != nil { +func (p *CoordinatorSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statusKey", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:statusKey: ", p), err) } - if err := oprot.WriteString(string(p.StatusKey)); err != nil { + if err := oprot.WriteString(ctx, string(p.StatusKey)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.statusKey (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:statusKey: ", p), err) } return err } +func (p *CoordinatorSlaPolicy) Equals(other *CoordinatorSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.CoordinatorUrl != other.CoordinatorUrl { return false } + if p.StatusKey != other.StatusKey { return false } + return true +} + func (p *CoordinatorSlaPolicy) String() string { if p == nil { return "" @@ -4959,14 +5359,14 @@ func (p *SlaPolicy) IsSetCoordinatorSlaPolicy() bool { return p.CoordinatorSlaPolicy != nil } -func (p *SlaPolicy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *SlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -4974,130 +5374,142 @@ func (p *SlaPolicy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *SlaPolicy) ReadField1(iprot thrift.TProtocol) error { +func (p *SlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.PercentageSlaPolicy = &PercentageSlaPolicy{} - if err := p.PercentageSlaPolicy.Read(iprot); err != nil { + if err := p.PercentageSlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PercentageSlaPolicy), err) } return nil } -func (p *SlaPolicy) ReadField2(iprot thrift.TProtocol) error { +func (p *SlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.CountSlaPolicy = &CountSlaPolicy{} - if err := p.CountSlaPolicy.Read(iprot); err != nil { + if err := p.CountSlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.CountSlaPolicy), err) } return nil } -func (p *SlaPolicy) ReadField3(iprot thrift.TProtocol) error { +func (p *SlaPolicy) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.CoordinatorSlaPolicy = &CoordinatorSlaPolicy{} - if err := p.CoordinatorSlaPolicy.Read(iprot); err != nil { + if err := p.CoordinatorSlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.CoordinatorSlaPolicy), err) } return nil } -func (p *SlaPolicy) Write(oprot thrift.TProtocol) error { +func (p *SlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsSlaPolicy(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("SlaPolicy"); err != nil { + if err := oprot.WriteStructBegin(ctx, "SlaPolicy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *SlaPolicy) writeField1(oprot thrift.TProtocol) (err error) { +func (p *SlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetPercentageSlaPolicy() { - if err := oprot.WriteFieldBegin("percentageSlaPolicy", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "percentageSlaPolicy", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:percentageSlaPolicy: ", p), err) } - if err := p.PercentageSlaPolicy.Write(oprot); err != nil { + if err := p.PercentageSlaPolicy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PercentageSlaPolicy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:percentageSlaPolicy: ", p), err) } } return err } -func (p *SlaPolicy) writeField2(oprot thrift.TProtocol) (err error) { +func (p *SlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetCountSlaPolicy() { - if err := oprot.WriteFieldBegin("countSlaPolicy", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "countSlaPolicy", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:countSlaPolicy: ", p), err) } - if err := p.CountSlaPolicy.Write(oprot); err != nil { + if err := p.CountSlaPolicy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.CountSlaPolicy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:countSlaPolicy: ", p), err) } } return err } -func (p *SlaPolicy) writeField3(oprot thrift.TProtocol) (err error) { +func (p *SlaPolicy) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetCoordinatorSlaPolicy() { - if err := oprot.WriteFieldBegin("coordinatorSlaPolicy", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "coordinatorSlaPolicy", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:coordinatorSlaPolicy: ", p), err) } - if err := p.CoordinatorSlaPolicy.Write(oprot); err != nil { + if err := p.CoordinatorSlaPolicy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.CoordinatorSlaPolicy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:coordinatorSlaPolicy: ", p), err) } } return err } +func (p *SlaPolicy) Equals(other *SlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PercentageSlaPolicy.Equals(other.PercentageSlaPolicy) { return false } + if !p.CountSlaPolicy.Equals(other.CountSlaPolicy) { return false } + if !p.CoordinatorSlaPolicy.Equals(other.CoordinatorSlaPolicy) { return false } + return true +} + func (p *SlaPolicy) String() string { if p == nil { return "" @@ -5308,14 +5720,14 @@ func (p *TaskConfig) IsSetContainer() bool { return p.Container != nil } -func (p *TaskConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *TaskConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -5323,207 +5735,207 @@ func (p *TaskConfig) Read(iprot thrift.TProtocol) error { switch fieldId { case 28: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField28(iprot); err != nil { + if err := p.ReadField28(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 17: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField17(iprot); err != nil { + if err := p.ReadField17(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.BOOL { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 11: if fieldTypeId == thrift.I32 { - if err := p.ReadField11(iprot); err != nil { + if err := p.ReadField11(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 13: if fieldTypeId == thrift.I32 { - if err := p.ReadField13(iprot); err != nil { + if err := p.ReadField13(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 18: if fieldTypeId == thrift.BOOL { - if err := p.ReadField18(iprot); err != nil { + if err := p.ReadField18(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 30: if fieldTypeId == thrift.STRING { - if err := p.ReadField30(iprot); err != nil { + if err := p.ReadField30(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 32: if fieldTypeId == thrift.SET { - if err := p.ReadField32(iprot); err != nil { + if err := p.ReadField32(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 20: if fieldTypeId == thrift.SET { - if err := p.ReadField20(iprot); err != nil { + if err := p.ReadField20(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 33: if fieldTypeId == thrift.SET { - if err := p.ReadField33(iprot); err != nil { + if err := p.ReadField33(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 22: if fieldTypeId == thrift.MAP { - if err := p.ReadField22(iprot); err != nil { + if err := p.ReadField22(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 23: if fieldTypeId == thrift.STRING { - if err := p.ReadField23(iprot); err != nil { + if err := p.ReadField23(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 25: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField25(iprot); err != nil { + if err := p.ReadField25(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 27: if fieldTypeId == thrift.SET { - if err := p.ReadField27(iprot); err != nil { + if err := p.ReadField27(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 34: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField34(iprot); err != nil { + if err := p.ReadField34(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 35: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField35(iprot); err != nil { + if err := p.ReadField35(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 29: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField29(iprot); err != nil { + if err := p.ReadField29(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *TaskConfig) ReadField28(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField28(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *TaskConfig) ReadField17(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField17(ctx context.Context, iprot thrift.TProtocol) error { p.Owner = &Identity{} - if err := p.Owner.Read(iprot); err != nil { + if err := p.Owner.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) } return nil } -func (p *TaskConfig) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *TaskConfig) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 7: ", err) } else { p.IsService = v @@ -5531,8 +5943,8 @@ func (p *TaskConfig) ReadField7(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *TaskConfig) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 11: ", err) } else { p.Priority = v @@ -5540,8 +5952,8 @@ func (p *TaskConfig) ReadField11(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *TaskConfig) ReadField13(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 13: ", err) } else { p.MaxTaskFailures = v @@ -5549,8 +5961,8 @@ func (p *TaskConfig) ReadField13(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField18(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *TaskConfig) ReadField18(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 18: ", err) } else { p.Production = &v @@ -5558,8 +5970,8 @@ func (p *TaskConfig) ReadField18(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField30(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskConfig) ReadField30(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 30: ", err) } else { p.Tier = &v @@ -5567,96 +5979,96 @@ func (p *TaskConfig) ReadField30(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField32(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskConfig) ReadField32(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Resource, 0, size) p.Resources = tSet for i := 0; i < size; i ++ { - _elem5 := &Resource{} - if err := _elem5.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem5), err) + _elem10 := &Resource{} + if err := _elem10.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) } - p.Resources = append(p.Resources, _elem5) + p.Resources = append(p.Resources, _elem10) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskConfig) ReadField20(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskConfig) ReadField20(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Constraint, 0, size) p.Constraints = tSet for i := 0; i < size; i ++ { - _elem6 := &Constraint{} - if err := _elem6.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem6), err) + _elem11 := &Constraint{} + if err := _elem11.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem11), err) } - p.Constraints = append(p.Constraints, _elem6) + p.Constraints = append(p.Constraints, _elem11) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskConfig) ReadField33(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskConfig) ReadField33(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*MesosFetcherURI, 0, size) p.MesosFetcherUris = tSet for i := 0; i < size; i ++ { - _elem7 := &MesosFetcherURI{} - if err := _elem7.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem7), err) + _elem12 := &MesosFetcherURI{} + if err := _elem12.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) } - p.MesosFetcherUris = append(p.MesosFetcherUris, _elem7) + p.MesosFetcherUris = append(p.MesosFetcherUris, _elem12) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskConfig) ReadField22(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() +func (p *TaskConfig) ReadField22(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) if err != nil { return thrift.PrependError("error reading map begin: ", err) } tMap := make(map[string]string, size) p.TaskLinks = tMap for i := 0; i < size; i ++ { -var _key8 string - if v, err := iprot.ReadString(); err != nil { +var _key13 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _key8 = v + _key13 = v } -var _val9 string - if v, err := iprot.ReadString(); err != nil { +var _val14 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _val9 = v + _val14 = v } - p.TaskLinks[_key8] = _val9 + p.TaskLinks[_key13] = _val14 } - if err := iprot.ReadMapEnd(); err != nil { + if err := iprot.ReadMapEnd(ctx); err != nil { return thrift.PrependError("error reading map end: ", err) } return nil } -func (p *TaskConfig) ReadField23(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskConfig) ReadField23(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 23: ", err) } else { p.ContactEmail = &v @@ -5664,355 +6076,428 @@ func (p *TaskConfig) ReadField23(iprot thrift.TProtocol) error { return nil } -func (p *TaskConfig) ReadField25(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField25(ctx context.Context, iprot thrift.TProtocol) error { p.ExecutorConfig = &ExecutorConfig{} - if err := p.ExecutorConfig.Read(iprot); err != nil { + if err := p.ExecutorConfig.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ExecutorConfig), err) } return nil } -func (p *TaskConfig) ReadField27(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskConfig) ReadField27(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Metadata, 0, size) p.Metadata = tSet for i := 0; i < size; i ++ { - _elem10 := &Metadata{} - if err := _elem10.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) + _elem15 := &Metadata{} + if err := _elem15.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem15), err) } - p.Metadata = append(p.Metadata, _elem10) + p.Metadata = append(p.Metadata, _elem15) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskConfig) ReadField34(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField34(ctx context.Context, iprot thrift.TProtocol) error { p.PartitionPolicy = &PartitionPolicy{} - if err := p.PartitionPolicy.Read(iprot); err != nil { + if err := p.PartitionPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PartitionPolicy), err) } return nil } -func (p *TaskConfig) ReadField35(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField35(ctx context.Context, iprot thrift.TProtocol) error { p.SlaPolicy = &SlaPolicy{} - if err := p.SlaPolicy.Read(iprot); err != nil { + if err := p.SlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.SlaPolicy), err) } return nil } -func (p *TaskConfig) ReadField29(iprot thrift.TProtocol) error { +func (p *TaskConfig) ReadField29(ctx context.Context, iprot thrift.TProtocol) error { p.Container = &Container{} - if err := p.Container.Read(iprot); err != nil { + if err := p.Container.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Container), err) } return nil } -func (p *TaskConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskConfig"); err != nil { +func (p *TaskConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskConfig"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField17(oprot); err != nil { return err } - if err := p.writeField18(oprot); err != nil { return err } - if err := p.writeField20(oprot); err != nil { return err } - if err := p.writeField22(oprot); err != nil { return err } - if err := p.writeField23(oprot); err != nil { return err } - if err := p.writeField25(oprot); err != nil { return err } - if err := p.writeField27(oprot); err != nil { return err } - if err := p.writeField28(oprot); err != nil { return err } - if err := p.writeField29(oprot); err != nil { return err } - if err := p.writeField30(oprot); err != nil { return err } - if err := p.writeField32(oprot); err != nil { return err } - if err := p.writeField33(oprot); err != nil { return err } - if err := p.writeField34(oprot); err != nil { return err } - if err := p.writeField35(oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField13(ctx, oprot); err != nil { return err } + if err := p.writeField17(ctx, oprot); err != nil { return err } + if err := p.writeField18(ctx, oprot); err != nil { return err } + if err := p.writeField20(ctx, oprot); err != nil { return err } + if err := p.writeField22(ctx, oprot); err != nil { return err } + if err := p.writeField23(ctx, oprot); err != nil { return err } + if err := p.writeField25(ctx, oprot); err != nil { return err } + if err := p.writeField27(ctx, oprot); err != nil { return err } + if err := p.writeField28(ctx, oprot); err != nil { return err } + if err := p.writeField29(ctx, oprot); err != nil { return err } + if err := p.writeField30(ctx, oprot); err != nil { return err } + if err := p.writeField32(ctx, oprot); err != nil { return err } + if err := p.writeField33(ctx, oprot); err != nil { return err } + if err := p.writeField34(ctx, oprot); err != nil { return err } + if err := p.writeField35(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *TaskConfig) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("isService", thrift.BOOL, 7); err != nil { +func (p *TaskConfig) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "isService", thrift.BOOL, 7); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:isService: ", p), err) } - if err := oprot.WriteBool(bool(p.IsService)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.IsService)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.isService (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 7:isService: ", p), err) } return err } -func (p *TaskConfig) writeField11(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("priority", thrift.I32, 11); err != nil { +func (p *TaskConfig) writeField11(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "priority", thrift.I32, 11); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:priority: ", p), err) } - if err := oprot.WriteI32(int32(p.Priority)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Priority)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.priority (11) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 11:priority: ", p), err) } return err } -func (p *TaskConfig) writeField13(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxTaskFailures", thrift.I32, 13); err != nil { +func (p *TaskConfig) writeField13(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxTaskFailures", thrift.I32, 13); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:maxTaskFailures: ", p), err) } - if err := oprot.WriteI32(int32(p.MaxTaskFailures)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.MaxTaskFailures)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.maxTaskFailures (13) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 13:maxTaskFailures: ", p), err) } return err } -func (p *TaskConfig) writeField17(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("owner", thrift.STRUCT, 17); err != nil { +func (p *TaskConfig) writeField17(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "owner", thrift.STRUCT, 17); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:owner: ", p), err) } - if err := p.Owner.Write(oprot); err != nil { + if err := p.Owner.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 17:owner: ", p), err) } return err } -func (p *TaskConfig) writeField18(oprot thrift.TProtocol) (err error) { +func (p *TaskConfig) writeField18(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetProduction() { - if err := oprot.WriteFieldBegin("production", thrift.BOOL, 18); err != nil { + if err := oprot.WriteFieldBegin(ctx, "production", thrift.BOOL, 18); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:production: ", p), err) } - if err := oprot.WriteBool(bool(*p.Production)); err != nil { + if err := oprot.WriteBool(ctx, bool(*p.Production)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.production (18) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 18:production: ", p), err) } } return err } -func (p *TaskConfig) writeField20(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("constraints", thrift.SET, 20); err != nil { +func (p *TaskConfig) writeField20(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "constraints", thrift.SET, 20); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:constraints: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Constraints)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Constraints)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -6035,14 +6520,14 @@ func NewResourceAggregate() *ResourceAggregate { func (p *ResourceAggregate) GetResources() []*Resource { return p.Resources } -func (p *ResourceAggregate) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ResourceAggregate) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -6050,88 +6535,105 @@ func (p *ResourceAggregate) Read(iprot thrift.TProtocol) error { switch fieldId { case 4: if fieldTypeId == thrift.SET { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ResourceAggregate) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *ResourceAggregate) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Resource, 0, size) p.Resources = tSet for i := 0; i < size; i ++ { - _elem11 := &Resource{} - if err := _elem11.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem11), err) + _elem21 := &Resource{} + if err := _elem21.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem21), err) } - p.Resources = append(p.Resources, _elem11) + p.Resources = append(p.Resources, _elem21) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *ResourceAggregate) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ResourceAggregate"); err != nil { +func (p *ResourceAggregate) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ResourceAggregate"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ResourceAggregate) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("resources", thrift.SET, 4); err != nil { +func (p *ResourceAggregate) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "resources", thrift.SET, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:resources: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Resources)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Resources)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -6216,14 +6718,14 @@ func (p *JobConfiguration) IsSetTaskConfig() bool { return p.TaskConfig != nil } -func (p *JobConfiguration) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobConfiguration) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -6231,97 +6733,97 @@ func (p *JobConfiguration) Read(iprot thrift.TProtocol) error { switch fieldId { case 9: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField9(iprot); err != nil { + if err := p.ReadField9(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.I32 { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 8: if fieldTypeId == thrift.I32 { - if err := p.ReadField8(iprot); err != nil { + if err := p.ReadField8(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobConfiguration) ReadField9(iprot thrift.TProtocol) error { +func (p *JobConfiguration) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &JobKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *JobConfiguration) ReadField7(iprot thrift.TProtocol) error { +func (p *JobConfiguration) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { p.Owner = &Identity{} - if err := p.Owner.Read(iprot); err != nil { + if err := p.Owner.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) } return nil } -func (p *JobConfiguration) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobConfiguration) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.CronSchedule = &v @@ -6329,8 +6831,8 @@ func (p *JobConfiguration) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *JobConfiguration) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobConfiguration) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 5: ", err) } else { temp := CronCollisionPolicy(v) @@ -6339,16 +6841,16 @@ func (p *JobConfiguration) ReadField5(iprot thrift.TProtocol) error { return nil } -func (p *JobConfiguration) ReadField6(iprot thrift.TProtocol) error { +func (p *JobConfiguration) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { + if err := p.TaskConfig.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) } return nil } -func (p *JobConfiguration) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobConfiguration) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 8: ", err) } else { p.InstanceCount = v @@ -6356,89 +6858,109 @@ func (p *JobConfiguration) ReadField8(iprot thrift.TProtocol) error { return nil } -func (p *JobConfiguration) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobConfiguration"); err != nil { +func (p *JobConfiguration) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobConfiguration"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobConfiguration) writeField4(oprot thrift.TProtocol) (err error) { +func (p *JobConfiguration) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetCronSchedule() { - if err := oprot.WriteFieldBegin("cronSchedule", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "cronSchedule", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:cronSchedule: ", p), err) } - if err := oprot.WriteString(string(*p.CronSchedule)); err != nil { + if err := oprot.WriteString(ctx, string(*p.CronSchedule)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.cronSchedule (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:cronSchedule: ", p), err) } } return err } -func (p *JobConfiguration) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("cronCollisionPolicy", thrift.I32, 5); err != nil { +func (p *JobConfiguration) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "cronCollisionPolicy", thrift.I32, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:cronCollisionPolicy: ", p), err) } - if err := oprot.WriteI32(int32(p.CronCollisionPolicy)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.CronCollisionPolicy)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.cronCollisionPolicy (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:cronCollisionPolicy: ", p), err) } return err } -func (p *JobConfiguration) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 6); err != nil { +func (p *JobConfiguration) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:taskConfig: ", p), err) } - if err := p.TaskConfig.Write(oprot); err != nil { + if err := p.TaskConfig.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:taskConfig: ", p), err) } return err } -func (p *JobConfiguration) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("owner", thrift.STRUCT, 7); err != nil { +func (p *JobConfiguration) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "owner", thrift.STRUCT, 7); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:owner: ", p), err) } - if err := p.Owner.Write(oprot); err != nil { + if err := p.Owner.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 7:owner: ", p), err) } return err } -func (p *JobConfiguration) writeField8(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceCount", thrift.I32, 8); err != nil { +func (p *JobConfiguration) writeField8(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceCount", thrift.I32, 8); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:instanceCount: ", p), err) } - if err := oprot.WriteI32(int32(p.InstanceCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.InstanceCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.instanceCount (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 8:instanceCount: ", p), err) } return err } -func (p *JobConfiguration) writeField9(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 9); err != nil { +func (p *JobConfiguration) writeField9(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 9); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:key: ", p), err) } - if err := p.Key.Write(oprot); err != nil { + if err := p.Key.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 9:key: ", p), err) } return err } +func (p *JobConfiguration) Equals(other *JobConfiguration) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.CronSchedule != other.CronSchedule { + if p.CronSchedule == nil || other.CronSchedule == nil { + return false + } + if (*p.CronSchedule) != (*other.CronSchedule) { return false } + } + if p.CronCollisionPolicy != other.CronCollisionPolicy { return false } + if !p.TaskConfig.Equals(other.TaskConfig) { return false } + if !p.Owner.Equals(other.Owner) { return false } + if p.InstanceCount != other.InstanceCount { return false } + if !p.Key.Equals(other.Key) { return false } + return true +} + func (p *JobConfiguration) String() string { if p == nil { return "" @@ -6478,14 +7000,14 @@ func (p *JobStats) GetFailedTaskCount() int32 { func (p *JobStats) GetPendingTaskCount() int32 { return p.PendingTaskCount } -func (p *JobStats) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobStats) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -6493,61 +7015,61 @@ func (p *JobStats) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.I32 { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobStats) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobStats) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.ActiveTaskCount = v @@ -6555,8 +7077,8 @@ func (p *JobStats) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobStats) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobStats) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.FinishedTaskCount = v @@ -6564,8 +7086,8 @@ func (p *JobStats) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobStats) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobStats) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.FailedTaskCount = v @@ -6573,8 +7095,8 @@ func (p *JobStats) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobStats) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobStats) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.PendingTaskCount = v @@ -6582,62 +7104,75 @@ func (p *JobStats) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *JobStats) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobStats"); err != nil { +func (p *JobStats) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobStats"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobStats) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("activeTaskCount", thrift.I32, 1); err != nil { +func (p *JobStats) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "activeTaskCount", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:activeTaskCount: ", p), err) } - if err := oprot.WriteI32(int32(p.ActiveTaskCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.ActiveTaskCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.activeTaskCount (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:activeTaskCount: ", p), err) } return err } -func (p *JobStats) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("finishedTaskCount", thrift.I32, 2); err != nil { +func (p *JobStats) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "finishedTaskCount", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:finishedTaskCount: ", p), err) } - if err := oprot.WriteI32(int32(p.FinishedTaskCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.FinishedTaskCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.finishedTaskCount (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:finishedTaskCount: ", p), err) } return err } -func (p *JobStats) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("failedTaskCount", thrift.I32, 3); err != nil { +func (p *JobStats) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "failedTaskCount", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failedTaskCount: ", p), err) } - if err := oprot.WriteI32(int32(p.FailedTaskCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.FailedTaskCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.failedTaskCount (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failedTaskCount: ", p), err) } return err } -func (p *JobStats) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("pendingTaskCount", thrift.I32, 4); err != nil { +func (p *JobStats) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "pendingTaskCount", thrift.I32, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:pendingTaskCount: ", p), err) } - if err := oprot.WriteI32(int32(p.PendingTaskCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.PendingTaskCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.pendingTaskCount (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:pendingTaskCount: ", p), err) } return err } +func (p *JobStats) Equals(other *JobStats) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ActiveTaskCount != other.ActiveTaskCount { return false } + if p.FinishedTaskCount != other.FinishedTaskCount { return false } + if p.FailedTaskCount != other.FailedTaskCount { return false } + if p.PendingTaskCount != other.PendingTaskCount { return false } + return true +} + func (p *JobStats) String() string { if p == nil { return "" @@ -6692,14 +7227,14 @@ func (p *JobSummary) IsSetNextCronRunMs() bool { return p.NextCronRunMs != nil } -func (p *JobSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -6707,67 +7242,67 @@ func (p *JobSummary) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobSummary) ReadField1(iprot thrift.TProtocol) error { +func (p *JobSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobConfiguration{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *JobSummary) ReadField2(iprot thrift.TProtocol) error { +func (p *JobSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Stats = &JobStats{} - if err := p.Stats.Read(iprot); err != nil { + if err := p.Stats.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Stats), err) } return nil } -func (p *JobSummary) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *JobSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.NextCronRunMs = &v @@ -6775,55 +7310,72 @@ func (p *JobSummary) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobSummary"); err != nil { +func (p *JobSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobSummary"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { +func (p *JobSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } return err } -func (p *JobSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stats", thrift.STRUCT, 2); err != nil { +func (p *JobSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "stats", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:stats: ", p), err) } - if err := p.Stats.Write(oprot); err != nil { + if err := p.Stats.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Stats), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:stats: ", p), err) } return err } -func (p *JobSummary) writeField3(oprot thrift.TProtocol) (err error) { +func (p *JobSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNextCronRunMs() { - if err := oprot.WriteFieldBegin("nextCronRunMs", thrift.I64, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "nextCronRunMs", thrift.I64, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nextCronRunMs: ", p), err) } - if err := oprot.WriteI64(int64(*p.NextCronRunMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(*p.NextCronRunMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.nextCronRunMs (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nextCronRunMs: ", p), err) } } return err } +func (p *JobSummary) Equals(other *JobSummary) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + if !p.Stats.Equals(other.Stats) { return false } + if p.NextCronRunMs != other.NextCronRunMs { + if p.NextCronRunMs == nil || other.NextCronRunMs == nil { + return false + } + if (*p.NextCronRunMs) != (*other.NextCronRunMs) { return false } + } + return true +} + func (p *JobSummary) String() string { if p == nil { return "" @@ -6853,14 +7405,14 @@ func (p *Range) GetFirst() int32 { func (p *Range) GetLast() int32 { return p.Last } -func (p *Range) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Range) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -6868,41 +7420,41 @@ func (p *Range) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Range) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *Range) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.First = v @@ -6910,8 +7462,8 @@ func (p *Range) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Range) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *Range) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Last = v @@ -6919,40 +7471,51 @@ func (p *Range) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *Range) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Range"); err != nil { +func (p *Range) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Range"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Range) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("first", thrift.I32, 1); err != nil { +func (p *Range) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "first", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:first: ", p), err) } - if err := oprot.WriteI32(int32(p.First)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.First)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.first (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:first: ", p), err) } return err } -func (p *Range) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("last", thrift.I32, 2); err != nil { +func (p *Range) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "last", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:last: ", p), err) } - if err := oprot.WriteI32(int32(p.Last)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Last)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.last (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:last: ", p), err) } return err } +func (p *Range) Equals(other *Range) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.First != other.First { return false } + if p.Last != other.Last { return false } + return true +} + func (p *Range) String() string { if p == nil { return "" @@ -6988,14 +7551,14 @@ func (p *ConfigGroup) IsSetConfig() bool { return p.Config != nil } -func (p *ConfigGroup) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ConfigGroup) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7003,118 +7566,136 @@ func (p *ConfigGroup) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.SET { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ConfigGroup) ReadField1(iprot thrift.TProtocol) error { +func (p *ConfigGroup) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Config = &TaskConfig{} - if err := p.Config.Read(iprot); err != nil { + if err := p.Config.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Config), err) } return nil } -func (p *ConfigGroup) ReadField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *ConfigGroup) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Range, 0, size) p.Instances = tSet for i := 0; i < size; i ++ { - _elem12 := &Range{} - if err := _elem12.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) + _elem23 := &Range{} + if err := _elem23.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem23), err) } - p.Instances = append(p.Instances, _elem12) + p.Instances = append(p.Instances, _elem23) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *ConfigGroup) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigGroup"); err != nil { +func (p *ConfigGroup) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigGroup"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ConfigGroup) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("config", thrift.STRUCT, 1); err != nil { +func (p *ConfigGroup) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "config", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:config: ", p), err) } - if err := p.Config.Write(oprot); err != nil { + if err := p.Config.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Config), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:config: ", p), err) } return err } -func (p *ConfigGroup) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instances", thrift.SET, 3); err != nil { +func (p *ConfigGroup) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instances", thrift.SET, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instances: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Instances)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Instances)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -7149,14 +7730,14 @@ func (p *ConfigSummary) IsSetKey() bool { return p.Key != nil } -func (p *ConfigSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ConfigSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7164,118 +7745,136 @@ func (p *ConfigSummary) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ConfigSummary) ReadField1(iprot thrift.TProtocol) error { +func (p *ConfigSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &JobKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *ConfigSummary) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *ConfigSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ConfigGroup, 0, size) p.Groups = tSet for i := 0; i < size; i ++ { - _elem13 := &ConfigGroup{} - if err := _elem13.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem13), err) + _elem25 := &ConfigGroup{} + if err := _elem25.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem25), err) } - p.Groups = append(p.Groups, _elem13) + p.Groups = append(p.Groups, _elem25) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *ConfigSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigSummary"); err != nil { +func (p *ConfigSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigSummary"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ConfigSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { +func (p *ConfigSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := p.Key.Write(oprot); err != nil { + if err := p.Key.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } return err } -func (p *ConfigSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("groups", thrift.SET, 2); err != nil { +func (p *ConfigSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groups", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:groups: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Groups)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Groups)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -7305,14 +7904,14 @@ func (p *PopulateJobResult_) IsSetTaskConfig() bool { return p.TaskConfig != nil } -func (p *PopulateJobResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *PopulateJobResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7320,61 +7919,71 @@ func (p *PopulateJobResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *PopulateJobResult_) ReadField2(iprot thrift.TProtocol) error { +func (p *PopulateJobResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { + if err := p.TaskConfig.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) } return nil } -func (p *PopulateJobResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PopulateJobResult"); err != nil { +func (p *PopulateJobResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PopulateJobResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *PopulateJobResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 2); err != nil { +func (p *PopulateJobResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:taskConfig: ", p), err) } - if err := p.TaskConfig.Write(oprot); err != nil { + if err := p.TaskConfig.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:taskConfig: ", p), err) } return err } +func (p *PopulateJobResult_) Equals(other *PopulateJobResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.TaskConfig.Equals(other.TaskConfig) { return false } + return true +} + func (p *PopulateJobResult_) String() string { if p == nil { return "" @@ -7455,14 +8064,14 @@ func (p *GetQuotaResult_) IsSetNonProdDedicatedConsumption() bool { return p.NonProdDedicatedConsumption != nil } -func (p *GetQuotaResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetQuotaResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7470,189 +8079,203 @@ func (p *GetQuotaResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetQuotaResult_) ReadField1(iprot thrift.TProtocol) error { +func (p *GetQuotaResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Quota = &ResourceAggregate{} - if err := p.Quota.Read(iprot); err != nil { + if err := p.Quota.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) } return nil } -func (p *GetQuotaResult_) ReadField2(iprot thrift.TProtocol) error { +func (p *GetQuotaResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.ProdSharedConsumption = &ResourceAggregate{} - if err := p.ProdSharedConsumption.Read(iprot); err != nil { + if err := p.ProdSharedConsumption.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdSharedConsumption), err) } return nil } -func (p *GetQuotaResult_) ReadField3(iprot thrift.TProtocol) error { +func (p *GetQuotaResult_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.NonProdSharedConsumption = &ResourceAggregate{} - if err := p.NonProdSharedConsumption.Read(iprot); err != nil { + if err := p.NonProdSharedConsumption.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdSharedConsumption), err) } return nil } -func (p *GetQuotaResult_) ReadField4(iprot thrift.TProtocol) error { +func (p *GetQuotaResult_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.ProdDedicatedConsumption = &ResourceAggregate{} - if err := p.ProdDedicatedConsumption.Read(iprot); err != nil { + if err := p.ProdDedicatedConsumption.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdDedicatedConsumption), err) } return nil } -func (p *GetQuotaResult_) ReadField5(iprot thrift.TProtocol) error { +func (p *GetQuotaResult_) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { p.NonProdDedicatedConsumption = &ResourceAggregate{} - if err := p.NonProdDedicatedConsumption.Read(iprot); err != nil { + if err := p.NonProdDedicatedConsumption.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdDedicatedConsumption), err) } return nil } -func (p *GetQuotaResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetQuotaResult"); err != nil { +func (p *GetQuotaResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetQuotaResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetQuotaResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("quota", thrift.STRUCT, 1); err != nil { +func (p *GetQuotaResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "quota", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:quota: ", p), err) } - if err := p.Quota.Write(oprot); err != nil { + if err := p.Quota.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:quota: ", p), err) } return err } -func (p *GetQuotaResult_) writeField2(oprot thrift.TProtocol) (err error) { +func (p *GetQuotaResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetProdSharedConsumption() { - if err := oprot.WriteFieldBegin("prodSharedConsumption", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "prodSharedConsumption", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:prodSharedConsumption: ", p), err) } - if err := p.ProdSharedConsumption.Write(oprot); err != nil { + if err := p.ProdSharedConsumption.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdSharedConsumption), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:prodSharedConsumption: ", p), err) } } return err } -func (p *GetQuotaResult_) writeField3(oprot thrift.TProtocol) (err error) { +func (p *GetQuotaResult_) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNonProdSharedConsumption() { - if err := oprot.WriteFieldBegin("nonProdSharedConsumption", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "nonProdSharedConsumption", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nonProdSharedConsumption: ", p), err) } - if err := p.NonProdSharedConsumption.Write(oprot); err != nil { + if err := p.NonProdSharedConsumption.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdSharedConsumption), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nonProdSharedConsumption: ", p), err) } } return err } -func (p *GetQuotaResult_) writeField4(oprot thrift.TProtocol) (err error) { +func (p *GetQuotaResult_) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetProdDedicatedConsumption() { - if err := oprot.WriteFieldBegin("prodDedicatedConsumption", thrift.STRUCT, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "prodDedicatedConsumption", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:prodDedicatedConsumption: ", p), err) } - if err := p.ProdDedicatedConsumption.Write(oprot); err != nil { + if err := p.ProdDedicatedConsumption.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdDedicatedConsumption), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:prodDedicatedConsumption: ", p), err) } } return err } -func (p *GetQuotaResult_) writeField5(oprot thrift.TProtocol) (err error) { +func (p *GetQuotaResult_) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetNonProdDedicatedConsumption() { - if err := oprot.WriteFieldBegin("nonProdDedicatedConsumption", thrift.STRUCT, 5); err != nil { + if err := oprot.WriteFieldBegin(ctx, "nonProdDedicatedConsumption", thrift.STRUCT, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:nonProdDedicatedConsumption: ", p), err) } - if err := p.NonProdDedicatedConsumption.Write(oprot); err != nil { + if err := p.NonProdDedicatedConsumption.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdDedicatedConsumption), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:nonProdDedicatedConsumption: ", p), err) } } return err } +func (p *GetQuotaResult_) Equals(other *GetQuotaResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Quota.Equals(other.Quota) { return false } + if !p.ProdSharedConsumption.Equals(other.ProdSharedConsumption) { return false } + if !p.NonProdSharedConsumption.Equals(other.NonProdSharedConsumption) { return false } + if !p.ProdDedicatedConsumption.Equals(other.ProdDedicatedConsumption) { return false } + if !p.NonProdDedicatedConsumption.Equals(other.NonProdDedicatedConsumption) { return false } + return true +} + func (p *GetQuotaResult_) String() string { if p == nil { return "" @@ -7708,14 +8331,14 @@ func (p *TaskEvent) IsSetScheduler() bool { return p.Scheduler != nil } -func (p *TaskEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *TaskEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7723,61 +8346,61 @@ func (p *TaskEvent) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I64 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *TaskEvent) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *TaskEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Timestamp = v @@ -7785,8 +8408,8 @@ func (p *TaskEvent) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *TaskEvent) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *TaskEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { temp := ScheduleStatus(v) @@ -7795,8 +8418,8 @@ func (p *TaskEvent) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *TaskEvent) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.Message = &v @@ -7804,8 +8427,8 @@ func (p *TaskEvent) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *TaskEvent) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.Scheduler = &v @@ -7813,66 +8436,89 @@ func (p *TaskEvent) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *TaskEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskEvent"); err != nil { +func (p *TaskEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskEvent"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *TaskEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil { +func (p *TaskEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestamp", thrift.I64, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:timestamp: ", p), err) } - if err := oprot.WriteI64(int64(p.Timestamp)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.Timestamp)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timestamp (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:timestamp: ", p), err) } return err } -func (p *TaskEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { +func (p *TaskEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } return err } -func (p *TaskEvent) writeField3(oprot thrift.TProtocol) (err error) { +func (p *TaskEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } - if err := oprot.WriteString(string(*p.Message)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } } return err } -func (p *TaskEvent) writeField4(oprot thrift.TProtocol) (err error) { +func (p *TaskEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetScheduler() { - if err := oprot.WriteFieldBegin("scheduler", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "scheduler", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:scheduler: ", p), err) } - if err := oprot.WriteString(string(*p.Scheduler)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Scheduler)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.scheduler (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:scheduler: ", p), err) } } return err } +func (p *TaskEvent) Equals(other *TaskEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Timestamp != other.Timestamp { return false } + if p.Status != other.Status { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + if p.Scheduler != other.Scheduler { + if p.Scheduler == nil || other.Scheduler == nil { + return false + } + if (*p.Scheduler) != (*other.Scheduler) { return false } + } + return true +} + func (p *TaskEvent) String() string { if p == nil { return "" @@ -7936,14 +8582,14 @@ func (p *AssignedTask) IsSetTask() bool { return p.Task != nil } -func (p *AssignedTask) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AssignedTask) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -7951,81 +8597,81 @@ func (p *AssignedTask) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.MAP { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.I32 { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AssignedTask) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AssignedTask) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.TaskId = v @@ -8033,8 +8679,8 @@ func (p *AssignedTask) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *AssignedTask) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AssignedTask) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.SlaveId = v @@ -8042,8 +8688,8 @@ func (p *AssignedTask) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *AssignedTask) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AssignedTask) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.SlaveHost = v @@ -8051,44 +8697,44 @@ func (p *AssignedTask) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *AssignedTask) ReadField4(iprot thrift.TProtocol) error { +func (p *AssignedTask) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.Task = &TaskConfig{} - if err := p.Task.Read(iprot); err != nil { + if err := p.Task.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) } return nil } -func (p *AssignedTask) ReadField5(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() +func (p *AssignedTask) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) if err != nil { return thrift.PrependError("error reading map begin: ", err) } tMap := make(map[string]int32, size) p.AssignedPorts = tMap for i := 0; i < size; i ++ { -var _key14 string - if v, err := iprot.ReadString(); err != nil { +var _key27 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _key14 = v + _key27 = v } -var _val15 int32 - if v, err := iprot.ReadI32(); err != nil { +var _val28 int32 + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _val15 = v + _val28 = v } - p.AssignedPorts[_key14] = _val15 + p.AssignedPorts[_key27] = _val28 } - if err := iprot.ReadMapEnd(); err != nil { + if err := iprot.ReadMapEnd(ctx); err != nil { return thrift.PrependError("error reading map end: ", err) } return nil } -func (p *AssignedTask) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *AssignedTask) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 6: ", err) } else { p.InstanceId = v @@ -8096,95 +8742,114 @@ func (p *AssignedTask) ReadField6(iprot thrift.TProtocol) error { return nil } -func (p *AssignedTask) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("AssignedTask"); err != nil { +func (p *AssignedTask) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "AssignedTask"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AssignedTask) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { +func (p *AssignedTask) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } - if err := oprot.WriteString(string(p.TaskId)); err != nil { + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } return err } -func (p *AssignedTask) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("slaveId", thrift.STRING, 2); err != nil { +func (p *AssignedTask) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "slaveId", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:slaveId: ", p), err) } - if err := oprot.WriteString(string(p.SlaveId)); err != nil { + if err := oprot.WriteString(ctx, string(p.SlaveId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.slaveId (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:slaveId: ", p), err) } return err } -func (p *AssignedTask) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("slaveHost", thrift.STRING, 3); err != nil { +func (p *AssignedTask) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "slaveHost", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:slaveHost: ", p), err) } - if err := oprot.WriteString(string(p.SlaveHost)); err != nil { + if err := oprot.WriteString(ctx, string(p.SlaveHost)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.slaveHost (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:slaveHost: ", p), err) } return err } -func (p *AssignedTask) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("task", thrift.STRUCT, 4); err != nil { +func (p *AssignedTask) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "task", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:task: ", p), err) } - if err := p.Task.Write(oprot); err != nil { + if err := p.Task.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:task: ", p), err) } return err } -func (p *AssignedTask) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("assignedPorts", thrift.MAP, 5); err != nil { +func (p *AssignedTask) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "assignedPorts", thrift.MAP, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:assignedPorts: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.AssignedPorts)); err != nil { + if err := oprot.WriteMapBegin(ctx, thrift.STRING, thrift.I32, len(p.AssignedPorts)); err != nil { return thrift.PrependError("error writing map begin: ", err) } for k, v := range p.AssignedPorts { - if err := oprot.WriteString(string(k)); err != nil { + if err := oprot.WriteString(ctx, string(k)); err != nil { return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteI32(int32(v)); err != nil { + if err := oprot.WriteI32(ctx, int32(v)); err != nil { return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } } - if err := oprot.WriteMapEnd(); err != nil { + if err := oprot.WriteMapEnd(ctx); err != nil { return thrift.PrependError("error writing map end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:assignedPorts: ", p), err) } return err } -func (p *AssignedTask) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 6); err != nil { +func (p *AssignedTask) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:instanceId: ", p), err) } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.instanceId (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:instanceId: ", p), err) } return err } +func (p *AssignedTask) Equals(other *AssignedTask) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.TaskId != other.TaskId { return false } + if p.SlaveId != other.SlaveId { return false } + if p.SlaveHost != other.SlaveHost { return false } + if !p.Task.Equals(other.Task) { return false } + if len(p.AssignedPorts) != len(other.AssignedPorts) { return false } + for k, _tgt := range p.AssignedPorts { + _src29 := other.AssignedPorts[k] + if _tgt != _src29 { return false } + } + if p.InstanceId != other.InstanceId { return false } + return true +} + func (p *AssignedTask) String() string { if p == nil { return "" @@ -8247,14 +8912,14 @@ func (p *ScheduledTask) IsSetAssignedTask() bool { return p.AssignedTask != nil } -func (p *ScheduledTask) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ScheduledTask) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -8262,89 +8927,89 @@ func (p *ScheduledTask) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.I32 { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.LIST { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.STRING { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ScheduledTask) ReadField1(iprot thrift.TProtocol) error { +func (p *ScheduledTask) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.AssignedTask = &AssignedTask{} - if err := p.AssignedTask.Read(iprot); err != nil { + if err := p.AssignedTask.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AssignedTask), err) } return nil } -func (p *ScheduledTask) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *ScheduledTask) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { temp := ScheduleStatus(v) @@ -8353,8 +9018,8 @@ func (p *ScheduledTask) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *ScheduledTask) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *ScheduledTask) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.FailureCount = v @@ -8362,8 +9027,8 @@ func (p *ScheduledTask) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *ScheduledTask) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *ScheduledTask) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 6: ", err) } else { p.TimesPartitioned = v @@ -8371,28 +9036,28 @@ func (p *ScheduledTask) ReadField6(iprot thrift.TProtocol) error { return nil } -func (p *ScheduledTask) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *ScheduledTask) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*TaskEvent, 0, size) p.TaskEvents = tSlice for i := 0; i < size; i ++ { - _elem16 := &TaskEvent{} - if err := _elem16.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem16), err) + _elem30 := &TaskEvent{} + if err := _elem30.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem30), err) } - p.TaskEvents = append(p.TaskEvents, _elem16) + p.TaskEvents = append(p.TaskEvents, _elem30) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *ScheduledTask) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ScheduledTask) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 5: ", err) } else { p.AncestorId = v @@ -8400,94 +9065,113 @@ func (p *ScheduledTask) ReadField5(iprot thrift.TProtocol) error { return nil } -func (p *ScheduledTask) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ScheduledTask"); err != nil { +func (p *ScheduledTask) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ScheduledTask"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ScheduledTask) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("assignedTask", thrift.STRUCT, 1); err != nil { +func (p *ScheduledTask) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "assignedTask", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assignedTask: ", p), err) } - if err := p.AssignedTask.Write(oprot); err != nil { + if err := p.AssignedTask.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AssignedTask), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assignedTask: ", p), err) } return err } -func (p *ScheduledTask) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { +func (p *ScheduledTask) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } return err } -func (p *ScheduledTask) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("failureCount", thrift.I32, 3); err != nil { +func (p *ScheduledTask) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "failureCount", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failureCount: ", p), err) } - if err := oprot.WriteI32(int32(p.FailureCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.FailureCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.failureCount (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failureCount: ", p), err) } return err } -func (p *ScheduledTask) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskEvents", thrift.LIST, 4); err != nil { +func (p *ScheduledTask) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskEvents", thrift.LIST, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskEvents: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.TaskEvents)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.TaskEvents)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.TaskEvents { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:taskEvents: ", p), err) } return err } -func (p *ScheduledTask) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ancestorId", thrift.STRING, 5); err != nil { +func (p *ScheduledTask) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ancestorId", thrift.STRING, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ancestorId: ", p), err) } - if err := oprot.WriteString(string(p.AncestorId)); err != nil { + if err := oprot.WriteString(ctx, string(p.AncestorId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.ancestorId (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ancestorId: ", p), err) } return err } -func (p *ScheduledTask) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timesPartitioned", thrift.I32, 6); err != nil { +func (p *ScheduledTask) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timesPartitioned", thrift.I32, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:timesPartitioned: ", p), err) } - if err := oprot.WriteI32(int32(p.TimesPartitioned)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.TimesPartitioned)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timesPartitioned (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:timesPartitioned: ", p), err) } return err } +func (p *ScheduledTask) Equals(other *ScheduledTask) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.AssignedTask.Equals(other.AssignedTask) { return false } + if p.Status != other.Status { return false } + if p.FailureCount != other.FailureCount { return false } + if len(p.TaskEvents) != len(other.TaskEvents) { return false } + for i, _tgt := range p.TaskEvents { + _src31 := other.TaskEvents[i] + if !_tgt.Equals(_src31) { return false } + } + if p.AncestorId != other.AncestorId { return false } + if p.TimesPartitioned != other.TimesPartitioned { return false } + return true +} + func (p *ScheduledTask) String() string { if p == nil { return "" @@ -8509,14 +9193,14 @@ func NewScheduleStatusResult_() *ScheduleStatusResult_ { func (p *ScheduleStatusResult_) GetTasks() []*ScheduledTask { return p.Tasks } -func (p *ScheduleStatusResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ScheduleStatusResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -8524,81 +9208,95 @@ func (p *ScheduleStatusResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.LIST { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ScheduleStatusResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *ScheduleStatusResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*ScheduledTask, 0, size) p.Tasks = tSlice for i := 0; i < size; i ++ { - _elem17 := &ScheduledTask{} - if err := _elem17.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem17), err) + _elem32 := &ScheduledTask{} + if err := _elem32.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem32), err) } - p.Tasks = append(p.Tasks, _elem17) + p.Tasks = append(p.Tasks, _elem32) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *ScheduleStatusResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ScheduleStatusResult"); err != nil { +func (p *ScheduleStatusResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ScheduleStatusResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ScheduleStatusResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tasks", thrift.LIST, 1); err != nil { +func (p *ScheduleStatusResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tasks", thrift.LIST, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Tasks)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Tasks)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.Tasks { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tasks: ", p), err) } return err } +func (p *ScheduleStatusResult_) Equals(other *ScheduleStatusResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.Tasks) != len(other.Tasks) { return false } + for i, _tgt := range p.Tasks { + _src33 := other.Tasks[i] + if !_tgt.Equals(_src33) { return false } + } + return true +} + func (p *ScheduleStatusResult_) String() string { if p == nil { return "" @@ -8620,14 +9318,14 @@ func NewGetJobsResult_() *GetJobsResult_ { func (p *GetJobsResult_) GetConfigs() []*JobConfiguration { return p.Configs } -func (p *GetJobsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetJobsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -8635,88 +9333,105 @@ func (p *GetJobsResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetJobsResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetJobsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*JobConfiguration, 0, size) p.Configs = tSet for i := 0; i < size; i ++ { - _elem18 := &JobConfiguration{} - if err := _elem18.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem18), err) + _elem34 := &JobConfiguration{} + if err := _elem34.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem34), err) } - p.Configs = append(p.Configs, _elem18) + p.Configs = append(p.Configs, _elem34) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetJobsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobsResult"); err != nil { +func (p *GetJobsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobsResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetJobsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("configs", thrift.SET, 1); err != nil { +func (p *GetJobsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "configs", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:configs: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Configs)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Configs)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -8859,14 +9574,14 @@ func (p *TaskQuery) IsSetLimit() bool { return p.Limit != nil } -func (p *TaskQuery) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *TaskQuery) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -8874,121 +9589,121 @@ func (p *TaskQuery) Read(iprot thrift.TProtocol) error { switch fieldId { case 14: if fieldTypeId == thrift.STRING { - if err := p.ReadField14(iprot); err != nil { + if err := p.ReadField14(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 9: if fieldTypeId == thrift.STRING { - if err := p.ReadField9(iprot); err != nil { + if err := p.ReadField9(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.SET { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.SET { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.SET { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 10: if fieldTypeId == thrift.SET { - if err := p.ReadField10(iprot); err != nil { + if err := p.ReadField10(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 11: if fieldTypeId == thrift.SET { - if err := p.ReadField11(iprot); err != nil { + if err := p.ReadField11(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 12: if fieldTypeId == thrift.I32 { - if err := p.ReadField12(iprot); err != nil { + if err := p.ReadField12(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 13: if fieldTypeId == thrift.I32 { - if err := p.ReadField13(iprot); err != nil { + if err := p.ReadField13(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *TaskQuery) ReadField14(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskQuery) ReadField14(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 14: ", err) } else { p.Role = &v @@ -8996,8 +9711,8 @@ func (p *TaskQuery) ReadField14(iprot thrift.TProtocol) error { return nil } -func (p *TaskQuery) ReadField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskQuery) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 9: ", err) } else { p.Environment = &v @@ -9005,8 +9720,8 @@ func (p *TaskQuery) ReadField9(iprot thrift.TProtocol) error { return nil } -func (p *TaskQuery) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TaskQuery) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.JobName = &v @@ -9014,117 +9729,117 @@ func (p *TaskQuery) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *TaskQuery) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskQuery) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]string, 0, size) p.TaskIds = tSet for i := 0; i < size; i ++ { -var _elem19 string - if v, err := iprot.ReadString(); err != nil { +var _elem36 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem19 = v + _elem36 = v } - p.TaskIds = append(p.TaskIds, _elem19) + p.TaskIds = append(p.TaskIds, _elem36) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskQuery) ReadField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskQuery) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]ScheduleStatus, 0, size) p.Statuses = tSet for i := 0; i < size; i ++ { -var _elem20 ScheduleStatus - if v, err := iprot.ReadI32(); err != nil { +var _elem37 ScheduleStatus + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { temp := ScheduleStatus(v) - _elem20 = temp + _elem37 = temp } - p.Statuses = append(p.Statuses, _elem20) + p.Statuses = append(p.Statuses, _elem37) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskQuery) ReadField7(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskQuery) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]int32, 0, size) p.InstanceIds = tSet for i := 0; i < size; i ++ { -var _elem21 int32 - if v, err := iprot.ReadI32(); err != nil { +var _elem38 int32 + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem21 = v + _elem38 = v } - p.InstanceIds = append(p.InstanceIds, _elem21) + p.InstanceIds = append(p.InstanceIds, _elem38) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskQuery) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskQuery) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]string, 0, size) p.SlaveHosts = tSet for i := 0; i < size; i ++ { -var _elem22 string - if v, err := iprot.ReadString(); err != nil { +var _elem39 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem22 = v + _elem39 = v } - p.SlaveHosts = append(p.SlaveHosts, _elem22) + p.SlaveHosts = append(p.SlaveHosts, _elem39) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskQuery) ReadField11(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *TaskQuery) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*JobKey, 0, size) p.JobKeys = tSet for i := 0; i < size; i ++ { - _elem23 := &JobKey{} - if err := _elem23.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem23), err) + _elem40 := &JobKey{} + if err := _elem40.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem40), err) } - p.JobKeys = append(p.JobKeys, _elem23) + p.JobKeys = append(p.JobKeys, _elem40) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *TaskQuery) ReadField12(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *TaskQuery) ReadField12(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 12: ", err) } else { p.Offset = &v @@ -9132,8 +9847,8 @@ func (p *TaskQuery) ReadField12(iprot thrift.TProtocol) error { return nil } -func (p *TaskQuery) ReadField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *TaskQuery) ReadField13(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 13: ", err) } else { p.Limit = &v @@ -9141,224 +9856,303 @@ func (p *TaskQuery) ReadField13(iprot thrift.TProtocol) error { return nil } -func (p *TaskQuery) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskQuery"); err != nil { +func (p *TaskQuery) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskQuery"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - if err := p.writeField13(oprot); err != nil { return err } - if err := p.writeField14(oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField12(ctx, oprot); err != nil { return err } + if err := p.writeField13(ctx, oprot); err != nil { return err } + if err := p.writeField14(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *TaskQuery) writeField2(oprot thrift.TProtocol) (err error) { +func (p *TaskQuery) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetJobName() { - if err := oprot.WriteFieldBegin("jobName", thrift.STRING, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "jobName", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobName: ", p), err) } - if err := oprot.WriteString(string(*p.JobName)); err != nil { + if err := oprot.WriteString(ctx, string(*p.JobName)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.jobName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobName: ", p), err) } } return err } -func (p *TaskQuery) writeField4(oprot thrift.TProtocol) (err error) { +func (p *TaskQuery) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetTaskIds() { - if err := oprot.WriteFieldBegin("taskIds", thrift.SET, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "taskIds", thrift.SET, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskIds: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.TaskIds)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.TaskIds)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -9386,14 +10180,14 @@ func (p *HostStatus) GetHost() string { func (p *HostStatus) GetMode() MaintenanceMode { return p.Mode } -func (p *HostStatus) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *HostStatus) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -9401,41 +10195,41 @@ func (p *HostStatus) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *HostStatus) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *HostStatus) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Host = v @@ -9443,8 +10237,8 @@ func (p *HostStatus) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *HostStatus) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *HostStatus) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { temp := MaintenanceMode(v) @@ -9453,40 +10247,51 @@ func (p *HostStatus) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *HostStatus) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HostStatus"); err != nil { +func (p *HostStatus) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostStatus"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *HostStatus) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("host", thrift.STRING, 1); err != nil { +func (p *HostStatus) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } - if err := oprot.WriteString(string(p.Host)); err != nil { + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } return err } -func (p *HostStatus) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("mode", thrift.I32, 2); err != nil { +func (p *HostStatus) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "mode", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:mode: ", p), err) } - if err := oprot.WriteI32(int32(p.Mode)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Mode)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.mode (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:mode: ", p), err) } return err } +func (p *HostStatus) Equals(other *HostStatus) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Host != other.Host { return false } + if p.Mode != other.Mode { return false } + return true +} + func (p *HostStatus) String() string { if p == nil { return "" @@ -9520,14 +10325,14 @@ func (p *RoleSummary) GetJobCount() int32 { func (p *RoleSummary) GetCronJobCount() int32 { return p.CronJobCount } -func (p *RoleSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *RoleSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -9535,51 +10340,51 @@ func (p *RoleSummary) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *RoleSummary) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *RoleSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Role = v @@ -9587,8 +10392,8 @@ func (p *RoleSummary) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *RoleSummary) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *RoleSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.JobCount = v @@ -9596,8 +10401,8 @@ func (p *RoleSummary) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *RoleSummary) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *RoleSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.CronJobCount = v @@ -9605,51 +10410,63 @@ func (p *RoleSummary) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *RoleSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("RoleSummary"); err != nil { +func (p *RoleSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "RoleSummary"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *RoleSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { +func (p *RoleSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } - if err := oprot.WriteString(string(p.Role)); err != nil { + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } return err } -func (p *RoleSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobCount", thrift.I32, 2); err != nil { +func (p *RoleSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobCount", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobCount: ", p), err) } - if err := oprot.WriteI32(int32(p.JobCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.JobCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.jobCount (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobCount: ", p), err) } return err } -func (p *RoleSummary) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("cronJobCount", thrift.I32, 3); err != nil { +func (p *RoleSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "cronJobCount", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cronJobCount: ", p), err) } - if err := oprot.WriteI32(int32(p.CronJobCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.CronJobCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.cronJobCount (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cronJobCount: ", p), err) } return err } +func (p *RoleSummary) Equals(other *RoleSummary) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.JobCount != other.JobCount { return false } + if p.CronJobCount != other.CronJobCount { return false } + return true +} + func (p *RoleSummary) String() string { if p == nil { return "" @@ -9671,14 +10488,14 @@ func NewHosts() *Hosts { func (p *Hosts) GetHostNames() []string { return p.HostNames } -func (p *Hosts) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Hosts) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -9686,89 +10503,106 @@ func (p *Hosts) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Hosts) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *Hosts) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]string, 0, size) p.HostNames = tSet for i := 0; i < size; i ++ { -var _elem24 string - if v, err := iprot.ReadString(); err != nil { +var _elem46 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem24 = v + _elem46 = v } - p.HostNames = append(p.HostNames, _elem24) + p.HostNames = append(p.HostNames, _elem46) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *Hosts) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Hosts"); err != nil { +func (p *Hosts) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Hosts"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Hosts) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hostNames", thrift.SET, 1); err != nil { +func (p *Hosts) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hostNames", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hostNames: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.HostNames)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.HostNames)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -9796,14 +10630,14 @@ func (p *PendingReason) GetTaskId() string { func (p *PendingReason) GetReason() string { return p.Reason } -func (p *PendingReason) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *PendingReason) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -9811,41 +10645,41 @@ func (p *PendingReason) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *PendingReason) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *PendingReason) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.TaskId = v @@ -9853,8 +10687,8 @@ func (p *PendingReason) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *PendingReason) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *PendingReason) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Reason = v @@ -9862,40 +10696,51 @@ func (p *PendingReason) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *PendingReason) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PendingReason"); err != nil { +func (p *PendingReason) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PendingReason"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *PendingReason) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { +func (p *PendingReason) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } - if err := oprot.WriteString(string(p.TaskId)); err != nil { + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } return err } -func (p *PendingReason) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { +func (p *PendingReason) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reason", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } - if err := oprot.WriteString(string(p.Reason)); err != nil { + if err := oprot.WriteString(ctx, string(p.Reason)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } return err } +func (p *PendingReason) Equals(other *PendingReason) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.TaskId != other.TaskId { return false } + if p.Reason != other.Reason { return false } + return true +} + func (p *PendingReason) String() string { if p == nil { return "" @@ -9932,14 +10777,14 @@ func (p *JobUpdateKey) IsSetJob() bool { return p.Job != nil } -func (p *JobUpdateKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -9947,49 +10792,49 @@ func (p *JobUpdateKey) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateKey) ReadField1(iprot thrift.TProtocol) error { +func (p *JobUpdateKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *JobUpdateKey) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.ID = v @@ -9997,41 +10842,52 @@ func (p *JobUpdateKey) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateKey"); err != nil { +func (p *JobUpdateKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateKey"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { +func (p *JobUpdateKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } return err } -func (p *JobUpdateKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.STRING, 2); err != nil { +func (p *JobUpdateKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "id", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id: ", p), err) } - if err := oprot.WriteString(string(p.ID)); err != nil { + if err := oprot.WriteString(ctx, string(p.ID)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.id (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id: ", p), err) } return err } +func (p *JobUpdateKey) Equals(other *JobUpdateKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + if p.ID != other.ID { return false } + return true +} + func (p *JobUpdateKey) String() string { if p == nil { return "" @@ -10055,14 +10911,14 @@ func NewQueueJobUpdateStrategy() *QueueJobUpdateStrategy { func (p *QueueJobUpdateStrategy) GetGroupSize() int32 { return p.GroupSize } -func (p *QueueJobUpdateStrategy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *QueueJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -10070,31 +10926,31 @@ func (p *QueueJobUpdateStrategy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *QueueJobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *QueueJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.GroupSize = v @@ -10102,29 +10958,39 @@ func (p *QueueJobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *QueueJobUpdateStrategy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("QueueJobUpdateStrategy"); err != nil { +func (p *QueueJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "QueueJobUpdateStrategy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *QueueJobUpdateStrategy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("groupSize", thrift.I32, 1); err != nil { +func (p *QueueJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSize", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSize: ", p), err) } - if err := oprot.WriteI32(int32(p.GroupSize)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.GroupSize)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.groupSize (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSize: ", p), err) } return err } +func (p *QueueJobUpdateStrategy) Equals(other *QueueJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.GroupSize != other.GroupSize { return false } + return true +} + func (p *QueueJobUpdateStrategy) String() string { if p == nil { return "" @@ -10155,14 +11021,14 @@ func (p *BatchJobUpdateStrategy) GetGroupSize() int32 { func (p *BatchJobUpdateStrategy) GetAutopauseAfterBatch() bool { return p.AutopauseAfterBatch } -func (p *BatchJobUpdateStrategy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *BatchJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -10170,41 +11036,41 @@ func (p *BatchJobUpdateStrategy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.BOOL { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *BatchJobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *BatchJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.GroupSize = v @@ -10212,8 +11078,8 @@ func (p *BatchJobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *BatchJobUpdateStrategy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *BatchJobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.AutopauseAfterBatch = v @@ -10221,40 +11087,51 @@ func (p *BatchJobUpdateStrategy) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *BatchJobUpdateStrategy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("BatchJobUpdateStrategy"); err != nil { +func (p *BatchJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "BatchJobUpdateStrategy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *BatchJobUpdateStrategy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("groupSize", thrift.I32, 1); err != nil { +func (p *BatchJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSize", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSize: ", p), err) } - if err := oprot.WriteI32(int32(p.GroupSize)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.GroupSize)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.groupSize (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSize: ", p), err) } return err } -func (p *BatchJobUpdateStrategy) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("autopauseAfterBatch", thrift.BOOL, 2); err != nil { +func (p *BatchJobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "autopauseAfterBatch", thrift.BOOL, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:autopauseAfterBatch: ", p), err) } - if err := oprot.WriteBool(bool(p.AutopauseAfterBatch)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.AutopauseAfterBatch)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.autopauseAfterBatch (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:autopauseAfterBatch: ", p), err) } return err } +func (p *BatchJobUpdateStrategy) Equals(other *BatchJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.GroupSize != other.GroupSize { return false } + if p.AutopauseAfterBatch != other.AutopauseAfterBatch { return false } + return true +} + func (p *BatchJobUpdateStrategy) String() string { if p == nil { return "" @@ -10285,14 +11162,14 @@ func (p *VariableBatchJobUpdateStrategy) GetGroupSizes() []int32 { func (p *VariableBatchJobUpdateStrategy) GetAutopauseAfterBatch() bool { return p.AutopauseAfterBatch } -func (p *VariableBatchJobUpdateStrategy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *VariableBatchJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -10300,63 +11177,63 @@ func (p *VariableBatchJobUpdateStrategy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.LIST { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.BOOL { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *VariableBatchJobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *VariableBatchJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]int32, 0, size) p.GroupSizes = tSlice for i := 0; i < size; i ++ { -var _elem25 int32 - if v, err := iprot.ReadI32(); err != nil { +var _elem48 int32 + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem25 = v + _elem48 = v } - p.GroupSizes = append(p.GroupSizes, _elem25) + p.GroupSizes = append(p.GroupSizes, _elem48) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *VariableBatchJobUpdateStrategy) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *VariableBatchJobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.AutopauseAfterBatch = v @@ -10364,48 +11241,63 @@ func (p *VariableBatchJobUpdateStrategy) ReadField2(iprot thrift.TProtocol) err return nil } -func (p *VariableBatchJobUpdateStrategy) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("VariableBatchJobUpdateStrategy"); err != nil { +func (p *VariableBatchJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "VariableBatchJobUpdateStrategy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *VariableBatchJobUpdateStrategy) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("groupSizes", thrift.LIST, 1); err != nil { +func (p *VariableBatchJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSizes", thrift.LIST, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSizes: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.GroupSizes)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.I32, len(p.GroupSizes)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.GroupSizes { - if err := oprot.WriteI32(int32(v)); err != nil { + if err := oprot.WriteI32(ctx, int32(v)); err != nil { return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSizes: ", p), err) } return err } -func (p *VariableBatchJobUpdateStrategy) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("autopauseAfterBatch", thrift.BOOL, 2); err != nil { +func (p *VariableBatchJobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "autopauseAfterBatch", thrift.BOOL, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:autopauseAfterBatch: ", p), err) } - if err := oprot.WriteBool(bool(p.AutopauseAfterBatch)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.AutopauseAfterBatch)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.autopauseAfterBatch (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:autopauseAfterBatch: ", p), err) } return err } +func (p *VariableBatchJobUpdateStrategy) Equals(other *VariableBatchJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.GroupSizes) != len(other.GroupSizes) { return false } + for i, _tgt := range p.GroupSizes { + _src49 := other.GroupSizes[i] + if _tgt != _src49 { return false } + } + if p.AutopauseAfterBatch != other.AutopauseAfterBatch { return false } + return true +} + func (p *VariableBatchJobUpdateStrategy) String() string { if p == nil { return "" @@ -10475,14 +11367,14 @@ func (p *JobUpdateStrategy) IsSetVarBatchStrategy() bool { return p.VarBatchStrategy != nil } -func (p *JobUpdateStrategy) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -10490,130 +11382,142 @@ func (p *JobUpdateStrategy) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateStrategy) ReadField1(iprot thrift.TProtocol) error { +func (p *JobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.QueueStrategy = &QueueJobUpdateStrategy{} - if err := p.QueueStrategy.Read(iprot); err != nil { + if err := p.QueueStrategy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QueueStrategy), err) } return nil } -func (p *JobUpdateStrategy) ReadField2(iprot thrift.TProtocol) error { +func (p *JobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.BatchStrategy = &BatchJobUpdateStrategy{} - if err := p.BatchStrategy.Read(iprot); err != nil { + if err := p.BatchStrategy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.BatchStrategy), err) } return nil } -func (p *JobUpdateStrategy) ReadField3(iprot thrift.TProtocol) error { +func (p *JobUpdateStrategy) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.VarBatchStrategy = &VariableBatchJobUpdateStrategy{} - if err := p.VarBatchStrategy.Read(iprot); err != nil { + if err := p.VarBatchStrategy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.VarBatchStrategy), err) } return nil } -func (p *JobUpdateStrategy) Write(oprot thrift.TProtocol) error { +func (p *JobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsJobUpdateStrategy(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("JobUpdateStrategy"); err != nil { + if err := oprot.WriteStructBegin(ctx, "JobUpdateStrategy"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateStrategy) writeField1(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetQueueStrategy() { - if err := oprot.WriteFieldBegin("queueStrategy", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "queueStrategy", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:queueStrategy: ", p), err) } - if err := p.QueueStrategy.Write(oprot); err != nil { + if err := p.QueueStrategy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QueueStrategy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:queueStrategy: ", p), err) } } return err } -func (p *JobUpdateStrategy) writeField2(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetBatchStrategy() { - if err := oprot.WriteFieldBegin("batchStrategy", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "batchStrategy", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:batchStrategy: ", p), err) } - if err := p.BatchStrategy.Write(oprot); err != nil { + if err := p.BatchStrategy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.BatchStrategy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:batchStrategy: ", p), err) } } return err } -func (p *JobUpdateStrategy) writeField3(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateStrategy) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetVarBatchStrategy() { - if err := oprot.WriteFieldBegin("varBatchStrategy", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "varBatchStrategy", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:varBatchStrategy: ", p), err) } - if err := p.VarBatchStrategy.Write(oprot); err != nil { + if err := p.VarBatchStrategy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.VarBatchStrategy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:varBatchStrategy: ", p), err) } } return err } +func (p *JobUpdateStrategy) Equals(other *JobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.QueueStrategy.Equals(other.QueueStrategy) { return false } + if !p.BatchStrategy.Equals(other.BatchStrategy) { return false } + if !p.VarBatchStrategy.Equals(other.VarBatchStrategy) { return false } + return true +} + func (p *JobUpdateStrategy) String() string { if p == nil { return "" @@ -10720,14 +11624,14 @@ func (p *JobUpdateSettings) IsSetUpdateStrategy() bool { return p.UpdateStrategy != nil } -func (p *JobUpdateSettings) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateSettings) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -10735,121 +11639,121 @@ func (p *JobUpdateSettings) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.I32 { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.BOOL { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.SET { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 8: if fieldTypeId == thrift.BOOL { - if err := p.ReadField8(iprot); err != nil { + if err := p.ReadField8(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 9: if fieldTypeId == thrift.I32 { - if err := p.ReadField9(iprot); err != nil { + if err := p.ReadField9(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 10: if fieldTypeId == thrift.BOOL { - if err := p.ReadField10(iprot); err != nil { + if err := p.ReadField10(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 11: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField11(iprot); err != nil { + if err := p.ReadField11(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateSettings) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateSettings) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.UpdateGroupSize = v @@ -10857,8 +11761,8 @@ func (p *JobUpdateSettings) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateSettings) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.MaxPerInstanceFailures = v @@ -10866,8 +11770,8 @@ func (p *JobUpdateSettings) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateSettings) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.MaxFailedInstances = v @@ -10875,8 +11779,8 @@ func (p *JobUpdateSettings) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateSettings) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 5: ", err) } else { p.MinWaitInInstanceRunningMs = v @@ -10884,8 +11788,8 @@ func (p *JobUpdateSettings) ReadField5(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *JobUpdateSettings) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 6: ", err) } else { p.RollbackOnFailure = v @@ -10893,28 +11797,28 @@ func (p *JobUpdateSettings) ReadField6(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField7(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobUpdateSettings) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Range, 0, size) p.UpdateOnlyTheseInstances = tSet for i := 0; i < size; i ++ { - _elem26 := &Range{} - if err := _elem26.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem26), err) + _elem50 := &Range{} + if err := _elem50.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem50), err) } - p.UpdateOnlyTheseInstances = append(p.UpdateOnlyTheseInstances, _elem26) + p.UpdateOnlyTheseInstances = append(p.UpdateOnlyTheseInstances, _elem50) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobUpdateSettings) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *JobUpdateSettings) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 8: ", err) } else { p.WaitForBatchCompletion = v @@ -10922,8 +11826,8 @@ func (p *JobUpdateSettings) ReadField8(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateSettings) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 9: ", err) } else { p.BlockIfNoPulsesAfterMs = &v @@ -10931,8 +11835,8 @@ func (p *JobUpdateSettings) ReadField9(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField10(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { +func (p *JobUpdateSettings) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { return thrift.PrependError("error reading field 10: ", err) } else { p.SlaAware = &v @@ -10940,159 +11844,195 @@ func (p *JobUpdateSettings) ReadField10(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSettings) ReadField11(iprot thrift.TProtocol) error { +func (p *JobUpdateSettings) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { p.UpdateStrategy = &JobUpdateStrategy{} - if err := p.UpdateStrategy.Read(iprot); err != nil { + if err := p.UpdateStrategy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UpdateStrategy), err) } return nil } -func (p *JobUpdateSettings) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateSettings"); err != nil { +func (p *JobUpdateSettings) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateSettings"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateSettings) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateGroupSize", thrift.I32, 1); err != nil { +func (p *JobUpdateSettings) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateGroupSize", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateGroupSize: ", p), err) } - if err := oprot.WriteI32(int32(p.UpdateGroupSize)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.UpdateGroupSize)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.updateGroupSize (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateGroupSize: ", p), err) } return err } -func (p *JobUpdateSettings) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxPerInstanceFailures", thrift.I32, 2); err != nil { +func (p *JobUpdateSettings) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxPerInstanceFailures", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:maxPerInstanceFailures: ", p), err) } - if err := oprot.WriteI32(int32(p.MaxPerInstanceFailures)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.MaxPerInstanceFailures)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.maxPerInstanceFailures (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:maxPerInstanceFailures: ", p), err) } return err } -func (p *JobUpdateSettings) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxFailedInstances", thrift.I32, 3); err != nil { +func (p *JobUpdateSettings) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxFailedInstances", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:maxFailedInstances: ", p), err) } - if err := oprot.WriteI32(int32(p.MaxFailedInstances)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.MaxFailedInstances)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.maxFailedInstances (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:maxFailedInstances: ", p), err) } return err } -func (p *JobUpdateSettings) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("minWaitInInstanceRunningMs", thrift.I32, 5); err != nil { +func (p *JobUpdateSettings) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "minWaitInInstanceRunningMs", thrift.I32, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:minWaitInInstanceRunningMs: ", p), err) } - if err := oprot.WriteI32(int32(p.MinWaitInInstanceRunningMs)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.MinWaitInInstanceRunningMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.minWaitInInstanceRunningMs (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:minWaitInInstanceRunningMs: ", p), err) } return err } -func (p *JobUpdateSettings) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("rollbackOnFailure", thrift.BOOL, 6); err != nil { +func (p *JobUpdateSettings) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "rollbackOnFailure", thrift.BOOL, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:rollbackOnFailure: ", p), err) } - if err := oprot.WriteBool(bool(p.RollbackOnFailure)); err != nil { + if err := oprot.WriteBool(ctx, bool(p.RollbackOnFailure)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.rollbackOnFailure (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:rollbackOnFailure: ", p), err) } return err } -func (p *JobUpdateSettings) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateOnlyTheseInstances", thrift.SET, 7); err != nil { +func (p *JobUpdateSettings) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateOnlyTheseInstances", thrift.SET, 7); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:updateOnlyTheseInstances: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.UpdateOnlyTheseInstances)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.UpdateOnlyTheseInstances)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -11149,14 +12089,14 @@ func (p *JobUpdateEvent) IsSetMessage() bool { return p.Message != nil } -func (p *JobUpdateEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -11164,61 +12104,61 @@ func (p *JobUpdateEvent) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateEvent) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { temp := JobUpdateStatus(v) @@ -11227,8 +12167,8 @@ func (p *JobUpdateEvent) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateEvent) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *JobUpdateEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.TimestampMs = v @@ -11236,8 +12176,8 @@ func (p *JobUpdateEvent) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateEvent) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.User = &v @@ -11245,8 +12185,8 @@ func (p *JobUpdateEvent) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateEvent) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.Message = &v @@ -11254,66 +12194,89 @@ func (p *JobUpdateEvent) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateEvent"); err != nil { +func (p *JobUpdateEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateEvent"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { +func (p *JobUpdateEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } return err } -func (p *JobUpdateEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 2); err != nil { +func (p *JobUpdateEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) } return err } -func (p *JobUpdateEvent) writeField3(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetUser() { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } - if err := oprot.WriteString(string(*p.User)); err != nil { + if err := oprot.WriteString(ctx, string(*p.User)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } } return err } -func (p *JobUpdateEvent) writeField4(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:message: ", p), err) } - if err := oprot.WriteString(string(*p.Message)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.message (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:message: ", p), err) } } return err } +func (p *JobUpdateEvent) Equals(other *JobUpdateEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.User != other.User { + if p.User == nil || other.User == nil { + return false + } + if (*p.User) != (*other.User) { return false } + } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + func (p *JobUpdateEvent) String() string { if p == nil { return "" @@ -11362,14 +12325,14 @@ func (p *JobInstanceUpdateEvent) IsSetMessage() bool { return p.Message != nil } -func (p *JobInstanceUpdateEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobInstanceUpdateEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -11377,61 +12340,61 @@ func (p *JobInstanceUpdateEvent) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I32 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobInstanceUpdateEvent) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobInstanceUpdateEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.InstanceId = v @@ -11439,8 +12402,8 @@ func (p *JobInstanceUpdateEvent) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobInstanceUpdateEvent) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *JobInstanceUpdateEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.TimestampMs = v @@ -11448,8 +12411,8 @@ func (p *JobInstanceUpdateEvent) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobInstanceUpdateEvent) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobInstanceUpdateEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { temp := JobUpdateAction(v) @@ -11458,8 +12421,8 @@ func (p *JobInstanceUpdateEvent) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobInstanceUpdateEvent) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobInstanceUpdateEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.Message = &v @@ -11467,64 +12430,82 @@ func (p *JobInstanceUpdateEvent) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *JobInstanceUpdateEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobInstanceUpdateEvent"); err != nil { +func (p *JobInstanceUpdateEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobInstanceUpdateEvent"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobInstanceUpdateEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 1); err != nil { +func (p *JobInstanceUpdateEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:instanceId: ", p), err) } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.instanceId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:instanceId: ", p), err) } return err } -func (p *JobInstanceUpdateEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 2); err != nil { +func (p *JobInstanceUpdateEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) } return err } -func (p *JobInstanceUpdateEvent) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("action", thrift.I32, 3); err != nil { +func (p *JobInstanceUpdateEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "action", thrift.I32, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:action: ", p), err) } - if err := oprot.WriteI32(int32(p.Action)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Action)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.action (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:action: ", p), err) } return err } -func (p *JobInstanceUpdateEvent) writeField4(oprot thrift.TProtocol) (err error) { +func (p *JobInstanceUpdateEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:message: ", p), err) } - if err := oprot.WriteString(string(*p.Message)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.message (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:message: ", p), err) } } return err } +func (p *JobInstanceUpdateEvent) Equals(other *JobInstanceUpdateEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.InstanceId != other.InstanceId { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.Action != other.Action { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + func (p *JobInstanceUpdateEvent) String() string { if p == nil { return "" @@ -11561,14 +12542,14 @@ func (p *InstanceTaskConfig) IsSetTask() bool { return p.Task != nil } -func (p *InstanceTaskConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *InstanceTaskConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -11576,118 +12557,136 @@ func (p *InstanceTaskConfig) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *InstanceTaskConfig) ReadField1(iprot thrift.TProtocol) error { +func (p *InstanceTaskConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Task = &TaskConfig{} - if err := p.Task.Read(iprot); err != nil { + if err := p.Task.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) } return nil } -func (p *InstanceTaskConfig) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *InstanceTaskConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Range, 0, size) p.Instances = tSet for i := 0; i < size; i ++ { - _elem27 := &Range{} - if err := _elem27.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem27), err) + _elem52 := &Range{} + if err := _elem52.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem52), err) } - p.Instances = append(p.Instances, _elem27) + p.Instances = append(p.Instances, _elem52) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *InstanceTaskConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("InstanceTaskConfig"); err != nil { +func (p *InstanceTaskConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "InstanceTaskConfig"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *InstanceTaskConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("task", thrift.STRUCT, 1); err != nil { +func (p *InstanceTaskConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "task", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:task: ", p), err) } - if err := p.Task.Write(oprot); err != nil { + if err := p.Task.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:task: ", p), err) } return err } -func (p *InstanceTaskConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instances", thrift.SET, 2); err != nil { +func (p *InstanceTaskConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instances", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instances: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Instances)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Instances)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -11723,14 +12722,14 @@ func (p *JobUpdateState) GetCreatedTimestampMs() int64 { func (p *JobUpdateState) GetLastModifiedTimestampMs() int64 { return p.LastModifiedTimestampMs } -func (p *JobUpdateState) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateState) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -11738,51 +12737,51 @@ func (p *JobUpdateState) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I64 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateState) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateState) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { temp := JobUpdateStatus(v) @@ -11791,8 +12790,8 @@ func (p *JobUpdateState) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateState) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *JobUpdateState) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.CreatedTimestampMs = v @@ -11800,8 +12799,8 @@ func (p *JobUpdateState) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateState) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *JobUpdateState) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.LastModifiedTimestampMs = v @@ -11809,51 +12808,63 @@ func (p *JobUpdateState) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateState) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateState"); err != nil { +func (p *JobUpdateState) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateState"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateState) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { +func (p *JobUpdateState) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } return err } -func (p *JobUpdateState) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("createdTimestampMs", thrift.I64, 2); err != nil { +func (p *JobUpdateState) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "createdTimestampMs", thrift.I64, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:createdTimestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.CreatedTimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.CreatedTimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.createdTimestampMs (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:createdTimestampMs: ", p), err) } return err } -func (p *JobUpdateState) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("lastModifiedTimestampMs", thrift.I64, 3); err != nil { +func (p *JobUpdateState) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "lastModifiedTimestampMs", thrift.I64, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:lastModifiedTimestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.LastModifiedTimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.LastModifiedTimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.lastModifiedTimestampMs (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:lastModifiedTimestampMs: ", p), err) } return err } +func (p *JobUpdateState) Equals(other *JobUpdateState) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + if p.CreatedTimestampMs != other.CreatedTimestampMs { return false } + if p.LastModifiedTimestampMs != other.LastModifiedTimestampMs { return false } + return true +} + func (p *JobUpdateState) String() string { if p == nil { return "" @@ -11915,14 +12926,14 @@ func (p *JobUpdateSummary) IsSetMetadata() bool { return p.Metadata != nil } -func (p *JobUpdateSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -11930,69 +12941,69 @@ func (p *JobUpdateSummary) Read(iprot thrift.TProtocol) error { switch fieldId { case 5: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.SET { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateSummary) ReadField5(iprot thrift.TProtocol) error { +func (p *JobUpdateSummary) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *JobUpdateSummary) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.User = v @@ -12000,110 +13011,130 @@ func (p *JobUpdateSummary) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateSummary) ReadField4(iprot thrift.TProtocol) error { +func (p *JobUpdateSummary) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.State = &JobUpdateState{} - if err := p.State.Read(iprot); err != nil { + if err := p.State.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.State), err) } return nil } -func (p *JobUpdateSummary) ReadField6(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobUpdateSummary) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Metadata, 0, size) p.Metadata = tSet for i := 0; i < size; i ++ { - _elem28 := &Metadata{} - if err := _elem28.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem28), err) + _elem54 := &Metadata{} + if err := _elem54.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem54), err) } - p.Metadata = append(p.Metadata, _elem28) + p.Metadata = append(p.Metadata, _elem54) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobUpdateSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateSummary"); err != nil { +func (p *JobUpdateSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateSummary"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateSummary) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { +func (p *JobUpdateSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } - if err := oprot.WriteString(string(p.User)); err != nil { + if err := oprot.WriteString(ctx, string(p.User)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } return err } -func (p *JobUpdateSummary) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("state", thrift.STRUCT, 4); err != nil { +func (p *JobUpdateSummary) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "state", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:state: ", p), err) } - if err := p.State.Write(oprot); err != nil { + if err := p.State.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.State), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:state: ", p), err) } return err } -func (p *JobUpdateSummary) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 5); err != nil { +func (p *JobUpdateSummary) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:key: ", p), err) } - if err := p.Key.Write(oprot); err != nil { + if err := p.Key.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:key: ", p), err) } return err } -func (p *JobUpdateSummary) writeField6(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateSummary) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMetadata() { - if err := oprot.WriteFieldBegin("metadata", thrift.SET, 6); err != nil { + if err := oprot.WriteFieldBegin(ctx, "metadata", thrift.SET, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:metadata: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Metadata)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Metadata)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -12153,14 +13184,14 @@ func (p *JobUpdateInstructions) IsSetSettings() bool { return p.Settings != nil } -func (p *JobUpdateInstructions) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateInstructions) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -12168,148 +13199,167 @@ func (p *JobUpdateInstructions) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateInstructions) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobUpdateInstructions) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*InstanceTaskConfig, 0, size) p.InitialState = tSet for i := 0; i < size; i ++ { - _elem29 := &InstanceTaskConfig{} - if err := _elem29.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem29), err) + _elem56 := &InstanceTaskConfig{} + if err := _elem56.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem56), err) } - p.InitialState = append(p.InitialState, _elem29) + p.InitialState = append(p.InitialState, _elem56) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobUpdateInstructions) ReadField2(iprot thrift.TProtocol) error { +func (p *JobUpdateInstructions) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.DesiredState = &InstanceTaskConfig{} - if err := p.DesiredState.Read(iprot); err != nil { + if err := p.DesiredState.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DesiredState), err) } return nil } -func (p *JobUpdateInstructions) ReadField3(iprot thrift.TProtocol) error { +func (p *JobUpdateInstructions) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.Settings = &JobUpdateSettings{} - if err := p.Settings.Read(iprot); err != nil { + if err := p.Settings.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) } return nil } -func (p *JobUpdateInstructions) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateInstructions"); err != nil { +func (p *JobUpdateInstructions) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateInstructions"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateInstructions) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("initialState", thrift.SET, 1); err != nil { +func (p *JobUpdateInstructions) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "initialState", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:initialState: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.InitialState)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.InitialState)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -12353,14 +13403,14 @@ func (p *JobUpdate) IsSetInstructions() bool { return p.Instructions != nil } -func (p *JobUpdate) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdate) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -12368,91 +13418,102 @@ func (p *JobUpdate) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdate) ReadField1(iprot thrift.TProtocol) error { +func (p *JobUpdate) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Summary = &JobUpdateSummary{} - if err := p.Summary.Read(iprot); err != nil { + if err := p.Summary.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) } return nil } -func (p *JobUpdate) ReadField2(iprot thrift.TProtocol) error { +func (p *JobUpdate) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Instructions = &JobUpdateInstructions{} - if err := p.Instructions.Read(iprot); err != nil { + if err := p.Instructions.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Instructions), err) } return nil } -func (p *JobUpdate) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdate"); err != nil { +func (p *JobUpdate) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdate"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdate) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summary", thrift.STRUCT, 1); err != nil { +func (p *JobUpdate) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summary", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) } - if err := p.Summary.Write(oprot); err != nil { + if err := p.Summary.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) } return err } -func (p *JobUpdate) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instructions", thrift.STRUCT, 2); err != nil { +func (p *JobUpdate) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instructions", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instructions: ", p), err) } - if err := p.Instructions.Write(oprot); err != nil { + if err := p.Instructions.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Instructions), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instructions: ", p), err) } return err } +func (p *JobUpdate) Equals(other *JobUpdate) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Summary.Equals(other.Summary) { return false } + if !p.Instructions.Equals(other.Instructions) { return false } + return true +} + func (p *JobUpdate) String() string { if p == nil { return "" @@ -12493,14 +13554,14 @@ func (p *JobUpdateDetails) IsSetUpdate() bool { return p.Update != nil } -func (p *JobUpdateDetails) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateDetails) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -12508,161 +13569,181 @@ func (p *JobUpdateDetails) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.LIST { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.LIST { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateDetails) ReadField1(iprot thrift.TProtocol) error { +func (p *JobUpdateDetails) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Update = &JobUpdate{} - if err := p.Update.Read(iprot); err != nil { + if err := p.Update.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Update), err) } return nil } -func (p *JobUpdateDetails) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *JobUpdateDetails) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*JobUpdateEvent, 0, size) p.UpdateEvents = tSlice for i := 0; i < size; i ++ { - _elem30 := &JobUpdateEvent{} - if err := _elem30.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem30), err) + _elem58 := &JobUpdateEvent{} + if err := _elem58.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem58), err) } - p.UpdateEvents = append(p.UpdateEvents, _elem30) + p.UpdateEvents = append(p.UpdateEvents, _elem58) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *JobUpdateDetails) ReadField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *JobUpdateDetails) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*JobInstanceUpdateEvent, 0, size) p.InstanceEvents = tSlice for i := 0; i < size; i ++ { - _elem31 := &JobInstanceUpdateEvent{} - if err := _elem31.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem31), err) + _elem59 := &JobInstanceUpdateEvent{} + if err := _elem59.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem59), err) } - p.InstanceEvents = append(p.InstanceEvents, _elem31) + p.InstanceEvents = append(p.InstanceEvents, _elem59) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *JobUpdateDetails) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateDetails"); err != nil { +func (p *JobUpdateDetails) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateDetails"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateDetails) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("update", thrift.STRUCT, 1); err != nil { +func (p *JobUpdateDetails) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "update", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:update: ", p), err) } - if err := p.Update.Write(oprot); err != nil { + if err := p.Update.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Update), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:update: ", p), err) } return err } -func (p *JobUpdateDetails) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateEvents", thrift.LIST, 2); err != nil { +func (p *JobUpdateDetails) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateEvents", thrift.LIST, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateEvents: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.UpdateEvents)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.UpdateEvents)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.UpdateEvents { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateEvents: ", p), err) } return err } -func (p *JobUpdateDetails) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceEvents", thrift.LIST, 3); err != nil { +func (p *JobUpdateDetails) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceEvents", thrift.LIST, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instanceEvents: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.InstanceEvents)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.InstanceEvents)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.InstanceEvents { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:instanceEvents: ", p), err) } return err } +func (p *JobUpdateDetails) Equals(other *JobUpdateDetails) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Update.Equals(other.Update) { return false } + if len(p.UpdateEvents) != len(other.UpdateEvents) { return false } + for i, _tgt := range p.UpdateEvents { + _src60 := other.UpdateEvents[i] + if !_tgt.Equals(_src60) { return false } + } + if len(p.InstanceEvents) != len(other.InstanceEvents) { return false } + for i, _tgt := range p.InstanceEvents { + _src61 := other.InstanceEvents[i] + if !_tgt.Equals(_src61) { return false } + } + return true +} + func (p *JobUpdateDetails) String() string { if p == nil { return "" @@ -12723,14 +13804,14 @@ func (p *JobUpdateRequest) IsSetMetadata() bool { return p.Metadata != nil } -func (p *JobUpdateRequest) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateRequest) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -12738,69 +13819,69 @@ func (p *JobUpdateRequest) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.SET { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateRequest) ReadField1(iprot thrift.TProtocol) error { +func (p *JobUpdateRequest) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { + if err := p.TaskConfig.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) } return nil } -func (p *JobUpdateRequest) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateRequest) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.InstanceCount = v @@ -12808,110 +13889,130 @@ func (p *JobUpdateRequest) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateRequest) ReadField3(iprot thrift.TProtocol) error { +func (p *JobUpdateRequest) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.Settings = &JobUpdateSettings{} - if err := p.Settings.Read(iprot); err != nil { + if err := p.Settings.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) } return nil } -func (p *JobUpdateRequest) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobUpdateRequest) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*Metadata, 0, size) p.Metadata = tSet for i := 0; i < size; i ++ { - _elem32 := &Metadata{} - if err := _elem32.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem32), err) + _elem62 := &Metadata{} + if err := _elem62.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem62), err) } - p.Metadata = append(p.Metadata, _elem32) + p.Metadata = append(p.Metadata, _elem62) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobUpdateRequest) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateRequest"); err != nil { +func (p *JobUpdateRequest) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateRequest"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 1); err != nil { +func (p *JobUpdateRequest) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskConfig: ", p), err) } - if err := p.TaskConfig.Write(oprot); err != nil { + if err := p.TaskConfig.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskConfig: ", p), err) } return err } -func (p *JobUpdateRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceCount", thrift.I32, 2); err != nil { +func (p *JobUpdateRequest) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceCount", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceCount: ", p), err) } - if err := oprot.WriteI32(int32(p.InstanceCount)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.InstanceCount)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.instanceCount (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceCount: ", p), err) } return err } -func (p *JobUpdateRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.STRUCT, 3); err != nil { +func (p *JobUpdateRequest) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:settings: ", p), err) } - if err := p.Settings.Write(oprot); err != nil { + if err := p.Settings.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:settings: ", p), err) } return err } -func (p *JobUpdateRequest) writeField4(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateRequest) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMetadata() { - if err := oprot.WriteFieldBegin("metadata", thrift.SET, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "metadata", thrift.SET, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:metadata: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Metadata)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Metadata)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13006,14 +14107,14 @@ func (p *JobUpdateQuery) IsSetUpdateStatuses() bool { return p.UpdateStatuses != nil } -func (p *JobUpdateQuery) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobUpdateQuery) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13021,91 +14122,91 @@ func (p *JobUpdateQuery) Read(iprot thrift.TProtocol) error { switch fieldId { case 2: if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 8: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField8(iprot); err != nil { + if err := p.ReadField8(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRING { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.SET { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.I32 { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.I32 { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobUpdateQuery) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateQuery) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { p.Role = &v @@ -13113,24 +14214,24 @@ func (p *JobUpdateQuery) ReadField2(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateQuery) ReadField8(iprot thrift.TProtocol) error { +func (p *JobUpdateQuery) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *JobUpdateQuery) ReadField3(iprot thrift.TProtocol) error { +func (p *JobUpdateQuery) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.JobKey = &JobKey{} - if err := p.JobKey.Read(iprot); err != nil { + if err := p.JobKey.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) } return nil } -func (p *JobUpdateQuery) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *JobUpdateQuery) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.User = &v @@ -13138,31 +14239,31 @@ func (p *JobUpdateQuery) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateQuery) ReadField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobUpdateQuery) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]JobUpdateStatus, 0, size) p.UpdateStatuses = tSet for i := 0; i < size; i ++ { -var _elem33 JobUpdateStatus - if v, err := iprot.ReadI32(); err != nil { +var _elem64 JobUpdateStatus + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { temp := JobUpdateStatus(v) - _elem33 = temp + _elem64 = temp } - p.UpdateStatuses = append(p.UpdateStatuses, _elem33) + p.UpdateStatuses = append(p.UpdateStatuses, _elem64) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobUpdateQuery) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateQuery) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 6: ", err) } else { p.Offset = v @@ -13170,8 +14271,8 @@ func (p *JobUpdateQuery) ReadField6(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateQuery) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *JobUpdateQuery) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 7: ", err) } else { p.Limit = v @@ -13179,122 +14280,155 @@ func (p *JobUpdateQuery) ReadField7(iprot thrift.TProtocol) error { return nil } -func (p *JobUpdateQuery) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateQuery"); err != nil { +func (p *JobUpdateQuery) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateQuery"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobUpdateQuery) writeField2(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateQuery) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetRole() { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:role: ", p), err) } - if err := oprot.WriteString(string(*p.Role)); err != nil { + if err := oprot.WriteString(ctx, string(*p.Role)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.role (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:role: ", p), err) } } return err } -func (p *JobUpdateQuery) writeField3(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateQuery) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetJobKey() { - if err := oprot.WriteFieldBegin("jobKey", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "jobKey", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:jobKey: ", p), err) } - if err := p.JobKey.Write(oprot); err != nil { + if err := p.JobKey.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:jobKey: ", p), err) } } return err } -func (p *JobUpdateQuery) writeField4(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateQuery) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetUser() { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:user: ", p), err) } - if err := oprot.WriteString(string(*p.User)); err != nil { + if err := oprot.WriteString(ctx, string(*p.User)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.user (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:user: ", p), err) } } return err } -func (p *JobUpdateQuery) writeField5(oprot thrift.TProtocol) (err error) { +func (p *JobUpdateQuery) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetUpdateStatuses() { - if err := oprot.WriteFieldBegin("updateStatuses", thrift.SET, 5); err != nil { + if err := oprot.WriteFieldBegin(ctx, "updateStatuses", thrift.SET, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:updateStatuses: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.UpdateStatuses)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.UpdateStatuses)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13341,14 +14475,14 @@ func (p *HostMaintenanceRequest) IsSetDefaultSlaPolicy() bool { return p.DefaultSlaPolicy != nil } -func (p *HostMaintenanceRequest) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *HostMaintenanceRequest) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13356,61 +14490,61 @@ func (p *HostMaintenanceRequest) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.I64 { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *HostMaintenanceRequest) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *HostMaintenanceRequest) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Host = v @@ -13418,16 +14552,16 @@ func (p *HostMaintenanceRequest) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *HostMaintenanceRequest) ReadField2(iprot thrift.TProtocol) error { +func (p *HostMaintenanceRequest) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.DefaultSlaPolicy = &SlaPolicy{} - if err := p.DefaultSlaPolicy.Read(iprot); err != nil { + if err := p.DefaultSlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DefaultSlaPolicy), err) } return nil } -func (p *HostMaintenanceRequest) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *HostMaintenanceRequest) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.TimeoutSecs = v @@ -13435,8 +14569,8 @@ func (p *HostMaintenanceRequest) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *HostMaintenanceRequest) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *HostMaintenanceRequest) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 4: ", err) } else { p.CreatedTimestampMs = v @@ -13444,63 +14578,76 @@ func (p *HostMaintenanceRequest) ReadField4(iprot thrift.TProtocol) error { return nil } -func (p *HostMaintenanceRequest) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HostMaintenanceRequest"); err != nil { +func (p *HostMaintenanceRequest) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostMaintenanceRequest"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *HostMaintenanceRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("host", thrift.STRING, 1); err != nil { +func (p *HostMaintenanceRequest) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } - if err := oprot.WriteString(string(p.Host)); err != nil { + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } return err } -func (p *HostMaintenanceRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("defaultSlaPolicy", thrift.STRUCT, 2); err != nil { +func (p *HostMaintenanceRequest) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultSlaPolicy", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultSlaPolicy: ", p), err) } - if err := p.DefaultSlaPolicy.Write(oprot); err != nil { + if err := p.DefaultSlaPolicy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DefaultSlaPolicy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultSlaPolicy: ", p), err) } return err } -func (p *HostMaintenanceRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timeoutSecs", thrift.I64, 3); err != nil { +func (p *HostMaintenanceRequest) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timeoutSecs", thrift.I64, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timeoutSecs: ", p), err) } - if err := oprot.WriteI64(int64(p.TimeoutSecs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.TimeoutSecs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timeoutSecs (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timeoutSecs: ", p), err) } return err } -func (p *HostMaintenanceRequest) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("createdTimestampMs", thrift.I64, 4); err != nil { +func (p *HostMaintenanceRequest) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "createdTimestampMs", thrift.I64, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:createdTimestampMs: ", p), err) } - if err := oprot.WriteI64(int64(p.CreatedTimestampMs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.CreatedTimestampMs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.createdTimestampMs (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:createdTimestampMs: ", p), err) } return err } +func (p *HostMaintenanceRequest) Equals(other *HostMaintenanceRequest) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Host != other.Host { return false } + if !p.DefaultSlaPolicy.Equals(other.DefaultSlaPolicy) { return false } + if p.TimeoutSecs != other.TimeoutSecs { return false } + if p.CreatedTimestampMs != other.CreatedTimestampMs { return false } + return true +} + func (p *HostMaintenanceRequest) String() string { if p == nil { return "" @@ -13522,14 +14669,14 @@ func NewListBackupsResult_() *ListBackupsResult_ { func (p *ListBackupsResult_) GetBackups() []string { return p.Backups } -func (p *ListBackupsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ListBackupsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13537,89 +14684,106 @@ func (p *ListBackupsResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ListBackupsResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *ListBackupsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]string, 0, size) p.Backups = tSet for i := 0; i < size; i ++ { -var _elem34 string - if v, err := iprot.ReadString(); err != nil { +var _elem66 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem34 = v + _elem66 = v } - p.Backups = append(p.Backups, _elem34) + p.Backups = append(p.Backups, _elem66) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *ListBackupsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ListBackupsResult"); err != nil { +func (p *ListBackupsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ListBackupsResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ListBackupsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("backups", thrift.SET, 1); err != nil { +func (p *ListBackupsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "backups", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backups: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Backups)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Backups)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13641,14 +14805,14 @@ func NewStartMaintenanceResult_() *StartMaintenanceResult_ { func (p *StartMaintenanceResult_) GetStatuses() []*HostStatus { return p.Statuses } -func (p *StartMaintenanceResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *StartMaintenanceResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13656,88 +14820,105 @@ func (p *StartMaintenanceResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *StartMaintenanceResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *StartMaintenanceResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*HostStatus, 0, size) p.Statuses = tSet for i := 0; i < size; i ++ { - _elem35 := &HostStatus{} - if err := _elem35.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem35), err) + _elem68 := &HostStatus{} + if err := _elem68.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem68), err) } - p.Statuses = append(p.Statuses, _elem35) + p.Statuses = append(p.Statuses, _elem68) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *StartMaintenanceResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("StartMaintenanceResult"); err != nil { +func (p *StartMaintenanceResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "StartMaintenanceResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *StartMaintenanceResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { +func (p *StartMaintenanceResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13759,14 +14940,14 @@ func NewDrainHostsResult_() *DrainHostsResult_ { func (p *DrainHostsResult_) GetStatuses() []*HostStatus { return p.Statuses } -func (p *DrainHostsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *DrainHostsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13774,88 +14955,105 @@ func (p *DrainHostsResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *DrainHostsResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *DrainHostsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*HostStatus, 0, size) p.Statuses = tSet for i := 0; i < size; i ++ { - _elem36 := &HostStatus{} - if err := _elem36.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem36), err) + _elem70 := &HostStatus{} + if err := _elem70.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem70), err) } - p.Statuses = append(p.Statuses, _elem36) + p.Statuses = append(p.Statuses, _elem70) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *DrainHostsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DrainHostsResult"); err != nil { +func (p *DrainHostsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DrainHostsResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *DrainHostsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { +func (p *DrainHostsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13877,14 +15075,14 @@ func NewQueryRecoveryResult_() *QueryRecoveryResult_ { func (p *QueryRecoveryResult_) GetTasks() []*ScheduledTask { return p.Tasks } -func (p *QueryRecoveryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *QueryRecoveryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -13892,88 +15090,105 @@ func (p *QueryRecoveryResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *QueryRecoveryResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *QueryRecoveryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ScheduledTask, 0, size) p.Tasks = tSet for i := 0; i < size; i ++ { - _elem37 := &ScheduledTask{} - if err := _elem37.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem37), err) + _elem72 := &ScheduledTask{} + if err := _elem72.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem72), err) } - p.Tasks = append(p.Tasks, _elem37) + p.Tasks = append(p.Tasks, _elem72) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *QueryRecoveryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("QueryRecoveryResult"); err != nil { +func (p *QueryRecoveryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "QueryRecoveryResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *QueryRecoveryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tasks", thrift.SET, 1); err != nil { +func (p *QueryRecoveryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tasks", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Tasks)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Tasks)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -13995,14 +15210,14 @@ func NewMaintenanceStatusResult_() *MaintenanceStatusResult_ { func (p *MaintenanceStatusResult_) GetStatuses() []*HostStatus { return p.Statuses } -func (p *MaintenanceStatusResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *MaintenanceStatusResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14010,88 +15225,105 @@ func (p *MaintenanceStatusResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *MaintenanceStatusResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *MaintenanceStatusResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*HostStatus, 0, size) p.Statuses = tSet for i := 0; i < size; i ++ { - _elem38 := &HostStatus{} - if err := _elem38.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem38), err) + _elem74 := &HostStatus{} + if err := _elem74.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem74), err) } - p.Statuses = append(p.Statuses, _elem38) + p.Statuses = append(p.Statuses, _elem74) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *MaintenanceStatusResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MaintenanceStatusResult"); err != nil { +func (p *MaintenanceStatusResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MaintenanceStatusResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *MaintenanceStatusResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { +func (p *MaintenanceStatusResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -14113,14 +15345,14 @@ func NewEndMaintenanceResult_() *EndMaintenanceResult_ { func (p *EndMaintenanceResult_) GetStatuses() []*HostStatus { return p.Statuses } -func (p *EndMaintenanceResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *EndMaintenanceResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14128,88 +15360,105 @@ func (p *EndMaintenanceResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *EndMaintenanceResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *EndMaintenanceResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*HostStatus, 0, size) p.Statuses = tSet for i := 0; i < size; i ++ { - _elem39 := &HostStatus{} - if err := _elem39.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem39), err) + _elem76 := &HostStatus{} + if err := _elem76.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem76), err) } - p.Statuses = append(p.Statuses, _elem39) + p.Statuses = append(p.Statuses, _elem76) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *EndMaintenanceResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("EndMaintenanceResult"); err != nil { +func (p *EndMaintenanceResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "EndMaintenanceResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *EndMaintenanceResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { +func (p *EndMaintenanceResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -14231,14 +15480,14 @@ func NewRoleSummaryResult_() *RoleSummaryResult_ { func (p *RoleSummaryResult_) GetSummaries() []*RoleSummary { return p.Summaries } -func (p *RoleSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *RoleSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14246,88 +15495,105 @@ func (p *RoleSummaryResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *RoleSummaryResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *RoleSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*RoleSummary, 0, size) p.Summaries = tSet for i := 0; i < size; i ++ { - _elem40 := &RoleSummary{} - if err := _elem40.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem40), err) + _elem78 := &RoleSummary{} + if err := _elem78.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem78), err) } - p.Summaries = append(p.Summaries, _elem40) + p.Summaries = append(p.Summaries, _elem78) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *RoleSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("RoleSummaryResult"); err != nil { +func (p *RoleSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "RoleSummaryResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *RoleSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summaries", thrift.SET, 1); err != nil { +func (p *RoleSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summaries", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Summaries)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Summaries)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -14349,14 +15615,14 @@ func NewJobSummaryResult_() *JobSummaryResult_ { func (p *JobSummaryResult_) GetSummaries() []*JobSummary { return p.Summaries } -func (p *JobSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *JobSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14364,88 +15630,105 @@ func (p *JobSummaryResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *JobSummaryResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *JobSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*JobSummary, 0, size) p.Summaries = tSet for i := 0; i < size; i ++ { - _elem41 := &JobSummary{} - if err := _elem41.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem41), err) + _elem80 := &JobSummary{} + if err := _elem80.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem80), err) } - p.Summaries = append(p.Summaries, _elem41) + p.Summaries = append(p.Summaries, _elem80) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *JobSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobSummaryResult"); err != nil { +func (p *JobSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobSummaryResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *JobSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summaries", thrift.SET, 1); err != nil { +func (p *JobSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summaries", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Summaries)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Summaries)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -14474,14 +15757,14 @@ func (p *ConfigSummaryResult_) IsSetSummary() bool { return p.Summary != nil } -func (p *ConfigSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ConfigSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14489,61 +15772,71 @@ func (p *ConfigSummaryResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ConfigSummaryResult_) ReadField1(iprot thrift.TProtocol) error { +func (p *ConfigSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Summary = &ConfigSummary{} - if err := p.Summary.Read(iprot); err != nil { + if err := p.Summary.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) } return nil } -func (p *ConfigSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigSummaryResult"); err != nil { +func (p *ConfigSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigSummaryResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ConfigSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summary", thrift.STRUCT, 1); err != nil { +func (p *ConfigSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summary", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) } - if err := p.Summary.Write(oprot); err != nil { + if err := p.Summary.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) } return err } +func (p *ConfigSummaryResult_) Equals(other *ConfigSummaryResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Summary.Equals(other.Summary) { return false } + return true +} + func (p *ConfigSummaryResult_) String() string { if p == nil { return "" @@ -14565,14 +15858,14 @@ func NewGetPendingReasonResult_() *GetPendingReasonResult_ { func (p *GetPendingReasonResult_) GetReasons() []*PendingReason { return p.Reasons } -func (p *GetPendingReasonResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetPendingReasonResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14580,88 +15873,105 @@ func (p *GetPendingReasonResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetPendingReasonResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetPendingReasonResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*PendingReason, 0, size) p.Reasons = tSet for i := 0; i < size; i ++ { - _elem42 := &PendingReason{} - if err := _elem42.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem42), err) + _elem82 := &PendingReason{} + if err := _elem82.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem82), err) } - p.Reasons = append(p.Reasons, _elem42) + p.Reasons = append(p.Reasons, _elem82) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetPendingReasonResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetPendingReasonResult"); err != nil { +func (p *GetPendingReasonResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetPendingReasonResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetPendingReasonResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("reasons", thrift.SET, 1); err != nil { +func (p *GetPendingReasonResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reasons", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reasons: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Reasons)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Reasons)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -14705,14 +16015,14 @@ func (p *StartJobUpdateResult_) IsSetUpdateSummary() bool { return p.UpdateSummary != nil } -func (p *StartJobUpdateResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *StartJobUpdateResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14720,93 +16030,104 @@ func (p *StartJobUpdateResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *StartJobUpdateResult_) ReadField1(iprot thrift.TProtocol) error { +func (p *StartJobUpdateResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { + if err := p.Key.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) } return nil } -func (p *StartJobUpdateResult_) ReadField2(iprot thrift.TProtocol) error { +func (p *StartJobUpdateResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.UpdateSummary = &JobUpdateSummary{} - if err := p.UpdateSummary.Read(iprot); err != nil { + if err := p.UpdateSummary.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UpdateSummary), err) } return nil } -func (p *StartJobUpdateResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("StartJobUpdateResult"); err != nil { +func (p *StartJobUpdateResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "StartJobUpdateResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *StartJobUpdateResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { +func (p *StartJobUpdateResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } - if err := p.Key.Write(oprot); err != nil { + if err := p.Key.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } return err } -func (p *StartJobUpdateResult_) writeField2(oprot thrift.TProtocol) (err error) { +func (p *StartJobUpdateResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetUpdateSummary() { - if err := oprot.WriteFieldBegin("updateSummary", thrift.STRUCT, 2); err != nil { + if err := oprot.WriteFieldBegin(ctx, "updateSummary", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateSummary: ", p), err) } - if err := p.UpdateSummary.Write(oprot); err != nil { + if err := p.UpdateSummary.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UpdateSummary), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateSummary: ", p), err) } } return err } +func (p *StartJobUpdateResult_) Equals(other *StartJobUpdateResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Key.Equals(other.Key) { return false } + if !p.UpdateSummary.Equals(other.UpdateSummary) { return false } + return true +} + func (p *StartJobUpdateResult_) String() string { if p == nil { return "" @@ -14830,14 +16151,14 @@ func NewGetJobUpdateSummariesResult_() *GetJobUpdateSummariesResult_ { func (p *GetJobUpdateSummariesResult_) GetUpdateSummaries() []*JobUpdateSummary { return p.UpdateSummaries } -func (p *GetJobUpdateSummariesResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetJobUpdateSummariesResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14845,81 +16166,95 @@ func (p *GetJobUpdateSummariesResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.LIST { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetJobUpdateSummariesResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *GetJobUpdateSummariesResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*JobUpdateSummary, 0, size) p.UpdateSummaries = tSlice for i := 0; i < size; i ++ { - _elem43 := &JobUpdateSummary{} - if err := _elem43.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem43), err) + _elem84 := &JobUpdateSummary{} + if err := _elem84.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem84), err) } - p.UpdateSummaries = append(p.UpdateSummaries, _elem43) + p.UpdateSummaries = append(p.UpdateSummaries, _elem84) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *GetJobUpdateSummariesResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateSummariesResult"); err != nil { +func (p *GetJobUpdateSummariesResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateSummariesResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetJobUpdateSummariesResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateSummaries", thrift.LIST, 1); err != nil { +func (p *GetJobUpdateSummariesResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateSummaries", thrift.LIST, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateSummaries: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.UpdateSummaries)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.UpdateSummaries)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.UpdateSummaries { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateSummaries: ", p), err) } return err } +func (p *GetJobUpdateSummariesResult_) Equals(other *GetJobUpdateSummariesResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.UpdateSummaries) != len(other.UpdateSummaries) { return false } + for i, _tgt := range p.UpdateSummaries { + _src85 := other.UpdateSummaries[i] + if !_tgt.Equals(_src85) { return false } + } + return true +} + func (p *GetJobUpdateSummariesResult_) String() string { if p == nil { return "" @@ -14956,14 +16291,14 @@ func (p *GetJobUpdateDetailsResult_) IsSetDetails() bool { return p.Details != nil } -func (p *GetJobUpdateDetailsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetJobUpdateDetailsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -14971,111 +16306,126 @@ func (p *GetJobUpdateDetailsResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.LIST { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetJobUpdateDetailsResult_) ReadField1(iprot thrift.TProtocol) error { +func (p *GetJobUpdateDetailsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Details = &JobUpdateDetails{} - if err := p.Details.Read(iprot); err != nil { + if err := p.Details.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Details), err) } return nil } -func (p *GetJobUpdateDetailsResult_) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *GetJobUpdateDetailsResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*JobUpdateDetails, 0, size) p.DetailsList = tSlice for i := 0; i < size; i ++ { - _elem44 := &JobUpdateDetails{} - if err := _elem44.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem44), err) + _elem86 := &JobUpdateDetails{} + if err := _elem86.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem86), err) } - p.DetailsList = append(p.DetailsList, _elem44) + p.DetailsList = append(p.DetailsList, _elem86) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *GetJobUpdateDetailsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateDetailsResult"); err != nil { +func (p *GetJobUpdateDetailsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateDetailsResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetJobUpdateDetailsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("details", thrift.STRUCT, 1); err != nil { +func (p *GetJobUpdateDetailsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "details", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:details: ", p), err) } - if err := p.Details.Write(oprot); err != nil { + if err := p.Details.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Details), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:details: ", p), err) } return err } -func (p *GetJobUpdateDetailsResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("detailsList", thrift.LIST, 2); err != nil { +func (p *GetJobUpdateDetailsResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "detailsList", thrift.LIST, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:detailsList: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.DetailsList)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.DetailsList)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.DetailsList { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:detailsList: ", p), err) } return err } +func (p *GetJobUpdateDetailsResult_) Equals(other *GetJobUpdateDetailsResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Details.Equals(other.Details) { return false } + if len(p.DetailsList) != len(other.DetailsList) { return false } + for i, _tgt := range p.DetailsList { + _src87 := other.DetailsList[i] + if !_tgt.Equals(_src87) { return false } + } + return true +} + func (p *GetJobUpdateDetailsResult_) String() string { if p == nil { return "" @@ -15099,14 +16449,14 @@ func NewPulseJobUpdateResult_() *PulseJobUpdateResult_ { func (p *PulseJobUpdateResult_) GetStatus() JobUpdatePulseStatus { return p.Status } -func (p *PulseJobUpdateResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *PulseJobUpdateResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -15114,31 +16464,31 @@ func (p *PulseJobUpdateResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *PulseJobUpdateResult_) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *PulseJobUpdateResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { temp := JobUpdatePulseStatus(v) @@ -15147,29 +16497,39 @@ func (p *PulseJobUpdateResult_) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *PulseJobUpdateResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PulseJobUpdateResult"); err != nil { +func (p *PulseJobUpdateResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PulseJobUpdateResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *PulseJobUpdateResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { +func (p *PulseJobUpdateResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } return err } +func (p *PulseJobUpdateResult_) Equals(other *PulseJobUpdateResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + return true +} + func (p *PulseJobUpdateResult_) String() string { if p == nil { return "" @@ -15209,14 +16569,14 @@ func (p *GetJobUpdateDiffResult_) GetUpdate() []*ConfigGroup { func (p *GetJobUpdateDiffResult_) GetUnchanged() []*ConfigGroup { return p.Unchanged } -func (p *GetJobUpdateDiffResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetJobUpdateDiffResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -15224,259 +16584,300 @@ func (p *GetJobUpdateDiffResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.SET { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.SET { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.SET { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetJobUpdateDiffResult_) ReadField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetJobUpdateDiffResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ConfigGroup, 0, size) p.Add = tSet for i := 0; i < size; i ++ { - _elem45 := &ConfigGroup{} - if err := _elem45.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem45), err) + _elem88 := &ConfigGroup{} + if err := _elem88.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem88), err) } - p.Add = append(p.Add, _elem45) + p.Add = append(p.Add, _elem88) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetJobUpdateDiffResult_) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetJobUpdateDiffResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ConfigGroup, 0, size) p.Remove = tSet for i := 0; i < size; i ++ { - _elem46 := &ConfigGroup{} - if err := _elem46.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem46), err) + _elem89 := &ConfigGroup{} + if err := _elem89.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem89), err) } - p.Remove = append(p.Remove, _elem46) + p.Remove = append(p.Remove, _elem89) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetJobUpdateDiffResult_) ReadField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetJobUpdateDiffResult_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ConfigGroup, 0, size) p.Update = tSet for i := 0; i < size; i ++ { - _elem47 := &ConfigGroup{} - if err := _elem47.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem47), err) + _elem90 := &ConfigGroup{} + if err := _elem90.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem90), err) } - p.Update = append(p.Update, _elem47) + p.Update = append(p.Update, _elem90) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetJobUpdateDiffResult_) ReadField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetJobUpdateDiffResult_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*ConfigGroup, 0, size) p.Unchanged = tSet for i := 0; i < size; i ++ { - _elem48 := &ConfigGroup{} - if err := _elem48.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem48), err) + _elem91 := &ConfigGroup{} + if err := _elem91.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem91), err) } - p.Unchanged = append(p.Unchanged, _elem48) + p.Unchanged = append(p.Unchanged, _elem91) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetJobUpdateDiffResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateDiffResult"); err != nil { +func (p *GetJobUpdateDiffResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateDiffResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetJobUpdateDiffResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.SET, 1); err != nil { +func (p *GetJobUpdateDiffResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "add", thrift.SET, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:add: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Add)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Add)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -15506,14 +16907,14 @@ func (p *TierConfig) GetName() string { func (p *TierConfig) GetSettings() map[string]string { return p.Settings } -func (p *TierConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *TierConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -15521,41 +16922,41 @@ func (p *TierConfig) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.MAP { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *TierConfig) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *TierConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Name = v @@ -15563,78 +16964,93 @@ func (p *TierConfig) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *TierConfig) ReadField2(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() +func (p *TierConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) if err != nil { return thrift.PrependError("error reading map begin: ", err) } tMap := make(map[string]string, size) p.Settings = tMap for i := 0; i < size; i ++ { -var _key49 string - if v, err := iprot.ReadString(); err != nil { +var _key96 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _key49 = v + _key96 = v } -var _val50 string - if v, err := iprot.ReadString(); err != nil { +var _val97 string + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _val50 = v + _val97 = v } - p.Settings[_key49] = _val50 + p.Settings[_key96] = _val97 } - if err := iprot.ReadMapEnd(); err != nil { + if err := iprot.ReadMapEnd(ctx); err != nil { return thrift.PrependError("error reading map end: ", err) } return nil } -func (p *TierConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TierConfig"); err != nil { +func (p *TierConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TierConfig"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *TierConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { +func (p *TierConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } - if err := oprot.WriteString(string(p.Name)); err != nil { + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } return err } -func (p *TierConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.MAP, 2); err != nil { +func (p *TierConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.MAP, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:settings: ", p), err) } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Settings)); err != nil { + if err := oprot.WriteMapBegin(ctx, thrift.STRING, thrift.STRING, len(p.Settings)); err != nil { return thrift.PrependError("error writing map begin: ", err) } for k, v := range p.Settings { - if err := oprot.WriteString(string(k)); err != nil { + if err := oprot.WriteString(ctx, string(k)); err != nil { return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - if err := oprot.WriteString(string(v)); err != nil { + if err := oprot.WriteString(ctx, string(v)); err != nil { return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } } - if err := oprot.WriteMapEnd(); err != nil { + if err := oprot.WriteMapEnd(ctx); err != nil { return thrift.PrependError("error writing map end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:settings: ", p), err) } return err } +func (p *TierConfig) Equals(other *TierConfig) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if len(p.Settings) != len(other.Settings) { return false } + for k, _tgt := range p.Settings { + _src98 := other.Settings[k] + if _tgt != _src98 { return false } + } + return true +} + func (p *TierConfig) String() string { if p == nil { return "" @@ -15664,14 +17080,14 @@ func (p *GetTierConfigResult_) GetDefaultTierName() string { func (p *GetTierConfigResult_) GetTiers() []*TierConfig { return p.Tiers } -func (p *GetTierConfigResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *GetTierConfigResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -15679,41 +17095,41 @@ func (p *GetTierConfigResult_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.SET { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *GetTierConfigResult_) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *GetTierConfigResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.DefaultTierName = v @@ -15721,76 +17137,94 @@ func (p *GetTierConfigResult_) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *GetTierConfigResult_) ReadField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *GetTierConfigResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]*TierConfig, 0, size) p.Tiers = tSet for i := 0; i < size; i ++ { - _elem51 := &TierConfig{} - if err := _elem51.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem51), err) + _elem99 := &TierConfig{} + if err := _elem99.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem99), err) } - p.Tiers = append(p.Tiers, _elem51) + p.Tiers = append(p.Tiers, _elem99) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *GetTierConfigResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetTierConfigResult"); err != nil { +func (p *GetTierConfigResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetTierConfigResult"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *GetTierConfigResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("defaultTierName", thrift.STRING, 1); err != nil { +func (p *GetTierConfigResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultTierName", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:defaultTierName: ", p), err) } - if err := oprot.WriteString(string(p.DefaultTierName)); err != nil { + if err := oprot.WriteString(ctx, string(p.DefaultTierName)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.defaultTierName (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:defaultTierName: ", p), err) } return err } -func (p *GetTierConfigResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tiers", thrift.SET, 2); err != nil { +func (p *GetTierConfigResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tiers", thrift.SET, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tiers: ", p), err) } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Tiers)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Tiers)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i" @@ -15821,14 +17255,14 @@ func (p *ServerInfo) GetClusterName() string { func (p *ServerInfo) GetStatsUrlPrefix() string { return p.StatsUrlPrefix } -func (p *ServerInfo) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ServerInfo) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -15836,41 +17270,41 @@ func (p *ServerInfo) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRING { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ServerInfo) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ServerInfo) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.ClusterName = v @@ -15878,8 +17312,8 @@ func (p *ServerInfo) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *ServerInfo) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ServerInfo) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.StatsUrlPrefix = v @@ -15887,40 +17321,51 @@ func (p *ServerInfo) ReadField3(iprot thrift.TProtocol) error { return nil } -func (p *ServerInfo) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ServerInfo"); err != nil { +func (p *ServerInfo) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ServerInfo"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ServerInfo) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("clusterName", thrift.STRING, 1); err != nil { +func (p *ServerInfo) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "clusterName", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:clusterName: ", p), err) } - if err := oprot.WriteString(string(p.ClusterName)); err != nil { + if err := oprot.WriteString(ctx, string(p.ClusterName)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.clusterName (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:clusterName: ", p), err) } return err } -func (p *ServerInfo) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statsUrlPrefix", thrift.STRING, 3); err != nil { +func (p *ServerInfo) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statsUrlPrefix", thrift.STRING, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:statsUrlPrefix: ", p), err) } - if err := oprot.WriteString(string(p.StatsUrlPrefix)); err != nil { + if err := oprot.WriteString(ctx, string(p.StatsUrlPrefix)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.statsUrlPrefix (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:statsUrlPrefix: ", p), err) } return err } +func (p *ServerInfo) Equals(other *ServerInfo) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ClusterName != other.ClusterName { return false } + if p.StatsUrlPrefix != other.StatsUrlPrefix { return false } + return true +} + func (p *ServerInfo) String() string { if p == nil { return "" @@ -16265,14 +17710,14 @@ func (p *Result_) IsSetGetTierConfigResult_() bool { return p.GetTierConfigResult_ != nil } -func (p *Result_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Result_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -16280,674 +17725,703 @@ func (p *Result_) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 7: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField7(iprot); err != nil { + if err := p.ReadField7(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 8: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField8(iprot); err != nil { + if err := p.ReadField8(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 9: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField9(iprot); err != nil { + if err := p.ReadField9(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 10: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField10(iprot); err != nil { + if err := p.ReadField10(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 11: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField11(iprot); err != nil { + if err := p.ReadField11(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 17: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField17(iprot); err != nil { + if err := p.ReadField17(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 18: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField18(iprot); err != nil { + if err := p.ReadField18(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 20: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField20(iprot); err != nil { + if err := p.ReadField20(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 21: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField21(iprot); err != nil { + if err := p.ReadField21(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 22: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField22(iprot); err != nil { + if err := p.ReadField22(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 23: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField23(iprot); err != nil { + if err := p.ReadField23(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 24: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField24(iprot); err != nil { + if err := p.ReadField24(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 25: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField25(iprot); err != nil { + if err := p.ReadField25(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 26: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField26(iprot); err != nil { + if err := p.ReadField26(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 27: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField27(iprot); err != nil { + if err := p.ReadField27(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Result_) ReadField1(iprot thrift.TProtocol) error { +func (p *Result_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.PopulateJobResult_ = &PopulateJobResult_{} - if err := p.PopulateJobResult_.Read(iprot); err != nil { + if err := p.PopulateJobResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PopulateJobResult_), err) } return nil } -func (p *Result_) ReadField3(iprot thrift.TProtocol) error { +func (p *Result_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.ScheduleStatusResult_ = &ScheduleStatusResult_{} - if err := p.ScheduleStatusResult_.Read(iprot); err != nil { + if err := p.ScheduleStatusResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ScheduleStatusResult_), err) } return nil } -func (p *Result_) ReadField4(iprot thrift.TProtocol) error { +func (p *Result_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.GetJobsResult_ = &GetJobsResult_{} - if err := p.GetJobsResult_.Read(iprot); err != nil { + if err := p.GetJobsResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobsResult_), err) } return nil } -func (p *Result_) ReadField5(iprot thrift.TProtocol) error { +func (p *Result_) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { p.GetQuotaResult_ = &GetQuotaResult_{} - if err := p.GetQuotaResult_.Read(iprot); err != nil { + if err := p.GetQuotaResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetQuotaResult_), err) } return nil } -func (p *Result_) ReadField6(iprot thrift.TProtocol) error { +func (p *Result_) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { p.ListBackupsResult_ = &ListBackupsResult_{} - if err := p.ListBackupsResult_.Read(iprot); err != nil { + if err := p.ListBackupsResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ListBackupsResult_), err) } return nil } -func (p *Result_) ReadField7(iprot thrift.TProtocol) error { +func (p *Result_) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { p.StartMaintenanceResult_ = &StartMaintenanceResult_{} - if err := p.StartMaintenanceResult_.Read(iprot); err != nil { + if err := p.StartMaintenanceResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartMaintenanceResult_), err) } return nil } -func (p *Result_) ReadField8(iprot thrift.TProtocol) error { +func (p *Result_) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { p.DrainHostsResult_ = &DrainHostsResult_{} - if err := p.DrainHostsResult_.Read(iprot); err != nil { + if err := p.DrainHostsResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DrainHostsResult_), err) } return nil } -func (p *Result_) ReadField9(iprot thrift.TProtocol) error { +func (p *Result_) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { p.QueryRecoveryResult_ = &QueryRecoveryResult_{} - if err := p.QueryRecoveryResult_.Read(iprot); err != nil { + if err := p.QueryRecoveryResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QueryRecoveryResult_), err) } return nil } -func (p *Result_) ReadField10(iprot thrift.TProtocol) error { +func (p *Result_) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { p.MaintenanceStatusResult_ = &MaintenanceStatusResult_{} - if err := p.MaintenanceStatusResult_.Read(iprot); err != nil { + if err := p.MaintenanceStatusResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MaintenanceStatusResult_), err) } return nil } -func (p *Result_) ReadField11(iprot thrift.TProtocol) error { +func (p *Result_) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { p.EndMaintenanceResult_ = &EndMaintenanceResult_{} - if err := p.EndMaintenanceResult_.Read(iprot); err != nil { + if err := p.EndMaintenanceResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.EndMaintenanceResult_), err) } return nil } -func (p *Result_) ReadField17(iprot thrift.TProtocol) error { +func (p *Result_) ReadField17(ctx context.Context, iprot thrift.TProtocol) error { p.RoleSummaryResult_ = &RoleSummaryResult_{} - if err := p.RoleSummaryResult_.Read(iprot); err != nil { + if err := p.RoleSummaryResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RoleSummaryResult_), err) } return nil } -func (p *Result_) ReadField18(iprot thrift.TProtocol) error { +func (p *Result_) ReadField18(ctx context.Context, iprot thrift.TProtocol) error { p.JobSummaryResult_ = &JobSummaryResult_{} - if err := p.JobSummaryResult_.Read(iprot); err != nil { + if err := p.JobSummaryResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobSummaryResult_), err) } return nil } -func (p *Result_) ReadField20(iprot thrift.TProtocol) error { +func (p *Result_) ReadField20(ctx context.Context, iprot thrift.TProtocol) error { p.ConfigSummaryResult_ = &ConfigSummaryResult_{} - if err := p.ConfigSummaryResult_.Read(iprot); err != nil { + if err := p.ConfigSummaryResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ConfigSummaryResult_), err) } return nil } -func (p *Result_) ReadField21(iprot thrift.TProtocol) error { +func (p *Result_) ReadField21(ctx context.Context, iprot thrift.TProtocol) error { p.GetPendingReasonResult_ = &GetPendingReasonResult_{} - if err := p.GetPendingReasonResult_.Read(iprot); err != nil { + if err := p.GetPendingReasonResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetPendingReasonResult_), err) } return nil } -func (p *Result_) ReadField22(iprot thrift.TProtocol) error { +func (p *Result_) ReadField22(ctx context.Context, iprot thrift.TProtocol) error { p.StartJobUpdateResult_ = &StartJobUpdateResult_{} - if err := p.StartJobUpdateResult_.Read(iprot); err != nil { + if err := p.StartJobUpdateResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartJobUpdateResult_), err) } return nil } -func (p *Result_) ReadField23(iprot thrift.TProtocol) error { +func (p *Result_) ReadField23(ctx context.Context, iprot thrift.TProtocol) error { p.GetJobUpdateSummariesResult_ = &GetJobUpdateSummariesResult_{} - if err := p.GetJobUpdateSummariesResult_.Read(iprot); err != nil { + if err := p.GetJobUpdateSummariesResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateSummariesResult_), err) } return nil } -func (p *Result_) ReadField24(iprot thrift.TProtocol) error { +func (p *Result_) ReadField24(ctx context.Context, iprot thrift.TProtocol) error { p.GetJobUpdateDetailsResult_ = &GetJobUpdateDetailsResult_{} - if err := p.GetJobUpdateDetailsResult_.Read(iprot); err != nil { + if err := p.GetJobUpdateDetailsResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDetailsResult_), err) } return nil } -func (p *Result_) ReadField25(iprot thrift.TProtocol) error { +func (p *Result_) ReadField25(ctx context.Context, iprot thrift.TProtocol) error { p.PulseJobUpdateResult_ = &PulseJobUpdateResult_{} - if err := p.PulseJobUpdateResult_.Read(iprot); err != nil { + if err := p.PulseJobUpdateResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PulseJobUpdateResult_), err) } return nil } -func (p *Result_) ReadField26(iprot thrift.TProtocol) error { +func (p *Result_) ReadField26(ctx context.Context, iprot thrift.TProtocol) error { p.GetJobUpdateDiffResult_ = &GetJobUpdateDiffResult_{} - if err := p.GetJobUpdateDiffResult_.Read(iprot); err != nil { + if err := p.GetJobUpdateDiffResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDiffResult_), err) } return nil } -func (p *Result_) ReadField27(iprot thrift.TProtocol) error { +func (p *Result_) ReadField27(ctx context.Context, iprot thrift.TProtocol) error { p.GetTierConfigResult_ = &GetTierConfigResult_{} - if err := p.GetTierConfigResult_.Read(iprot); err != nil { + if err := p.GetTierConfigResult_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetTierConfigResult_), err) } return nil } -func (p *Result_) Write(oprot thrift.TProtocol) error { +func (p *Result_) Write(ctx context.Context, oprot thrift.TProtocol) error { if c := p.CountSetFieldsResult_(); c != 1 { return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) } - if err := oprot.WriteStructBegin("Result"); err != nil { + if err := oprot.WriteStructBegin(ctx, "Result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField17(oprot); err != nil { return err } - if err := p.writeField18(oprot); err != nil { return err } - if err := p.writeField20(oprot); err != nil { return err } - if err := p.writeField21(oprot); err != nil { return err } - if err := p.writeField22(oprot); err != nil { return err } - if err := p.writeField23(oprot); err != nil { return err } - if err := p.writeField24(oprot); err != nil { return err } - if err := p.writeField25(oprot); err != nil { return err } - if err := p.writeField26(oprot); err != nil { return err } - if err := p.writeField27(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField17(ctx, oprot); err != nil { return err } + if err := p.writeField18(ctx, oprot); err != nil { return err } + if err := p.writeField20(ctx, oprot); err != nil { return err } + if err := p.writeField21(ctx, oprot); err != nil { return err } + if err := p.writeField22(ctx, oprot); err != nil { return err } + if err := p.writeField23(ctx, oprot); err != nil { return err } + if err := p.writeField24(ctx, oprot); err != nil { return err } + if err := p.writeField25(ctx, oprot); err != nil { return err } + if err := p.writeField26(ctx, oprot); err != nil { return err } + if err := p.writeField27(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Result_) writeField1(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetPopulateJobResult_() { - if err := oprot.WriteFieldBegin("populateJobResult", thrift.STRUCT, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "populateJobResult", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:populateJobResult: ", p), err) } - if err := p.PopulateJobResult_.Write(oprot); err != nil { + if err := p.PopulateJobResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PopulateJobResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:populateJobResult: ", p), err) } } return err } -func (p *Result_) writeField3(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetScheduleStatusResult_() { - if err := oprot.WriteFieldBegin("scheduleStatusResult", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "scheduleStatusResult", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:scheduleStatusResult: ", p), err) } - if err := p.ScheduleStatusResult_.Write(oprot); err != nil { + if err := p.ScheduleStatusResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ScheduleStatusResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:scheduleStatusResult: ", p), err) } } return err } -func (p *Result_) writeField4(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetJobsResult_() { - if err := oprot.WriteFieldBegin("getJobsResult", thrift.STRUCT, 4); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getJobsResult", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:getJobsResult: ", p), err) } - if err := p.GetJobsResult_.Write(oprot); err != nil { + if err := p.GetJobsResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobsResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:getJobsResult: ", p), err) } } return err } -func (p *Result_) writeField5(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetQuotaResult_() { - if err := oprot.WriteFieldBegin("getQuotaResult", thrift.STRUCT, 5); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getQuotaResult", thrift.STRUCT, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:getQuotaResult: ", p), err) } - if err := p.GetQuotaResult_.Write(oprot); err != nil { + if err := p.GetQuotaResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetQuotaResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:getQuotaResult: ", p), err) } } return err } -func (p *Result_) writeField6(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetListBackupsResult_() { - if err := oprot.WriteFieldBegin("listBackupsResult", thrift.STRUCT, 6); err != nil { + if err := oprot.WriteFieldBegin(ctx, "listBackupsResult", thrift.STRUCT, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:listBackupsResult: ", p), err) } - if err := p.ListBackupsResult_.Write(oprot); err != nil { + if err := p.ListBackupsResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ListBackupsResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:listBackupsResult: ", p), err) } } return err } -func (p *Result_) writeField7(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetStartMaintenanceResult_() { - if err := oprot.WriteFieldBegin("startMaintenanceResult", thrift.STRUCT, 7); err != nil { + if err := oprot.WriteFieldBegin(ctx, "startMaintenanceResult", thrift.STRUCT, 7); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:startMaintenanceResult: ", p), err) } - if err := p.StartMaintenanceResult_.Write(oprot); err != nil { + if err := p.StartMaintenanceResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartMaintenanceResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 7:startMaintenanceResult: ", p), err) } } return err } -func (p *Result_) writeField8(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField8(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetDrainHostsResult_() { - if err := oprot.WriteFieldBegin("drainHostsResult", thrift.STRUCT, 8); err != nil { + if err := oprot.WriteFieldBegin(ctx, "drainHostsResult", thrift.STRUCT, 8); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:drainHostsResult: ", p), err) } - if err := p.DrainHostsResult_.Write(oprot); err != nil { + if err := p.DrainHostsResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DrainHostsResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 8:drainHostsResult: ", p), err) } } return err } -func (p *Result_) writeField9(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField9(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetQueryRecoveryResult_() { - if err := oprot.WriteFieldBegin("queryRecoveryResult", thrift.STRUCT, 9); err != nil { + if err := oprot.WriteFieldBegin(ctx, "queryRecoveryResult", thrift.STRUCT, 9); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:queryRecoveryResult: ", p), err) } - if err := p.QueryRecoveryResult_.Write(oprot); err != nil { + if err := p.QueryRecoveryResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QueryRecoveryResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 9:queryRecoveryResult: ", p), err) } } return err } -func (p *Result_) writeField10(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField10(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMaintenanceStatusResult_() { - if err := oprot.WriteFieldBegin("maintenanceStatusResult", thrift.STRUCT, 10); err != nil { + if err := oprot.WriteFieldBegin(ctx, "maintenanceStatusResult", thrift.STRUCT, 10); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:maintenanceStatusResult: ", p), err) } - if err := p.MaintenanceStatusResult_.Write(oprot); err != nil { + if err := p.MaintenanceStatusResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MaintenanceStatusResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 10:maintenanceStatusResult: ", p), err) } } return err } -func (p *Result_) writeField11(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField11(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetEndMaintenanceResult_() { - if err := oprot.WriteFieldBegin("endMaintenanceResult", thrift.STRUCT, 11); err != nil { + if err := oprot.WriteFieldBegin(ctx, "endMaintenanceResult", thrift.STRUCT, 11); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:endMaintenanceResult: ", p), err) } - if err := p.EndMaintenanceResult_.Write(oprot); err != nil { + if err := p.EndMaintenanceResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.EndMaintenanceResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 11:endMaintenanceResult: ", p), err) } } return err } -func (p *Result_) writeField17(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField17(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetRoleSummaryResult_() { - if err := oprot.WriteFieldBegin("roleSummaryResult", thrift.STRUCT, 17); err != nil { + if err := oprot.WriteFieldBegin(ctx, "roleSummaryResult", thrift.STRUCT, 17); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:roleSummaryResult: ", p), err) } - if err := p.RoleSummaryResult_.Write(oprot); err != nil { + if err := p.RoleSummaryResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RoleSummaryResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 17:roleSummaryResult: ", p), err) } } return err } -func (p *Result_) writeField18(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField18(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetJobSummaryResult_() { - if err := oprot.WriteFieldBegin("jobSummaryResult", thrift.STRUCT, 18); err != nil { + if err := oprot.WriteFieldBegin(ctx, "jobSummaryResult", thrift.STRUCT, 18); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:jobSummaryResult: ", p), err) } - if err := p.JobSummaryResult_.Write(oprot); err != nil { + if err := p.JobSummaryResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobSummaryResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 18:jobSummaryResult: ", p), err) } } return err } -func (p *Result_) writeField20(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField20(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetConfigSummaryResult_() { - if err := oprot.WriteFieldBegin("configSummaryResult", thrift.STRUCT, 20); err != nil { + if err := oprot.WriteFieldBegin(ctx, "configSummaryResult", thrift.STRUCT, 20); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:configSummaryResult: ", p), err) } - if err := p.ConfigSummaryResult_.Write(oprot); err != nil { + if err := p.ConfigSummaryResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ConfigSummaryResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 20:configSummaryResult: ", p), err) } } return err } -func (p *Result_) writeField21(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField21(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetPendingReasonResult_() { - if err := oprot.WriteFieldBegin("getPendingReasonResult", thrift.STRUCT, 21); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getPendingReasonResult", thrift.STRUCT, 21); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:getPendingReasonResult: ", p), err) } - if err := p.GetPendingReasonResult_.Write(oprot); err != nil { + if err := p.GetPendingReasonResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetPendingReasonResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 21:getPendingReasonResult: ", p), err) } } return err } -func (p *Result_) writeField22(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField22(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetStartJobUpdateResult_() { - if err := oprot.WriteFieldBegin("startJobUpdateResult", thrift.STRUCT, 22); err != nil { + if err := oprot.WriteFieldBegin(ctx, "startJobUpdateResult", thrift.STRUCT, 22); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:startJobUpdateResult: ", p), err) } - if err := p.StartJobUpdateResult_.Write(oprot); err != nil { + if err := p.StartJobUpdateResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartJobUpdateResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 22:startJobUpdateResult: ", p), err) } } return err } -func (p *Result_) writeField23(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField23(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetJobUpdateSummariesResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateSummariesResult", thrift.STRUCT, 23); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateSummariesResult", thrift.STRUCT, 23); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 23:getJobUpdateSummariesResult: ", p), err) } - if err := p.GetJobUpdateSummariesResult_.Write(oprot); err != nil { + if err := p.GetJobUpdateSummariesResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateSummariesResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 23:getJobUpdateSummariesResult: ", p), err) } } return err } -func (p *Result_) writeField24(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField24(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetJobUpdateDetailsResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateDetailsResult", thrift.STRUCT, 24); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateDetailsResult", thrift.STRUCT, 24); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 24:getJobUpdateDetailsResult: ", p), err) } - if err := p.GetJobUpdateDetailsResult_.Write(oprot); err != nil { + if err := p.GetJobUpdateDetailsResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDetailsResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 24:getJobUpdateDetailsResult: ", p), err) } } return err } -func (p *Result_) writeField25(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField25(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetPulseJobUpdateResult_() { - if err := oprot.WriteFieldBegin("pulseJobUpdateResult", thrift.STRUCT, 25); err != nil { + if err := oprot.WriteFieldBegin(ctx, "pulseJobUpdateResult", thrift.STRUCT, 25); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 25:pulseJobUpdateResult: ", p), err) } - if err := p.PulseJobUpdateResult_.Write(oprot); err != nil { + if err := p.PulseJobUpdateResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PulseJobUpdateResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 25:pulseJobUpdateResult: ", p), err) } } return err } -func (p *Result_) writeField26(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField26(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetJobUpdateDiffResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateDiffResult", thrift.STRUCT, 26); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateDiffResult", thrift.STRUCT, 26); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 26:getJobUpdateDiffResult: ", p), err) } - if err := p.GetJobUpdateDiffResult_.Write(oprot); err != nil { + if err := p.GetJobUpdateDiffResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDiffResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 26:getJobUpdateDiffResult: ", p), err) } } return err } -func (p *Result_) writeField27(oprot thrift.TProtocol) (err error) { +func (p *Result_) writeField27(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetGetTierConfigResult_() { - if err := oprot.WriteFieldBegin("getTierConfigResult", thrift.STRUCT, 27); err != nil { + if err := oprot.WriteFieldBegin(ctx, "getTierConfigResult", thrift.STRUCT, 27); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 27:getTierConfigResult: ", p), err) } - if err := p.GetTierConfigResult_.Write(oprot); err != nil { + if err := p.GetTierConfigResult_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetTierConfigResult_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 27:getTierConfigResult: ", p), err) } } return err } +func (p *Result_) Equals(other *Result_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PopulateJobResult_.Equals(other.PopulateJobResult_) { return false } + if !p.ScheduleStatusResult_.Equals(other.ScheduleStatusResult_) { return false } + if !p.GetJobsResult_.Equals(other.GetJobsResult_) { return false } + if !p.GetQuotaResult_.Equals(other.GetQuotaResult_) { return false } + if !p.ListBackupsResult_.Equals(other.ListBackupsResult_) { return false } + if !p.StartMaintenanceResult_.Equals(other.StartMaintenanceResult_) { return false } + if !p.DrainHostsResult_.Equals(other.DrainHostsResult_) { return false } + if !p.QueryRecoveryResult_.Equals(other.QueryRecoveryResult_) { return false } + if !p.MaintenanceStatusResult_.Equals(other.MaintenanceStatusResult_) { return false } + if !p.EndMaintenanceResult_.Equals(other.EndMaintenanceResult_) { return false } + if !p.RoleSummaryResult_.Equals(other.RoleSummaryResult_) { return false } + if !p.JobSummaryResult_.Equals(other.JobSummaryResult_) { return false } + if !p.ConfigSummaryResult_.Equals(other.ConfigSummaryResult_) { return false } + if !p.GetPendingReasonResult_.Equals(other.GetPendingReasonResult_) { return false } + if !p.StartJobUpdateResult_.Equals(other.StartJobUpdateResult_) { return false } + if !p.GetJobUpdateSummariesResult_.Equals(other.GetJobUpdateSummariesResult_) { return false } + if !p.GetJobUpdateDetailsResult_.Equals(other.GetJobUpdateDetailsResult_) { return false } + if !p.PulseJobUpdateResult_.Equals(other.PulseJobUpdateResult_) { return false } + if !p.GetJobUpdateDiffResult_.Equals(other.GetJobUpdateDiffResult_) { return false } + if !p.GetTierConfigResult_.Equals(other.GetTierConfigResult_) { return false } + return true +} + func (p *Result_) String() string { if p == nil { return "" @@ -16969,14 +18443,14 @@ func NewResponseDetail() *ResponseDetail { func (p *ResponseDetail) GetMessage() string { return p.Message } -func (p *ResponseDetail) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ResponseDetail) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -16984,31 +18458,31 @@ func (p *ResponseDetail) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ResponseDetail) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ResponseDetail) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Message = v @@ -17016,29 +18490,39 @@ func (p *ResponseDetail) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *ResponseDetail) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ResponseDetail"); err != nil { +func (p *ResponseDetail) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ResponseDetail"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ResponseDetail) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { +func (p *ResponseDetail) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } return err } +func (p *ResponseDetail) Equals(other *ResponseDetail) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Message != other.Message { return false } + return true +} + func (p *ResponseDetail) String() string { if p == nil { return "" @@ -17095,14 +18579,14 @@ func (p *Response) IsSetResult_() bool { return p.Result_ != nil } -func (p *Response) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *Response) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -17110,61 +18594,61 @@ func (p *Response) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 5: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 6: if fieldTypeId == thrift.LIST { - if err := p.ReadField6(iprot); err != nil { + if err := p.ReadField6(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *Response) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *Response) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { temp := ResponseCode(v) @@ -17173,111 +18657,128 @@ func (p *Response) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *Response) ReadField5(iprot thrift.TProtocol) error { +func (p *Response) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { p.ServerInfo = &ServerInfo{} - if err := p.ServerInfo.Read(iprot); err != nil { + if err := p.ServerInfo.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ServerInfo), err) } return nil } -func (p *Response) ReadField3(iprot thrift.TProtocol) error { +func (p *Response) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { p.Result_ = &Result_{} - if err := p.Result_.Read(iprot); err != nil { + if err := p.Result_.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Result_), err) } return nil } -func (p *Response) ReadField6(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() +func (p *Response) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) if err != nil { return thrift.PrependError("error reading list begin: ", err) } tSlice := make([]*ResponseDetail, 0, size) p.Details = tSlice for i := 0; i < size; i ++ { - _elem52 := &ResponseDetail{} - if err := _elem52.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem52), err) + _elem101 := &ResponseDetail{} + if err := _elem101.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem101), err) } - p.Details = append(p.Details, _elem52) + p.Details = append(p.Details, _elem101) } - if err := iprot.ReadListEnd(); err != nil { + if err := iprot.ReadListEnd(ctx); err != nil { return thrift.PrependError("error reading list end: ", err) } return nil } -func (p *Response) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Response"); err != nil { +func (p *Response) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Response"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("responseCode", thrift.I32, 1); err != nil { +func (p *Response) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "responseCode", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:responseCode: ", p), err) } - if err := oprot.WriteI32(int32(p.ResponseCode)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.ResponseCode)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.responseCode (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:responseCode: ", p), err) } return err } -func (p *Response) writeField3(oprot thrift.TProtocol) (err error) { +func (p *Response) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetResult_() { - if err := oprot.WriteFieldBegin("result", thrift.STRUCT, 3); err != nil { + if err := oprot.WriteFieldBegin(ctx, "result", thrift.STRUCT, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:result: ", p), err) } - if err := p.Result_.Write(oprot); err != nil { + if err := p.Result_.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Result_), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:result: ", p), err) } } return err } -func (p *Response) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("serverInfo", thrift.STRUCT, 5); err != nil { +func (p *Response) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "serverInfo", thrift.STRUCT, 5); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:serverInfo: ", p), err) } - if err := p.ServerInfo.Write(oprot); err != nil { + if err := p.ServerInfo.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ServerInfo), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 5:serverInfo: ", p), err) } return err } -func (p *Response) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("details", thrift.LIST, 6); err != nil { +func (p *Response) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "details", thrift.LIST, 6); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:details: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Details)); err != nil { + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Details)); err != nil { return thrift.PrependError("error writing list begin: ", err) } for _, v := range p.Details { - if err := v.Write(oprot); err != nil { + if err := v.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) } } - if err := oprot.WriteListEnd(); err != nil { + if err := oprot.WriteListEnd(ctx); err != nil { return thrift.PrependError("error writing list end: ", err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 6:details: ", p), err) } return err } +func (p *Response) Equals(other *Response) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ResponseCode != other.ResponseCode { return false } + if !p.Result_.Equals(other.Result_) { return false } + if !p.ServerInfo.Equals(other.ServerInfo) { return false } + if len(p.Details) != len(other.Details) { return false } + for i, _tgt := range p.Details { + _src102 := other.Details[i] + if !_tgt.Equals(_src102) { return false } + } + return true +} + func (p *Response) String() string { if p == nil { return "" @@ -17306,14 +18807,14 @@ func (p *ExplicitReconciliationSettings) IsSetBatchSize() bool { return p.BatchSize != nil } -func (p *ExplicitReconciliationSettings) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ExplicitReconciliationSettings) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -17321,31 +18822,31 @@ func (p *ExplicitReconciliationSettings) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.I32 { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ExplicitReconciliationSettings) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *ExplicitReconciliationSettings) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.BatchSize = &v @@ -17353,31 +18854,46 @@ func (p *ExplicitReconciliationSettings) ReadField1(iprot thrift.TProtocol) err return nil } -func (p *ExplicitReconciliationSettings) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ExplicitReconciliationSettings"); err != nil { +func (p *ExplicitReconciliationSettings) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ExplicitReconciliationSettings"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ExplicitReconciliationSettings) writeField1(oprot thrift.TProtocol) (err error) { +func (p *ExplicitReconciliationSettings) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetBatchSize() { - if err := oprot.WriteFieldBegin("batchSize", thrift.I32, 1); err != nil { + if err := oprot.WriteFieldBegin(ctx, "batchSize", thrift.I32, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:batchSize: ", p), err) } - if err := oprot.WriteI32(int32(*p.BatchSize)); err != nil { + if err := oprot.WriteI32(ctx, int32(*p.BatchSize)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.batchSize (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:batchSize: ", p), err) } } return err } +func (p *ExplicitReconciliationSettings) Equals(other *ExplicitReconciliationSettings) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.BatchSize != other.BatchSize { + if p.BatchSize == nil || other.BatchSize == nil { + return false + } + if (*p.BatchSize) != (*other.BatchSize) { return false } + } + return true +} + func (p *ExplicitReconciliationSettings) String() string { if p == nil { return "" @@ -17452,6 +18968,7 @@ type ReadOnlyScheduler interface { type ReadOnlySchedulerClient struct { c thrift.TClient + meta thrift.ResponseMeta } func NewReadOnlySchedulerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ReadOnlySchedulerClient { @@ -17475,14 +18992,26 @@ func NewReadOnlySchedulerClient(c thrift.TClient) *ReadOnlySchedulerClient { func (p *ReadOnlySchedulerClient) Client_() thrift.TClient { return p.c } + +func (p *ReadOnlySchedulerClient) LastResponseMeta_() thrift.ResponseMeta { + return p.meta +} + +func (p *ReadOnlySchedulerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { + p.meta = meta +} + // Returns a summary of the jobs grouped by role. func (p *ReadOnlySchedulerClient) GetRoleSummary(ctx context.Context) (r *Response, err error) { - var _args53 ReadOnlySchedulerGetRoleSummaryArgs - var _result54 ReadOnlySchedulerGetRoleSummaryResult - if err = p.Client_().Call(ctx, "getRoleSummary", &_args53, &_result54); err != nil { + var _args103 ReadOnlySchedulerGetRoleSummaryArgs + var _result104 ReadOnlySchedulerGetRoleSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getRoleSummary", &_args103, &_result104) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result54.GetSuccess(), nil + return _result104.GetSuccess(), nil } // Returns a summary of jobs, optionally only those owned by a specific role. @@ -17490,13 +19019,16 @@ func (p *ReadOnlySchedulerClient) GetRoleSummary(ctx context.Context) (r *Respon // Parameters: // - Role func (p *ReadOnlySchedulerClient) GetJobSummary(ctx context.Context, role string) (r *Response, err error) { - var _args55 ReadOnlySchedulerGetJobSummaryArgs - _args55.Role = role - var _result56 ReadOnlySchedulerGetJobSummaryResult - if err = p.Client_().Call(ctx, "getJobSummary", &_args55, &_result56); err != nil { + var _args105 ReadOnlySchedulerGetJobSummaryArgs + _args105.Role = role + var _result106 ReadOnlySchedulerGetJobSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobSummary", &_args105, &_result106) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result56.GetSuccess(), nil + return _result106.GetSuccess(), nil } // Fetches the status of tasks. @@ -17504,13 +19036,16 @@ func (p *ReadOnlySchedulerClient) GetJobSummary(ctx context.Context, role string // Parameters: // - Query func (p *ReadOnlySchedulerClient) GetTasksStatus(ctx context.Context, query *TaskQuery) (r *Response, err error) { - var _args57 ReadOnlySchedulerGetTasksStatusArgs - _args57.Query = query - var _result58 ReadOnlySchedulerGetTasksStatusResult - if err = p.Client_().Call(ctx, "getTasksStatus", &_args57, &_result58); err != nil { + var _args107 ReadOnlySchedulerGetTasksStatusArgs + _args107.Query = query + var _result108 ReadOnlySchedulerGetTasksStatusResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTasksStatus", &_args107, &_result108) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result58.GetSuccess(), nil + return _result108.GetSuccess(), nil } // Same as getTaskStatus but without the TaskConfig.ExecutorConfig data set. @@ -17519,13 +19054,16 @@ func (p *ReadOnlySchedulerClient) GetTasksStatus(ctx context.Context, query *Tas // Parameters: // - Query func (p *ReadOnlySchedulerClient) GetTasksWithoutConfigs(ctx context.Context, query *TaskQuery) (r *Response, err error) { - var _args59 ReadOnlySchedulerGetTasksWithoutConfigsArgs - _args59.Query = query - var _result60 ReadOnlySchedulerGetTasksWithoutConfigsResult - if err = p.Client_().Call(ctx, "getTasksWithoutConfigs", &_args59, &_result60); err != nil { + var _args109 ReadOnlySchedulerGetTasksWithoutConfigsArgs + _args109.Query = query + var _result110 ReadOnlySchedulerGetTasksWithoutConfigsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTasksWithoutConfigs", &_args109, &_result110) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result60.GetSuccess(), nil + return _result110.GetSuccess(), nil } // Returns user-friendly reasons (if available) for tasks retained in PENDING state. @@ -17533,13 +19071,16 @@ func (p *ReadOnlySchedulerClient) GetTasksWithoutConfigs(ctx context.Context, qu // Parameters: // - Query func (p *ReadOnlySchedulerClient) GetPendingReason(ctx context.Context, query *TaskQuery) (r *Response, err error) { - var _args61 ReadOnlySchedulerGetPendingReasonArgs - _args61.Query = query - var _result62 ReadOnlySchedulerGetPendingReasonResult - if err = p.Client_().Call(ctx, "getPendingReason", &_args61, &_result62); err != nil { + var _args111 ReadOnlySchedulerGetPendingReasonArgs + _args111.Query = query + var _result112 ReadOnlySchedulerGetPendingReasonResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getPendingReason", &_args111, &_result112) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result62.GetSuccess(), nil + return _result112.GetSuccess(), nil } // Fetches the configuration summary of active tasks for the specified job. @@ -17547,13 +19088,16 @@ func (p *ReadOnlySchedulerClient) GetPendingReason(ctx context.Context, query *T // Parameters: // - Job func (p *ReadOnlySchedulerClient) GetConfigSummary(ctx context.Context, job *JobKey) (r *Response, err error) { - var _args63 ReadOnlySchedulerGetConfigSummaryArgs - _args63.Job = job - var _result64 ReadOnlySchedulerGetConfigSummaryResult - if err = p.Client_().Call(ctx, "getConfigSummary", &_args63, &_result64); err != nil { + var _args113 ReadOnlySchedulerGetConfigSummaryArgs + _args113.Job = job + var _result114 ReadOnlySchedulerGetConfigSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getConfigSummary", &_args113, &_result114) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result64.GetSuccess(), nil + return _result114.GetSuccess(), nil } // Fetches the status of jobs. @@ -17562,13 +19106,16 @@ func (p *ReadOnlySchedulerClient) GetConfigSummary(ctx context.Context, job *Job // Parameters: // - OwnerRole func (p *ReadOnlySchedulerClient) GetJobs(ctx context.Context, ownerRole string) (r *Response, err error) { - var _args65 ReadOnlySchedulerGetJobsArgs - _args65.OwnerRole = ownerRole - var _result66 ReadOnlySchedulerGetJobsResult - if err = p.Client_().Call(ctx, "getJobs", &_args65, &_result66); err != nil { + var _args115 ReadOnlySchedulerGetJobsArgs + _args115.OwnerRole = ownerRole + var _result116 ReadOnlySchedulerGetJobsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobs", &_args115, &_result116) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result66.GetSuccess(), nil + return _result116.GetSuccess(), nil } // Fetches the quota allocated for a user. @@ -17576,13 +19123,16 @@ func (p *ReadOnlySchedulerClient) GetJobs(ctx context.Context, ownerRole string) // Parameters: // - OwnerRole func (p *ReadOnlySchedulerClient) GetQuota(ctx context.Context, ownerRole string) (r *Response, err error) { - var _args67 ReadOnlySchedulerGetQuotaArgs - _args67.OwnerRole = ownerRole - var _result68 ReadOnlySchedulerGetQuotaResult - if err = p.Client_().Call(ctx, "getQuota", &_args67, &_result68); err != nil { + var _args117 ReadOnlySchedulerGetQuotaArgs + _args117.OwnerRole = ownerRole + var _result118 ReadOnlySchedulerGetQuotaResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getQuota", &_args117, &_result118) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result68.GetSuccess(), nil + return _result118.GetSuccess(), nil } // Populates fields in a job configuration as though it were about to be run. @@ -17591,13 +19141,16 @@ func (p *ReadOnlySchedulerClient) GetQuota(ctx context.Context, ownerRole string // Parameters: // - Description func (p *ReadOnlySchedulerClient) PopulateJobConfig(ctx context.Context, description *JobConfiguration) (r *Response, err error) { - var _args69 ReadOnlySchedulerPopulateJobConfigArgs - _args69.Description = description - var _result70 ReadOnlySchedulerPopulateJobConfigResult - if err = p.Client_().Call(ctx, "populateJobConfig", &_args69, &_result70); err != nil { + var _args119 ReadOnlySchedulerPopulateJobConfigArgs + _args119.Description = description + var _result120 ReadOnlySchedulerPopulateJobConfigResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "populateJobConfig", &_args119, &_result120) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result70.GetSuccess(), nil + return _result120.GetSuccess(), nil } // Gets job update summaries. @@ -17605,13 +19158,16 @@ func (p *ReadOnlySchedulerClient) PopulateJobConfig(ctx context.Context, descrip // Parameters: // - JobUpdateQuery func (p *ReadOnlySchedulerClient) GetJobUpdateSummaries(ctx context.Context, jobUpdateQuery *JobUpdateQuery) (r *Response, err error) { - var _args71 ReadOnlySchedulerGetJobUpdateSummariesArgs - _args71.JobUpdateQuery = jobUpdateQuery - var _result72 ReadOnlySchedulerGetJobUpdateSummariesResult - if err = p.Client_().Call(ctx, "getJobUpdateSummaries", &_args71, &_result72); err != nil { + var _args121 ReadOnlySchedulerGetJobUpdateSummariesArgs + _args121.JobUpdateQuery = jobUpdateQuery + var _result122 ReadOnlySchedulerGetJobUpdateSummariesResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateSummaries", &_args121, &_result122) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result72.GetSuccess(), nil + return _result122.GetSuccess(), nil } // Gets job update details. @@ -17619,13 +19175,16 @@ func (p *ReadOnlySchedulerClient) GetJobUpdateSummaries(ctx context.Context, job // Parameters: // - Query func (p *ReadOnlySchedulerClient) GetJobUpdateDetails(ctx context.Context, query *JobUpdateQuery) (r *Response, err error) { - var _args73 ReadOnlySchedulerGetJobUpdateDetailsArgs - _args73.Query = query - var _result74 ReadOnlySchedulerGetJobUpdateDetailsResult - if err = p.Client_().Call(ctx, "getJobUpdateDetails", &_args73, &_result74); err != nil { + var _args123 ReadOnlySchedulerGetJobUpdateDetailsArgs + _args123.Query = query + var _result124 ReadOnlySchedulerGetJobUpdateDetailsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateDetails", &_args123, &_result124) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result74.GetSuccess(), nil + return _result124.GetSuccess(), nil } // Gets the diff between client (desired) and server (current) job states. @@ -17633,23 +19192,29 @@ func (p *ReadOnlySchedulerClient) GetJobUpdateDetails(ctx context.Context, query // Parameters: // - Request func (p *ReadOnlySchedulerClient) GetJobUpdateDiff(ctx context.Context, request *JobUpdateRequest) (r *Response, err error) { - var _args75 ReadOnlySchedulerGetJobUpdateDiffArgs - _args75.Request = request - var _result76 ReadOnlySchedulerGetJobUpdateDiffResult - if err = p.Client_().Call(ctx, "getJobUpdateDiff", &_args75, &_result76); err != nil { + var _args125 ReadOnlySchedulerGetJobUpdateDiffArgs + _args125.Request = request + var _result126 ReadOnlySchedulerGetJobUpdateDiffResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateDiff", &_args125, &_result126) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result76.GetSuccess(), nil + return _result126.GetSuccess(), nil } // Gets tier configurations. func (p *ReadOnlySchedulerClient) GetTierConfigs(ctx context.Context) (r *Response, err error) { - var _args77 ReadOnlySchedulerGetTierConfigsArgs - var _result78 ReadOnlySchedulerGetTierConfigsResult - if err = p.Client_().Call(ctx, "getTierConfigs", &_args77, &_result78); err != nil { + var _args127 ReadOnlySchedulerGetTierConfigsArgs + var _result128 ReadOnlySchedulerGetTierConfigsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTierConfigs", &_args127, &_result128) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result78.GetSuccess(), nil + return _result128.GetSuccess(), nil } type ReadOnlySchedulerProcessor struct { @@ -17672,37 +19237,37 @@ func (p *ReadOnlySchedulerProcessor) ProcessorMap() map[string]thrift.TProcessor func NewReadOnlySchedulerProcessor(handler ReadOnlyScheduler) *ReadOnlySchedulerProcessor { - self79 := &ReadOnlySchedulerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} - self79.processorMap["getRoleSummary"] = &readOnlySchedulerProcessorGetRoleSummary{handler:handler} - self79.processorMap["getJobSummary"] = &readOnlySchedulerProcessorGetJobSummary{handler:handler} - self79.processorMap["getTasksStatus"] = &readOnlySchedulerProcessorGetTasksStatus{handler:handler} - self79.processorMap["getTasksWithoutConfigs"] = &readOnlySchedulerProcessorGetTasksWithoutConfigs{handler:handler} - self79.processorMap["getPendingReason"] = &readOnlySchedulerProcessorGetPendingReason{handler:handler} - self79.processorMap["getConfigSummary"] = &readOnlySchedulerProcessorGetConfigSummary{handler:handler} - self79.processorMap["getJobs"] = &readOnlySchedulerProcessorGetJobs{handler:handler} - self79.processorMap["getQuota"] = &readOnlySchedulerProcessorGetQuota{handler:handler} - self79.processorMap["populateJobConfig"] = &readOnlySchedulerProcessorPopulateJobConfig{handler:handler} - self79.processorMap["getJobUpdateSummaries"] = &readOnlySchedulerProcessorGetJobUpdateSummaries{handler:handler} - self79.processorMap["getJobUpdateDetails"] = &readOnlySchedulerProcessorGetJobUpdateDetails{handler:handler} - self79.processorMap["getJobUpdateDiff"] = &readOnlySchedulerProcessorGetJobUpdateDiff{handler:handler} - self79.processorMap["getTierConfigs"] = &readOnlySchedulerProcessorGetTierConfigs{handler:handler} -return self79 + self129 := &ReadOnlySchedulerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} + self129.processorMap["getRoleSummary"] = &readOnlySchedulerProcessorGetRoleSummary{handler:handler} + self129.processorMap["getJobSummary"] = &readOnlySchedulerProcessorGetJobSummary{handler:handler} + self129.processorMap["getTasksStatus"] = &readOnlySchedulerProcessorGetTasksStatus{handler:handler} + self129.processorMap["getTasksWithoutConfigs"] = &readOnlySchedulerProcessorGetTasksWithoutConfigs{handler:handler} + self129.processorMap["getPendingReason"] = &readOnlySchedulerProcessorGetPendingReason{handler:handler} + self129.processorMap["getConfigSummary"] = &readOnlySchedulerProcessorGetConfigSummary{handler:handler} + self129.processorMap["getJobs"] = &readOnlySchedulerProcessorGetJobs{handler:handler} + self129.processorMap["getQuota"] = &readOnlySchedulerProcessorGetQuota{handler:handler} + self129.processorMap["populateJobConfig"] = &readOnlySchedulerProcessorPopulateJobConfig{handler:handler} + self129.processorMap["getJobUpdateSummaries"] = &readOnlySchedulerProcessorGetJobUpdateSummaries{handler:handler} + self129.processorMap["getJobUpdateDetails"] = &readOnlySchedulerProcessorGetJobUpdateDetails{handler:handler} + self129.processorMap["getJobUpdateDiff"] = &readOnlySchedulerProcessorGetJobUpdateDiff{handler:handler} + self129.processorMap["getTierConfigs"] = &readOnlySchedulerProcessorGetTierConfigs{handler:handler} +return self129 } func (p *ReadOnlySchedulerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { return false, err } + name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) + if err2 != nil { return false, thrift.WrapTException(err2) } if processor, ok := p.GetProcessorFunction(name); ok { return processor.Process(ctx, seqId, iprot, oprot) } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x80 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x80.Write(oprot) - oprot.WriteMessageEnd() + iprot.Skip(ctx, thrift.STRUCT) + iprot.ReadMessageEnd(ctx) + x130 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) + oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) + x130.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, x80 + return false, x130 } @@ -17712,41 +19277,72 @@ type readOnlySchedulerProcessorGetRoleSummary struct { func (p *readOnlySchedulerProcessorGetRoleSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetRoleSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getRoleSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetRoleSummaryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetRoleSummary(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getRoleSummary: " + err2.Error()) - oprot.WriteMessageBegin("getRoleSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getRoleSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -17760,41 +19356,72 @@ type readOnlySchedulerProcessorGetJobSummary struct { func (p *readOnlySchedulerProcessorGetJobSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetJobSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetJobSummaryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetJobSummary(ctx, args.Role); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobSummary: " + err2.Error()) - oprot.WriteMessageBegin("getJobSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getJobSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -17808,41 +19435,72 @@ type readOnlySchedulerProcessorGetTasksStatus struct { func (p *readOnlySchedulerProcessorGetTasksStatus) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetTasksStatusArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTasksStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetTasksStatusResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetTasksStatus(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksStatus: " + err2.Error()) - oprot.WriteMessageBegin("getTasksStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getTasksStatus", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -17856,41 +19514,72 @@ type readOnlySchedulerProcessorGetTasksWithoutConfigs struct { func (p *readOnlySchedulerProcessorGetTasksWithoutConfigs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetTasksWithoutConfigsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetTasksWithoutConfigsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetTasksWithoutConfigs(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksWithoutConfigs: " + err2.Error()) - oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -17904,41 +19593,72 @@ type readOnlySchedulerProcessorGetPendingReason struct { func (p *readOnlySchedulerProcessorGetPendingReason) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetPendingReasonArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getPendingReason", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetPendingReasonResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetPendingReason(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getPendingReason: " + err2.Error()) - oprot.WriteMessageBegin("getPendingReason", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getPendingReason", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -17952,41 +19672,72 @@ type readOnlySchedulerProcessorGetConfigSummary struct { func (p *readOnlySchedulerProcessorGetConfigSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetConfigSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getConfigSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetConfigSummaryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetConfigSummary(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getConfigSummary: " + err2.Error()) - oprot.WriteMessageBegin("getConfigSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getConfigSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18000,41 +19751,72 @@ type readOnlySchedulerProcessorGetJobs struct { func (p *readOnlySchedulerProcessorGetJobs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetJobsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetJobsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetJobs(ctx, args.OwnerRole); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobs: " + err2.Error()) - oprot.WriteMessageBegin("getJobs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getJobs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getJobs", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18048,41 +19830,72 @@ type readOnlySchedulerProcessorGetQuota struct { func (p *readOnlySchedulerProcessorGetQuota) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetQuotaArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetQuotaResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetQuota(ctx, args.OwnerRole); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getQuota: " + err2.Error()) - oprot.WriteMessageBegin("getQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getQuota", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getQuota", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18096,41 +19909,72 @@ type readOnlySchedulerProcessorPopulateJobConfig struct { func (p *readOnlySchedulerProcessorPopulateJobConfig) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerPopulateJobConfigArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("populateJobConfig", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerPopulateJobConfigResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.PopulateJobConfig(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing populateJobConfig: " + err2.Error()) - oprot.WriteMessageBegin("populateJobConfig", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("populateJobConfig", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18144,41 +19988,72 @@ type readOnlySchedulerProcessorGetJobUpdateSummaries struct { func (p *readOnlySchedulerProcessorGetJobUpdateSummaries) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetJobUpdateSummariesArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetJobUpdateSummariesResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetJobUpdateSummaries(ctx, args.JobUpdateQuery); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateSummaries: " + err2.Error()) - oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18192,41 +20067,72 @@ type readOnlySchedulerProcessorGetJobUpdateDetails struct { func (p *readOnlySchedulerProcessorGetJobUpdateDetails) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetJobUpdateDetailsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateDetails", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetJobUpdateDetailsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetJobUpdateDetails(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDetails: " + err2.Error()) - oprot.WriteMessageBegin("getJobUpdateDetails", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getJobUpdateDetails", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18240,41 +20146,72 @@ type readOnlySchedulerProcessorGetJobUpdateDiff struct { func (p *readOnlySchedulerProcessorGetJobUpdateDiff) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetJobUpdateDiffArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateDiff", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetJobUpdateDiffResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetJobUpdateDiff(ctx, args.Request); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDiff: " + err2.Error()) - oprot.WriteMessageBegin("getJobUpdateDiff", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getJobUpdateDiff", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18288,41 +20225,72 @@ type readOnlySchedulerProcessorGetTierConfigs struct { func (p *readOnlySchedulerProcessorGetTierConfigs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := ReadOnlySchedulerGetTierConfigsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTierConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := ReadOnlySchedulerGetTierConfigsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.GetTierConfigs(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTierConfigs: " + err2.Error()) - oprot.WriteMessageBegin("getTierConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("getTierConfigs", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -18340,39 +20308,39 @@ func NewReadOnlySchedulerGetRoleSummaryArgs() *ReadOnlySchedulerGetRoleSummaryAr return &ReadOnlySchedulerGetRoleSummaryArgs{} } -func (p *ReadOnlySchedulerGetRoleSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetRoleSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetRoleSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getRoleSummary_args"); err != nil { +func (p *ReadOnlySchedulerGetRoleSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getRoleSummary_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -18405,14 +20373,14 @@ func (p *ReadOnlySchedulerGetRoleSummaryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetRoleSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetRoleSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18420,58 +20388,58 @@ func (p *ReadOnlySchedulerGetRoleSummaryResult) Read(iprot thrift.TProtocol) err switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetRoleSummaryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetRoleSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetRoleSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getRoleSummary_result"); err != nil { +func (p *ReadOnlySchedulerGetRoleSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getRoleSummary_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetRoleSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetRoleSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -18498,14 +20466,14 @@ func NewReadOnlySchedulerGetJobSummaryArgs() *ReadOnlySchedulerGetJobSummaryArgs func (p *ReadOnlySchedulerGetJobSummaryArgs) GetRole() string { return p.Role } -func (p *ReadOnlySchedulerGetJobSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18513,31 +20481,31 @@ func (p *ReadOnlySchedulerGetJobSummaryArgs) Read(iprot thrift.TProtocol) error switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobSummaryArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.Role = v @@ -18545,25 +20513,25 @@ func (p *ReadOnlySchedulerGetJobSummaryArgs) ReadField1(iprot thrift.TProtocol) return nil } -func (p *ReadOnlySchedulerGetJobSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobSummary_args"); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobSummary_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobSummaryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } - if err := oprot.WriteString(string(p.Role)); err != nil { + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } return err } @@ -18596,14 +20564,14 @@ func (p *ReadOnlySchedulerGetJobSummaryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetJobSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18611,58 +20579,58 @@ func (p *ReadOnlySchedulerGetJobSummaryResult) Read(iprot thrift.TProtocol) erro switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobSummaryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetJobSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobSummary_result"); err != nil { +func (p *ReadOnlySchedulerGetJobSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobSummary_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetJobSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -18696,14 +20664,14 @@ func (p *ReadOnlySchedulerGetTasksStatusArgs) IsSetQuery() bool { return p.Query != nil } -func (p *ReadOnlySchedulerGetTasksStatusArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTasksStatusArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18711,57 +20679,57 @@ func (p *ReadOnlySchedulerGetTasksStatusArgs) Read(iprot thrift.TProtocol) error switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetTasksStatusArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksStatus_args"); err != nil { +func (p *ReadOnlySchedulerGetTasksStatusArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksStatus_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetTasksStatusArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -18794,14 +20762,14 @@ func (p *ReadOnlySchedulerGetTasksStatusResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetTasksStatusResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTasksStatusResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18809,58 +20777,58 @@ func (p *ReadOnlySchedulerGetTasksStatusResult) Read(iprot thrift.TProtocol) err switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetTasksStatusResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksStatus_result"); err != nil { +func (p *ReadOnlySchedulerGetTasksStatusResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksStatus_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetTasksStatusResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetTasksStatusResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -18894,14 +20862,14 @@ func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) IsSetQuery() bool { return p.Query != nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -18909,57 +20877,57 @@ func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Read(iprot thrift.TProtoco switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksWithoutConfigs_args"); err != nil { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksWithoutConfigs_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -18992,14 +20960,14 @@ func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19007,58 +20975,58 @@ func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Read(iprot thrift.TProto switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksWithoutConfigs_result"); err != nil { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksWithoutConfigs_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -19092,14 +21060,14 @@ func (p *ReadOnlySchedulerGetPendingReasonArgs) IsSetQuery() bool { return p.Query != nil } -func (p *ReadOnlySchedulerGetPendingReasonArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetPendingReasonArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19107,57 +21075,57 @@ func (p *ReadOnlySchedulerGetPendingReasonArgs) Read(iprot thrift.TProtocol) err switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetPendingReasonArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getPendingReason_args"); err != nil { +func (p *ReadOnlySchedulerGetPendingReasonArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getPendingReason_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetPendingReasonArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -19190,14 +21158,14 @@ func (p *ReadOnlySchedulerGetPendingReasonResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetPendingReasonResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetPendingReasonResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19205,58 +21173,58 @@ func (p *ReadOnlySchedulerGetPendingReasonResult) Read(iprot thrift.TProtocol) e switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetPendingReasonResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getPendingReason_result"); err != nil { +func (p *ReadOnlySchedulerGetPendingReasonResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getPendingReason_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetPendingReasonResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetPendingReasonResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -19290,14 +21258,14 @@ func (p *ReadOnlySchedulerGetConfigSummaryArgs) IsSetJob() bool { return p.Job != nil } -func (p *ReadOnlySchedulerGetConfigSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetConfigSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19305,57 +21273,57 @@ func (p *ReadOnlySchedulerGetConfigSummaryArgs) Read(iprot thrift.TProtocol) err switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetConfigSummaryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getConfigSummary_args"); err != nil { +func (p *ReadOnlySchedulerGetConfigSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getConfigSummary_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetConfigSummaryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } return err } @@ -19388,14 +21356,14 @@ func (p *ReadOnlySchedulerGetConfigSummaryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetConfigSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetConfigSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19403,58 +21371,58 @@ func (p *ReadOnlySchedulerGetConfigSummaryResult) Read(iprot thrift.TProtocol) e switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetConfigSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getConfigSummary_result"); err != nil { +func (p *ReadOnlySchedulerGetConfigSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getConfigSummary_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetConfigSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetConfigSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -19481,14 +21449,14 @@ func NewReadOnlySchedulerGetJobsArgs() *ReadOnlySchedulerGetJobsArgs { func (p *ReadOnlySchedulerGetJobsArgs) GetOwnerRole() string { return p.OwnerRole } -func (p *ReadOnlySchedulerGetJobsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19496,31 +21464,31 @@ func (p *ReadOnlySchedulerGetJobsArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobsArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ReadOnlySchedulerGetJobsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.OwnerRole = v @@ -19528,25 +21496,25 @@ func (p *ReadOnlySchedulerGetJobsArgs) ReadField1(iprot thrift.TProtocol) error return nil } -func (p *ReadOnlySchedulerGetJobsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobs_args"); err != nil { +func (p *ReadOnlySchedulerGetJobsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobs_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { +func (p *ReadOnlySchedulerGetJobsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } return err } @@ -19579,14 +21547,14 @@ func (p *ReadOnlySchedulerGetJobsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetJobsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19594,58 +21562,58 @@ func (p *ReadOnlySchedulerGetJobsResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetJobsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobs_result"); err != nil { +func (p *ReadOnlySchedulerGetJobsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobs_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetJobsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -19672,14 +21640,14 @@ func NewReadOnlySchedulerGetQuotaArgs() *ReadOnlySchedulerGetQuotaArgs { func (p *ReadOnlySchedulerGetQuotaArgs) GetOwnerRole() string { return p.OwnerRole } -func (p *ReadOnlySchedulerGetQuotaArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetQuotaArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19687,31 +21655,31 @@ func (p *ReadOnlySchedulerGetQuotaArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetQuotaArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *ReadOnlySchedulerGetQuotaArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.OwnerRole = v @@ -19719,25 +21687,25 @@ func (p *ReadOnlySchedulerGetQuotaArgs) ReadField1(iprot thrift.TProtocol) erro return nil } -func (p *ReadOnlySchedulerGetQuotaArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getQuota_args"); err != nil { +func (p *ReadOnlySchedulerGetQuotaArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getQuota_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetQuotaArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { +func (p *ReadOnlySchedulerGetQuotaArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } return err } @@ -19770,14 +21738,14 @@ func (p *ReadOnlySchedulerGetQuotaResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetQuotaResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetQuotaResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19785,58 +21753,58 @@ func (p *ReadOnlySchedulerGetQuotaResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetQuotaResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetQuotaResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetQuotaResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getQuota_result"); err != nil { +func (p *ReadOnlySchedulerGetQuotaResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getQuota_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetQuotaResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetQuotaResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -19870,14 +21838,14 @@ func (p *ReadOnlySchedulerPopulateJobConfigArgs) IsSetDescription() bool { return p.Description != nil } -func (p *ReadOnlySchedulerPopulateJobConfigArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerPopulateJobConfigArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19885,57 +21853,57 @@ func (p *ReadOnlySchedulerPopulateJobConfigArgs) Read(iprot thrift.TProtocol) er switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerPopulateJobConfigArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { + if err := p.Description.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("populateJobConfig_args"); err != nil { +func (p *ReadOnlySchedulerPopulateJobConfigArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "populateJobConfig_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerPopulateJobConfigArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } - if err := p.Description.Write(oprot); err != nil { + if err := p.Description.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } return err } @@ -19968,14 +21936,14 @@ func (p *ReadOnlySchedulerPopulateJobConfigResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerPopulateJobConfigResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerPopulateJobConfigResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -19983,58 +21951,58 @@ func (p *ReadOnlySchedulerPopulateJobConfigResult) Read(iprot thrift.TProtocol) switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerPopulateJobConfigResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("populateJobConfig_result"); err != nil { +func (p *ReadOnlySchedulerPopulateJobConfigResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "populateJobConfig_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerPopulateJobConfigResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerPopulateJobConfigResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -20068,14 +22036,14 @@ func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) IsSetJobUpdateQuery() bool return p.JobUpdateQuery != nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20083,57 +22051,57 @@ func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Read(iprot thrift.TProtocol switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.JobUpdateQuery = &JobUpdateQuery{} - if err := p.JobUpdateQuery.Read(iprot); err != nil { + if err := p.JobUpdateQuery.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobUpdateQuery), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateSummaries_args"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateSummaries_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobUpdateQuery", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobUpdateQuery", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobUpdateQuery: ", p), err) } - if err := p.JobUpdateQuery.Write(oprot); err != nil { + if err := p.JobUpdateQuery.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobUpdateQuery), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobUpdateQuery: ", p), err) } return err } @@ -20166,14 +22134,14 @@ func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20181,58 +22149,58 @@ func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Read(iprot thrift.TProtoc switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateSummaries_result"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateSummaries_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -20267,14 +22235,14 @@ func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) IsSetQuery() bool { return p.Query != nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20282,57 +22250,57 @@ func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Read(iprot thrift.TProtocol) switch fieldId { case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) ReadField2(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &JobUpdateQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDetails_args"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDetails_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 2); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:query: ", p), err) } return err } @@ -20365,14 +22333,14 @@ func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20380,58 +22348,58 @@ func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Read(iprot thrift.TProtocol switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDetails_result"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDetails_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -20465,14 +22433,14 @@ func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) IsSetRequest() bool { return p.Request != nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20480,57 +22448,57 @@ func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Read(iprot thrift.TProtocol) err switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Request = &JobUpdateRequest{} - if err := p.Request.Read(iprot); err != nil { + if err := p.Request.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDiff_args"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDiff_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "request", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) } - if err := p.Request.Write(oprot); err != nil { + if err := p.Request.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) } return err } @@ -20563,14 +22531,14 @@ func (p *ReadOnlySchedulerGetJobUpdateDiffResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20578,58 +22546,58 @@ func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Read(iprot thrift.TProtocol) e switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDiff_result"); err != nil { +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDiff_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -20649,39 +22617,39 @@ func NewReadOnlySchedulerGetTierConfigsArgs() *ReadOnlySchedulerGetTierConfigsAr return &ReadOnlySchedulerGetTierConfigsArgs{} } -func (p *ReadOnlySchedulerGetTierConfigsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTierConfigsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTierConfigsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTierConfigs_args"); err != nil { +func (p *ReadOnlySchedulerGetTierConfigsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTierConfigs_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -20714,14 +22682,14 @@ func (p *ReadOnlySchedulerGetTierConfigsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *ReadOnlySchedulerGetTierConfigsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *ReadOnlySchedulerGetTierConfigsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -20729,58 +22697,58 @@ func (p *ReadOnlySchedulerGetTierConfigsResult) Read(iprot thrift.TProtocol) err switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *ReadOnlySchedulerGetTierConfigsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *ReadOnlySchedulerGetTierConfigsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *ReadOnlySchedulerGetTierConfigsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTierConfigs_result"); err != nil { +func (p *ReadOnlySchedulerGetTierConfigsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTierConfigs_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *ReadOnlySchedulerGetTierConfigsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *ReadOnlySchedulerGetTierConfigsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -20909,13 +22877,16 @@ func NewAuroraSchedulerManagerClient(c thrift.TClient) *AuroraSchedulerManagerCl // Parameters: // - Description func (p *AuroraSchedulerManagerClient) CreateJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) { - var _args132 AuroraSchedulerManagerCreateJobArgs - _args132.Description = description - var _result133 AuroraSchedulerManagerCreateJobResult - if err = p.Client_().Call(ctx, "createJob", &_args132, &_result133); err != nil { + var _args182 AuroraSchedulerManagerCreateJobArgs + _args182.Description = description + var _result183 AuroraSchedulerManagerCreateJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "createJob", &_args182, &_result183) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result133.GetSuccess(), nil + return _result183.GetSuccess(), nil } // Enters a job into the cron schedule, without actually starting the job. @@ -20925,13 +22896,16 @@ func (p *AuroraSchedulerManagerClient) CreateJob(ctx context.Context, descriptio // Parameters: // - Description func (p *AuroraSchedulerManagerClient) ScheduleCronJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) { - var _args134 AuroraSchedulerManagerScheduleCronJobArgs - _args134.Description = description - var _result135 AuroraSchedulerManagerScheduleCronJobResult - if err = p.Client_().Call(ctx, "scheduleCronJob", &_args134, &_result135); err != nil { + var _args184 AuroraSchedulerManagerScheduleCronJobArgs + _args184.Description = description + var _result185 AuroraSchedulerManagerScheduleCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "scheduleCronJob", &_args184, &_result185) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result135.GetSuccess(), nil + return _result185.GetSuccess(), nil } // Removes a job from the cron schedule. The request will be denied if the job was not previously @@ -20940,13 +22914,16 @@ func (p *AuroraSchedulerManagerClient) ScheduleCronJob(ctx context.Context, desc // Parameters: // - Job func (p *AuroraSchedulerManagerClient) DescheduleCronJob(ctx context.Context, job *JobKey) (r *Response, err error) { - var _args136 AuroraSchedulerManagerDescheduleCronJobArgs - _args136.Job = job - var _result137 AuroraSchedulerManagerDescheduleCronJobResult - if err = p.Client_().Call(ctx, "descheduleCronJob", &_args136, &_result137); err != nil { + var _args186 AuroraSchedulerManagerDescheduleCronJobArgs + _args186.Job = job + var _result187 AuroraSchedulerManagerDescheduleCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "descheduleCronJob", &_args186, &_result187) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result137.GetSuccess(), nil + return _result187.GetSuccess(), nil } // Starts a cron job immediately. The request will be denied if the specified job does not @@ -20955,13 +22932,16 @@ func (p *AuroraSchedulerManagerClient) DescheduleCronJob(ctx context.Context, jo // Parameters: // - Job func (p *AuroraSchedulerManagerClient) StartCronJob(ctx context.Context, job *JobKey) (r *Response, err error) { - var _args138 AuroraSchedulerManagerStartCronJobArgs - _args138.Job = job - var _result139 AuroraSchedulerManagerStartCronJobResult - if err = p.Client_().Call(ctx, "startCronJob", &_args138, &_result139); err != nil { + var _args188 AuroraSchedulerManagerStartCronJobArgs + _args188.Job = job + var _result189 AuroraSchedulerManagerStartCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "startCronJob", &_args188, &_result189) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result139.GetSuccess(), nil + return _result189.GetSuccess(), nil } // Restarts a batch of shards. @@ -20970,14 +22950,17 @@ func (p *AuroraSchedulerManagerClient) StartCronJob(ctx context.Context, job *Jo // - Job // - ShardIds func (p *AuroraSchedulerManagerClient) RestartShards(ctx context.Context, job *JobKey, shardIds []int32) (r *Response, err error) { - var _args140 AuroraSchedulerManagerRestartShardsArgs - _args140.Job = job - _args140.ShardIds = shardIds - var _result141 AuroraSchedulerManagerRestartShardsResult - if err = p.Client_().Call(ctx, "restartShards", &_args140, &_result141); err != nil { + var _args190 AuroraSchedulerManagerRestartShardsArgs + _args190.Job = job + _args190.ShardIds = shardIds + var _result191 AuroraSchedulerManagerRestartShardsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "restartShards", &_args190, &_result191) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result141.GetSuccess(), nil + return _result191.GetSuccess(), nil } // Initiates a kill on tasks. @@ -20987,15 +22970,18 @@ func (p *AuroraSchedulerManagerClient) RestartShards(ctx context.Context, job *J // - Instances // - Message func (p *AuroraSchedulerManagerClient) KillTasks(ctx context.Context, job *JobKey, instances []int32, message string) (r *Response, err error) { - var _args142 AuroraSchedulerManagerKillTasksArgs - _args142.Job = job - _args142.Instances = instances - _args142.Message = message - var _result143 AuroraSchedulerManagerKillTasksResult - if err = p.Client_().Call(ctx, "killTasks", &_args142, &_result143); err != nil { + var _args192 AuroraSchedulerManagerKillTasksArgs + _args192.Job = job + _args192.Instances = instances + _args192.Message = message + var _result193 AuroraSchedulerManagerKillTasksResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "killTasks", &_args192, &_result193) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result143.GetSuccess(), nil + return _result193.GetSuccess(), nil } // Adds new instances with the TaskConfig of the existing instance pointed by the key. @@ -21004,14 +22990,17 @@ func (p *AuroraSchedulerManagerClient) KillTasks(ctx context.Context, job *JobKe // - Key // - Count func (p *AuroraSchedulerManagerClient) AddInstances(ctx context.Context, key *InstanceKey, count int32) (r *Response, err error) { - var _args144 AuroraSchedulerManagerAddInstancesArgs - _args144.Key = key - _args144.Count = count - var _result145 AuroraSchedulerManagerAddInstancesResult - if err = p.Client_().Call(ctx, "addInstances", &_args144, &_result145); err != nil { + var _args194 AuroraSchedulerManagerAddInstancesArgs + _args194.Key = key + _args194.Count = count + var _result195 AuroraSchedulerManagerAddInstancesResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "addInstances", &_args194, &_result195) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result145.GetSuccess(), nil + return _result195.GetSuccess(), nil } // Replaces the template (configuration) for the existing cron job. @@ -21020,13 +23009,16 @@ func (p *AuroraSchedulerManagerClient) AddInstances(ctx context.Context, key *In // Parameters: // - Config func (p *AuroraSchedulerManagerClient) ReplaceCronTemplate(ctx context.Context, config *JobConfiguration) (r *Response, err error) { - var _args146 AuroraSchedulerManagerReplaceCronTemplateArgs - _args146.Config = config - var _result147 AuroraSchedulerManagerReplaceCronTemplateResult - if err = p.Client_().Call(ctx, "replaceCronTemplate", &_args146, &_result147); err != nil { + var _args196 AuroraSchedulerManagerReplaceCronTemplateArgs + _args196.Config = config + var _result197 AuroraSchedulerManagerReplaceCronTemplateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "replaceCronTemplate", &_args196, &_result197) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result147.GetSuccess(), nil + return _result197.GetSuccess(), nil } // Starts update of the existing service job. @@ -21035,14 +23027,17 @@ func (p *AuroraSchedulerManagerClient) ReplaceCronTemplate(ctx context.Context, // - Request: A description of how to change the job. // - Message: A user-specified message to include with the induced job update state change. func (p *AuroraSchedulerManagerClient) StartJobUpdate(ctx context.Context, request *JobUpdateRequest, message string) (r *Response, err error) { - var _args148 AuroraSchedulerManagerStartJobUpdateArgs - _args148.Request = request - _args148.Message = message - var _result149 AuroraSchedulerManagerStartJobUpdateResult - if err = p.Client_().Call(ctx, "startJobUpdate", &_args148, &_result149); err != nil { + var _args198 AuroraSchedulerManagerStartJobUpdateArgs + _args198.Request = request + _args198.Message = message + var _result199 AuroraSchedulerManagerStartJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "startJobUpdate", &_args198, &_result199) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result149.GetSuccess(), nil + return _result199.GetSuccess(), nil } // Pauses the specified job update. Can be resumed by resumeUpdate call. @@ -21051,14 +23046,17 @@ func (p *AuroraSchedulerManagerClient) StartJobUpdate(ctx context.Context, reque // - Key: The update to pause. // - Message: A user-specified message to include with the induced job update state change. func (p *AuroraSchedulerManagerClient) PauseJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { - var _args150 AuroraSchedulerManagerPauseJobUpdateArgs - _args150.Key = key - _args150.Message = message - var _result151 AuroraSchedulerManagerPauseJobUpdateResult - if err = p.Client_().Call(ctx, "pauseJobUpdate", &_args150, &_result151); err != nil { + var _args200 AuroraSchedulerManagerPauseJobUpdateArgs + _args200.Key = key + _args200.Message = message + var _result201 AuroraSchedulerManagerPauseJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "pauseJobUpdate", &_args200, &_result201) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result151.GetSuccess(), nil + return _result201.GetSuccess(), nil } // Resumes progress of a previously paused job update. @@ -21067,14 +23065,17 @@ func (p *AuroraSchedulerManagerClient) PauseJobUpdate(ctx context.Context, key * // - Key: The update to resume. // - Message: A user-specified message to include with the induced job update state change. func (p *AuroraSchedulerManagerClient) ResumeJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { - var _args152 AuroraSchedulerManagerResumeJobUpdateArgs - _args152.Key = key - _args152.Message = message - var _result153 AuroraSchedulerManagerResumeJobUpdateResult - if err = p.Client_().Call(ctx, "resumeJobUpdate", &_args152, &_result153); err != nil { + var _args202 AuroraSchedulerManagerResumeJobUpdateArgs + _args202.Key = key + _args202.Message = message + var _result203 AuroraSchedulerManagerResumeJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "resumeJobUpdate", &_args202, &_result203) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result153.GetSuccess(), nil + return _result203.GetSuccess(), nil } // Permanently aborts the job update. Does not remove the update history. @@ -21083,14 +23084,17 @@ func (p *AuroraSchedulerManagerClient) ResumeJobUpdate(ctx context.Context, key // - Key: The update to abort. // - Message: A user-specified message to include with the induced job update state change. func (p *AuroraSchedulerManagerClient) AbortJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { - var _args154 AuroraSchedulerManagerAbortJobUpdateArgs - _args154.Key = key - _args154.Message = message - var _result155 AuroraSchedulerManagerAbortJobUpdateResult - if err = p.Client_().Call(ctx, "abortJobUpdate", &_args154, &_result155); err != nil { + var _args204 AuroraSchedulerManagerAbortJobUpdateArgs + _args204.Key = key + _args204.Message = message + var _result205 AuroraSchedulerManagerAbortJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "abortJobUpdate", &_args204, &_result205) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result155.GetSuccess(), nil + return _result205.GetSuccess(), nil } // Rollbacks the specified active job update to the initial state. @@ -21099,14 +23103,17 @@ func (p *AuroraSchedulerManagerClient) AbortJobUpdate(ctx context.Context, key * // - Key: The update to rollback. // - Message: A user-specified message to include with the induced job update state change. func (p *AuroraSchedulerManagerClient) RollbackJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { - var _args156 AuroraSchedulerManagerRollbackJobUpdateArgs - _args156.Key = key - _args156.Message = message - var _result157 AuroraSchedulerManagerRollbackJobUpdateResult - if err = p.Client_().Call(ctx, "rollbackJobUpdate", &_args156, &_result157); err != nil { + var _args206 AuroraSchedulerManagerRollbackJobUpdateArgs + _args206.Key = key + _args206.Message = message + var _result207 AuroraSchedulerManagerRollbackJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "rollbackJobUpdate", &_args206, &_result207) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result157.GetSuccess(), nil + return _result207.GetSuccess(), nil } // Allows progress of the job update in case blockIfNoPulsesAfterMs is specified in @@ -21116,13 +23123,16 @@ func (p *AuroraSchedulerManagerClient) RollbackJobUpdate(ctx context.Context, ke // Parameters: // - Key func (p *AuroraSchedulerManagerClient) PulseJobUpdate(ctx context.Context, key *JobUpdateKey) (r *Response, err error) { - var _args158 AuroraSchedulerManagerPulseJobUpdateArgs - _args158.Key = key - var _result159 AuroraSchedulerManagerPulseJobUpdateResult - if err = p.Client_().Call(ctx, "pulseJobUpdate", &_args158, &_result159); err != nil { + var _args208 AuroraSchedulerManagerPulseJobUpdateArgs + _args208.Key = key + var _result209 AuroraSchedulerManagerPulseJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "pulseJobUpdate", &_args208, &_result209) + p.SetLastResponseMeta_(meta) + if err != nil { return } - return _result159.GetSuccess(), nil + return _result209.GetSuccess(), nil } type AuroraSchedulerManagerProcessor struct { @@ -21130,22 +23140,22 @@ type AuroraSchedulerManagerProcessor struct { } func NewAuroraSchedulerManagerProcessor(handler AuroraSchedulerManager) *AuroraSchedulerManagerProcessor { - self160 := &AuroraSchedulerManagerProcessor{NewReadOnlySchedulerProcessor(handler)} - self160.AddToProcessorMap("createJob", &auroraSchedulerManagerProcessorCreateJob{handler:handler}) - self160.AddToProcessorMap("scheduleCronJob", &auroraSchedulerManagerProcessorScheduleCronJob{handler:handler}) - self160.AddToProcessorMap("descheduleCronJob", &auroraSchedulerManagerProcessorDescheduleCronJob{handler:handler}) - self160.AddToProcessorMap("startCronJob", &auroraSchedulerManagerProcessorStartCronJob{handler:handler}) - self160.AddToProcessorMap("restartShards", &auroraSchedulerManagerProcessorRestartShards{handler:handler}) - self160.AddToProcessorMap("killTasks", &auroraSchedulerManagerProcessorKillTasks{handler:handler}) - self160.AddToProcessorMap("addInstances", &auroraSchedulerManagerProcessorAddInstances{handler:handler}) - self160.AddToProcessorMap("replaceCronTemplate", &auroraSchedulerManagerProcessorReplaceCronTemplate{handler:handler}) - self160.AddToProcessorMap("startJobUpdate", &auroraSchedulerManagerProcessorStartJobUpdate{handler:handler}) - self160.AddToProcessorMap("pauseJobUpdate", &auroraSchedulerManagerProcessorPauseJobUpdate{handler:handler}) - self160.AddToProcessorMap("resumeJobUpdate", &auroraSchedulerManagerProcessorResumeJobUpdate{handler:handler}) - self160.AddToProcessorMap("abortJobUpdate", &auroraSchedulerManagerProcessorAbortJobUpdate{handler:handler}) - self160.AddToProcessorMap("rollbackJobUpdate", &auroraSchedulerManagerProcessorRollbackJobUpdate{handler:handler}) - self160.AddToProcessorMap("pulseJobUpdate", &auroraSchedulerManagerProcessorPulseJobUpdate{handler:handler}) - return self160 + self210 := &AuroraSchedulerManagerProcessor{NewReadOnlySchedulerProcessor(handler)} + self210.AddToProcessorMap("createJob", &auroraSchedulerManagerProcessorCreateJob{handler:handler}) + self210.AddToProcessorMap("scheduleCronJob", &auroraSchedulerManagerProcessorScheduleCronJob{handler:handler}) + self210.AddToProcessorMap("descheduleCronJob", &auroraSchedulerManagerProcessorDescheduleCronJob{handler:handler}) + self210.AddToProcessorMap("startCronJob", &auroraSchedulerManagerProcessorStartCronJob{handler:handler}) + self210.AddToProcessorMap("restartShards", &auroraSchedulerManagerProcessorRestartShards{handler:handler}) + self210.AddToProcessorMap("killTasks", &auroraSchedulerManagerProcessorKillTasks{handler:handler}) + self210.AddToProcessorMap("addInstances", &auroraSchedulerManagerProcessorAddInstances{handler:handler}) + self210.AddToProcessorMap("replaceCronTemplate", &auroraSchedulerManagerProcessorReplaceCronTemplate{handler:handler}) + self210.AddToProcessorMap("startJobUpdate", &auroraSchedulerManagerProcessorStartJobUpdate{handler:handler}) + self210.AddToProcessorMap("pauseJobUpdate", &auroraSchedulerManagerProcessorPauseJobUpdate{handler:handler}) + self210.AddToProcessorMap("resumeJobUpdate", &auroraSchedulerManagerProcessorResumeJobUpdate{handler:handler}) + self210.AddToProcessorMap("abortJobUpdate", &auroraSchedulerManagerProcessorAbortJobUpdate{handler:handler}) + self210.AddToProcessorMap("rollbackJobUpdate", &auroraSchedulerManagerProcessorRollbackJobUpdate{handler:handler}) + self210.AddToProcessorMap("pulseJobUpdate", &auroraSchedulerManagerProcessorPulseJobUpdate{handler:handler}) + return self210 } type auroraSchedulerManagerProcessorCreateJob struct { @@ -21154,41 +23164,72 @@ type auroraSchedulerManagerProcessorCreateJob struct { func (p *auroraSchedulerManagerProcessorCreateJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerCreateJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("createJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "createJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerCreateJobResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.CreateJob(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing createJob: " + err2.Error()) - oprot.WriteMessageBegin("createJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "createJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("createJob", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "createJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21202,41 +23243,72 @@ type auroraSchedulerManagerProcessorScheduleCronJob struct { func (p *auroraSchedulerManagerProcessorScheduleCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerScheduleCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("scheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerScheduleCronJobResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.ScheduleCronJob(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing scheduleCronJob: " + err2.Error()) - oprot.WriteMessageBegin("scheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("scheduleCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21250,41 +23322,72 @@ type auroraSchedulerManagerProcessorDescheduleCronJob struct { func (p *auroraSchedulerManagerProcessorDescheduleCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerDescheduleCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("descheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerDescheduleCronJobResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.DescheduleCronJob(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing descheduleCronJob: " + err2.Error()) - oprot.WriteMessageBegin("descheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("descheduleCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21298,41 +23401,72 @@ type auroraSchedulerManagerProcessorStartCronJob struct { func (p *auroraSchedulerManagerProcessorStartCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerStartCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerStartCronJobResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.StartCronJob(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startCronJob: " + err2.Error()) - oprot.WriteMessageBegin("startCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "startCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("startCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21346,41 +23480,72 @@ type auroraSchedulerManagerProcessorRestartShards struct { func (p *auroraSchedulerManagerProcessorRestartShards) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerRestartShardsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("restartShards", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "restartShards", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerRestartShardsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.RestartShards(ctx, args.Job, args.ShardIds); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing restartShards: " + err2.Error()) - oprot.WriteMessageBegin("restartShards", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "restartShards", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("restartShards", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "restartShards", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21394,41 +23559,72 @@ type auroraSchedulerManagerProcessorKillTasks struct { func (p *auroraSchedulerManagerProcessorKillTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerKillTasksArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("killTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "killTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerKillTasksResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.KillTasks(ctx, args.Job, args.Instances, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing killTasks: " + err2.Error()) - oprot.WriteMessageBegin("killTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "killTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("killTasks", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "killTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21442,41 +23638,72 @@ type auroraSchedulerManagerProcessorAddInstances struct { func (p *auroraSchedulerManagerProcessorAddInstances) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerAddInstancesArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("addInstances", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "addInstances", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerAddInstancesResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.AddInstances(ctx, args.Key, args.Count); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing addInstances: " + err2.Error()) - oprot.WriteMessageBegin("addInstances", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "addInstances", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("addInstances", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "addInstances", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21490,41 +23717,72 @@ type auroraSchedulerManagerProcessorReplaceCronTemplate struct { func (p *auroraSchedulerManagerProcessorReplaceCronTemplate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerReplaceCronTemplateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("replaceCronTemplate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerReplaceCronTemplateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.ReplaceCronTemplate(ctx, args.Config); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing replaceCronTemplate: " + err2.Error()) - oprot.WriteMessageBegin("replaceCronTemplate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("replaceCronTemplate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21538,41 +23796,72 @@ type auroraSchedulerManagerProcessorStartJobUpdate struct { func (p *auroraSchedulerManagerProcessorStartJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerStartJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerStartJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.StartJobUpdate(ctx, args.Request, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("startJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("startJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21586,41 +23875,72 @@ type auroraSchedulerManagerProcessorPauseJobUpdate struct { func (p *auroraSchedulerManagerProcessorPauseJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerPauseJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("pauseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerPauseJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.PauseJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pauseJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("pauseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("pauseJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21634,41 +23954,72 @@ type auroraSchedulerManagerProcessorResumeJobUpdate struct { func (p *auroraSchedulerManagerProcessorResumeJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerResumeJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("resumeJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerResumeJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.ResumeJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing resumeJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("resumeJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("resumeJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21682,41 +24033,72 @@ type auroraSchedulerManagerProcessorAbortJobUpdate struct { func (p *auroraSchedulerManagerProcessorAbortJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerAbortJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("abortJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerAbortJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.AbortJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing abortJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("abortJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("abortJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21730,41 +24112,72 @@ type auroraSchedulerManagerProcessorRollbackJobUpdate struct { func (p *auroraSchedulerManagerProcessorRollbackJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerRollbackJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("rollbackJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerRollbackJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.RollbackJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing rollbackJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("rollbackJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("rollbackJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21778,41 +24191,72 @@ type auroraSchedulerManagerProcessorPulseJobUpdate struct { func (p *auroraSchedulerManagerProcessorPulseJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraSchedulerManagerPulseJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("pulseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraSchedulerManagerPulseJobUpdateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.PulseJobUpdate(ctx, args.Key); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pulseJobUpdate: " + err2.Error()) - oprot.WriteMessageBegin("pulseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("pulseJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -21844,14 +24288,14 @@ func (p *AuroraSchedulerManagerCreateJobArgs) IsSetDescription() bool { return p.Description != nil } -func (p *AuroraSchedulerManagerCreateJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerCreateJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -21859,57 +24303,57 @@ func (p *AuroraSchedulerManagerCreateJobArgs) Read(iprot thrift.TProtocol) error switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerCreateJobArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerCreateJobArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { + if err := p.Description.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) } return nil } -func (p *AuroraSchedulerManagerCreateJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("createJob_args"); err != nil { +func (p *AuroraSchedulerManagerCreateJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "createJob_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerCreateJobArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { +func (p *AuroraSchedulerManagerCreateJobArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } - if err := p.Description.Write(oprot); err != nil { + if err := p.Description.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } return err } @@ -21942,14 +24386,14 @@ func (p *AuroraSchedulerManagerCreateJobResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraSchedulerManagerCreateJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerCreateJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -21957,58 +24401,58 @@ func (p *AuroraSchedulerManagerCreateJobResult) Read(iprot thrift.TProtocol) err switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerCreateJobResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerCreateJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraSchedulerManagerCreateJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("createJob_result"); err != nil { +func (p *AuroraSchedulerManagerCreateJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "createJob_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerCreateJobResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraSchedulerManagerCreateJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -22042,14 +24486,14 @@ func (p *AuroraSchedulerManagerScheduleCronJobArgs) IsSetDescription() bool { return p.Description != nil } -func (p *AuroraSchedulerManagerScheduleCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerScheduleCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22057,57 +24501,57 @@ func (p *AuroraSchedulerManagerScheduleCronJobArgs) Read(iprot thrift.TProtocol) switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerScheduleCronJobArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { + if err := p.Description.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("scheduleCronJob_args"); err != nil { +func (p *AuroraSchedulerManagerScheduleCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "scheduleCronJob_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { +func (p *AuroraSchedulerManagerScheduleCronJobArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } - if err := p.Description.Write(oprot); err != nil { + if err := p.Description.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } return err } @@ -22140,14 +24584,14 @@ func (p *AuroraSchedulerManagerScheduleCronJobResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraSchedulerManagerScheduleCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerScheduleCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22155,58 +24599,58 @@ func (p *AuroraSchedulerManagerScheduleCronJobResult) Read(iprot thrift.TProtoco switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerScheduleCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("scheduleCronJob_result"); err != nil { +func (p *AuroraSchedulerManagerScheduleCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "scheduleCronJob_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerScheduleCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraSchedulerManagerScheduleCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -22241,14 +24685,14 @@ func (p *AuroraSchedulerManagerDescheduleCronJobArgs) IsSetJob() bool { return p.Job != nil } -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22256,57 +24700,57 @@ func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Read(iprot thrift.TProtoco switch fieldId { case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) ReadField4(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("descheduleCronJob_args"); err != nil { +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "descheduleCronJob_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 4); err != nil { +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) } return err } @@ -22339,14 +24783,14 @@ func (p *AuroraSchedulerManagerDescheduleCronJobResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraSchedulerManagerDescheduleCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerDescheduleCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22354,58 +24798,58 @@ func (p *AuroraSchedulerManagerDescheduleCronJobResult) Read(iprot thrift.TProto switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerDescheduleCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("descheduleCronJob_result"); err != nil { +func (p *AuroraSchedulerManagerDescheduleCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "descheduleCronJob_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerDescheduleCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraSchedulerManagerDescheduleCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -22440,14 +24884,14 @@ func (p *AuroraSchedulerManagerStartCronJobArgs) IsSetJob() bool { return p.Job != nil } -func (p *AuroraSchedulerManagerStartCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerStartCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22455,57 +24899,57 @@ func (p *AuroraSchedulerManagerStartCronJobArgs) Read(iprot thrift.TProtocol) er switch fieldId { case 4: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField4(iprot); err != nil { + if err := p.ReadField4(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobArgs) ReadField4(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerStartCronJobArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startCronJob_args"); err != nil { +func (p *AuroraSchedulerManagerStartCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startCronJob_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField4(oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 4); err != nil { +func (p *AuroraSchedulerManagerStartCronJobArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 4); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) } - if err := p.Job.Write(oprot); err != nil { + if err := p.Job.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) } return err } @@ -22538,14 +24982,14 @@ func (p *AuroraSchedulerManagerStartCronJobResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraSchedulerManagerStartCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerStartCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22553,58 +24997,58 @@ func (p *AuroraSchedulerManagerStartCronJobResult) Read(iprot thrift.TProtocol) switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerStartCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startCronJob_result"); err != nil { +func (p *AuroraSchedulerManagerStartCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startCronJob_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerStartCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraSchedulerManagerStartCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -22646,14 +25090,14 @@ func (p *AuroraSchedulerManagerRestartShardsArgs) IsSetJob() bool { return p.Job != nil } -func (p *AuroraSchedulerManagerRestartShardsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraSchedulerManagerRestartShardsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -22661,115 +25105,118 @@ func (p *AuroraSchedulerManagerRestartShardsArgs) Read(iprot thrift.TProtocol) e switch fieldId { case 5: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField5(iprot); err != nil { + if err := p.ReadField5(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.SET { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField5(iprot thrift.TProtocol) error { +func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { + if err := p.Job.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) } return nil } -func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() +func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) if err != nil { return thrift.PrependError("error reading set begin: ", err) } tSet := make([]int32, 0, size) p.ShardIds = tSet for i := 0; i < size; i ++ { -var _elem161 int32 - if v, err := iprot.ReadI32(); err != nil { +var _elem211 int32 + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 0: ", err) } else { - _elem161 = v + _elem211 = v } - p.ShardIds = append(p.ShardIds, _elem161) + p.ShardIds = append(p.ShardIds, _elem211) } - if err := iprot.ReadSetEnd(); err != nil { + if err := iprot.ReadSetEnd(ctx); err != nil { return thrift.PrependError("error reading set end: ", err) } return nil } -func (p *AuroraSchedulerManagerRestartShardsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("restartShards_args"); err != nil { +func (p *AuroraSchedulerManagerRestartShardsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "restartShards_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraSchedulerManagerRestartShardsArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("shardIds", thrift.SET, 3); err != nil { +func (p *AuroraSchedulerManagerRestartShardsArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "shardIds", thrift.SET, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:shardIds: ", p), err) } - if err := oprot.WriteSetBegin(thrift.I32, len(p.ShardIds)); err != nil { + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.ShardIds)); err != nil { return thrift.PrependError("error writing set begin: ", err) } for i := 0; i 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminSetQuotaResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.SetQuota(ctx, args.OwnerRole, args.Quota); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing setQuota: " + err2.Error()) - oprot.WriteMessageBegin("setQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "setQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("setQuota", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "setQuota", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25413,41 +27948,72 @@ type auroraAdminProcessorForceTaskState struct { func (p *auroraAdminProcessorForceTaskState) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminForceTaskStateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("forceTaskState", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminForceTaskStateResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.ForceTaskState(ctx, args.TaskId, args.Status); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing forceTaskState: " + err2.Error()) - oprot.WriteMessageBegin("forceTaskState", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("forceTaskState", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25461,41 +28027,72 @@ type auroraAdminProcessorPerformBackup struct { func (p *auroraAdminProcessorPerformBackup) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminPerformBackupArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("performBackup", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "performBackup", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminPerformBackupResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.PerformBackup(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing performBackup: " + err2.Error()) - oprot.WriteMessageBegin("performBackup", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "performBackup", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("performBackup", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "performBackup", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25509,41 +28106,72 @@ type auroraAdminProcessorListBackups struct { func (p *auroraAdminProcessorListBackups) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminListBackupsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("listBackups", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "listBackups", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminListBackupsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.ListBackups(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing listBackups: " + err2.Error()) - oprot.WriteMessageBegin("listBackups", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "listBackups", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("listBackups", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "listBackups", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25557,41 +28185,72 @@ type auroraAdminProcessorStageRecovery struct { func (p *auroraAdminProcessorStageRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminStageRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("stageRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminStageRecoveryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.StageRecovery(ctx, args.BackupId); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing stageRecovery: " + err2.Error()) - oprot.WriteMessageBegin("stageRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("stageRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25605,41 +28264,72 @@ type auroraAdminProcessorQueryRecovery struct { func (p *auroraAdminProcessorQueryRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminQueryRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("queryRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminQueryRecoveryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.QueryRecovery(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing queryRecovery: " + err2.Error()) - oprot.WriteMessageBegin("queryRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("queryRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25653,41 +28343,72 @@ type auroraAdminProcessorDeleteRecoveryTasks struct { func (p *auroraAdminProcessorDeleteRecoveryTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminDeleteRecoveryTasksArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminDeleteRecoveryTasksResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.DeleteRecoveryTasks(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing deleteRecoveryTasks: " + err2.Error()) - oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25701,41 +28422,72 @@ type auroraAdminProcessorCommitRecovery struct { func (p *auroraAdminProcessorCommitRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminCommitRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("commitRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminCommitRecoveryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.CommitRecovery(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing commitRecovery: " + err2.Error()) - oprot.WriteMessageBegin("commitRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("commitRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25749,41 +28501,72 @@ type auroraAdminProcessorUnloadRecovery struct { func (p *auroraAdminProcessorUnloadRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminUnloadRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("unloadRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminUnloadRecoveryResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.UnloadRecovery(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing unloadRecovery: " + err2.Error()) - oprot.WriteMessageBegin("unloadRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("unloadRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25797,41 +28580,72 @@ type auroraAdminProcessorStartMaintenance struct { func (p *auroraAdminProcessorStartMaintenance) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminStartMaintenanceArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminStartMaintenanceResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.StartMaintenance(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startMaintenance: " + err2.Error()) - oprot.WriteMessageBegin("startMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("startMaintenance", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25845,41 +28659,72 @@ type auroraAdminProcessorDrainHosts struct { func (p *auroraAdminProcessorDrainHosts) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminDrainHostsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("drainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "drainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminDrainHostsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.DrainHosts(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing drainHosts: " + err2.Error()) - oprot.WriteMessageBegin("drainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "drainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("drainHosts", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "drainHosts", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25893,41 +28738,72 @@ type auroraAdminProcessorMaintenanceStatus struct { func (p *auroraAdminProcessorMaintenanceStatus) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminMaintenanceStatusArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("maintenanceStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminMaintenanceStatusResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.MaintenanceStatus(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing maintenanceStatus: " + err2.Error()) - oprot.WriteMessageBegin("maintenanceStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("maintenanceStatus", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25941,41 +28817,72 @@ type auroraAdminProcessorEndMaintenance struct { func (p *auroraAdminProcessorEndMaintenance) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminEndMaintenanceArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("endMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminEndMaintenanceResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.EndMaintenance(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing endMaintenance: " + err2.Error()) - oprot.WriteMessageBegin("endMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("endMaintenance", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -25989,41 +28896,72 @@ type auroraAdminProcessorSlaDrainHosts struct { func (p *auroraAdminProcessorSlaDrainHosts) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminSlaDrainHostsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("slaDrainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminSlaDrainHostsResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.SlaDrainHosts(ctx, args.Hosts, args.DefaultSlaPolicy, args.TimeoutSecs); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing slaDrainHosts: " + err2.Error()) - oprot.WriteMessageBegin("slaDrainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("slaDrainHosts", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -26037,41 +28975,72 @@ type auroraAdminProcessorSnapshot struct { func (p *auroraAdminProcessorSnapshot) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminSnapshotArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("snapshot", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "snapshot", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminSnapshotResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.Snapshot(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing snapshot: " + err2.Error()) - oprot.WriteMessageBegin("snapshot", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "snapshot", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("snapshot", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "snapshot", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -26085,41 +29054,72 @@ type auroraAdminProcessorTriggerExplicitTaskReconciliation struct { func (p *auroraAdminProcessorTriggerExplicitTaskReconciliation) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminTriggerExplicitTaskReconciliationArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminTriggerExplicitTaskReconciliationResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.TriggerExplicitTaskReconciliation(ctx, args.Settings); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerExplicitTaskReconciliation: " + err2.Error()) - oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -26133,41 +29133,72 @@ type auroraAdminProcessorTriggerImplicitTaskReconciliation struct { func (p *auroraAdminProcessorTriggerImplicitTaskReconciliation) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminTriggerImplicitTaskReconciliationArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminTriggerImplicitTaskReconciliationResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.TriggerImplicitTaskReconciliation(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerImplicitTaskReconciliation: " + err2.Error()) - oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -26181,41 +29212,72 @@ type auroraAdminProcessorPruneTasks struct { func (p *auroraAdminProcessorPruneTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { args := AuroraAdminPruneTasksArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("pruneTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return false, err + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) } - iprot.ReadMessageEnd() result := AuroraAdminPruneTasksResult{} -var retval *Response - var err2 error + var retval *Response if retval, err2 = p.handler.PruneTasks(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pruneTasks: " + err2.Error()) - oprot.WriteMessageBegin("pruneTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() + oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) oprot.Flush(ctx) - return true, err2 + return true, thrift.WrapTException(err2) } else { result.Success = retval -} - if err2 = oprot.WriteMessageBegin("pruneTasks", thrift.REPLY, seqId); err2 != nil { - err = err2 } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) } if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 + err = thrift.WrapTException(err2) } if err != nil { return @@ -26253,14 +29315,14 @@ func (p *AuroraAdminSetQuotaArgs) IsSetQuota() bool { return p.Quota != nil } -func (p *AuroraAdminSetQuotaArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSetQuotaArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26268,41 +29330,41 @@ func (p *AuroraAdminSetQuotaArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSetQuotaArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AuroraAdminSetQuotaArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.OwnerRole = v @@ -26310,45 +29372,45 @@ func (p *AuroraAdminSetQuotaArgs) ReadField1(iprot thrift.TProtocol) error { return nil } -func (p *AuroraAdminSetQuotaArgs) ReadField2(iprot thrift.TProtocol) error { +func (p *AuroraAdminSetQuotaArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.Quota = &ResourceAggregate{} - if err := p.Quota.Read(iprot); err != nil { + if err := p.Quota.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) } return nil } -func (p *AuroraAdminSetQuotaArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("setQuota_args"); err != nil { +func (p *AuroraAdminSetQuotaArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "setQuota_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminSetQuotaArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { +func (p *AuroraAdminSetQuotaArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } return err } -func (p *AuroraAdminSetQuotaArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("quota", thrift.STRUCT, 2); err != nil { +func (p *AuroraAdminSetQuotaArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "quota", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:quota: ", p), err) } - if err := p.Quota.Write(oprot); err != nil { + if err := p.Quota.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:quota: ", p), err) } return err } @@ -26381,14 +29443,14 @@ func (p *AuroraAdminSetQuotaResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminSetQuotaResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSetQuotaResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26396,58 +29458,58 @@ func (p *AuroraAdminSetQuotaResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSetQuotaResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminSetQuotaResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminSetQuotaResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("setQuota_result"); err != nil { +func (p *AuroraAdminSetQuotaResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "setQuota_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminSetQuotaResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminSetQuotaResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -26480,14 +29542,14 @@ func (p *AuroraAdminForceTaskStateArgs) GetTaskId() string { func (p *AuroraAdminForceTaskStateArgs) GetStatus() ScheduleStatus { return p.Status } -func (p *AuroraAdminForceTaskStateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminForceTaskStateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26495,41 +29557,41 @@ func (p *AuroraAdminForceTaskStateArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminForceTaskStateArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AuroraAdminForceTaskStateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.TaskId = v @@ -26537,8 +29599,8 @@ func (p *AuroraAdminForceTaskStateArgs) ReadField1(iprot thrift.TProtocol) erro return nil } -func (p *AuroraAdminForceTaskStateArgs) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { +func (p *AuroraAdminForceTaskStateArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { return thrift.PrependError("error reading field 2: ", err) } else { temp := ScheduleStatus(v) @@ -26547,36 +29609,36 @@ func (p *AuroraAdminForceTaskStateArgs) ReadField2(iprot thrift.TProtocol) erro return nil } -func (p *AuroraAdminForceTaskStateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("forceTaskState_args"); err != nil { +func (p *AuroraAdminForceTaskStateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "forceTaskState_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminForceTaskStateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { +func (p *AuroraAdminForceTaskStateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } - if err := oprot.WriteString(string(p.TaskId)); err != nil { + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } return err } -func (p *AuroraAdminForceTaskStateArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { +func (p *AuroraAdminForceTaskStateArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } - if err := oprot.WriteI32(int32(p.Status)); err != nil { + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } return err } @@ -26609,14 +29671,14 @@ func (p *AuroraAdminForceTaskStateResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminForceTaskStateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminForceTaskStateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26624,58 +29686,58 @@ func (p *AuroraAdminForceTaskStateResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminForceTaskStateResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminForceTaskStateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminForceTaskStateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("forceTaskState_result"); err != nil { +func (p *AuroraAdminForceTaskStateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "forceTaskState_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminForceTaskStateResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminForceTaskStateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -26695,39 +29757,39 @@ func NewAuroraAdminPerformBackupArgs() *AuroraAdminPerformBackupArgs { return &AuroraAdminPerformBackupArgs{} } -func (p *AuroraAdminPerformBackupArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminPerformBackupArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminPerformBackupArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("performBackup_args"); err != nil { +func (p *AuroraAdminPerformBackupArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "performBackup_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -26760,14 +29822,14 @@ func (p *AuroraAdminPerformBackupResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminPerformBackupResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminPerformBackupResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26775,58 +29837,58 @@ func (p *AuroraAdminPerformBackupResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminPerformBackupResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminPerformBackupResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminPerformBackupResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("performBackup_result"); err != nil { +func (p *AuroraAdminPerformBackupResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "performBackup_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminPerformBackupResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminPerformBackupResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -26846,39 +29908,39 @@ func NewAuroraAdminListBackupsArgs() *AuroraAdminListBackupsArgs { return &AuroraAdminListBackupsArgs{} } -func (p *AuroraAdminListBackupsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminListBackupsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminListBackupsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("listBackups_args"); err != nil { +func (p *AuroraAdminListBackupsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "listBackups_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -26911,14 +29973,14 @@ func (p *AuroraAdminListBackupsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminListBackupsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminListBackupsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -26926,58 +29988,58 @@ func (p *AuroraAdminListBackupsResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminListBackupsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminListBackupsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminListBackupsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("listBackups_result"); err != nil { +func (p *AuroraAdminListBackupsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "listBackups_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminListBackupsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminListBackupsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27004,14 +30066,14 @@ func NewAuroraAdminStageRecoveryArgs() *AuroraAdminStageRecoveryArgs { func (p *AuroraAdminStageRecoveryArgs) GetBackupId() string { return p.BackupId } -func (p *AuroraAdminStageRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminStageRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27019,31 +30081,31 @@ func (p *AuroraAdminStageRecoveryArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminStageRecoveryArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { +func (p *AuroraAdminStageRecoveryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { return thrift.PrependError("error reading field 1: ", err) } else { p.BackupId = v @@ -27051,25 +30113,25 @@ func (p *AuroraAdminStageRecoveryArgs) ReadField1(iprot thrift.TProtocol) error return nil } -func (p *AuroraAdminStageRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("stageRecovery_args"); err != nil { +func (p *AuroraAdminStageRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "stageRecovery_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminStageRecoveryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("backupId", thrift.STRING, 1); err != nil { +func (p *AuroraAdminStageRecoveryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "backupId", thrift.STRING, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backupId: ", p), err) } - if err := oprot.WriteString(string(p.BackupId)); err != nil { + if err := oprot.WriteString(ctx, string(p.BackupId)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.backupId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:backupId: ", p), err) } return err } @@ -27102,14 +30164,14 @@ func (p *AuroraAdminStageRecoveryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminStageRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminStageRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27117,58 +30179,58 @@ func (p *AuroraAdminStageRecoveryResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminStageRecoveryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminStageRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminStageRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("stageRecovery_result"); err != nil { +func (p *AuroraAdminStageRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "stageRecovery_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminStageRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminStageRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27202,14 +30264,14 @@ func (p *AuroraAdminQueryRecoveryArgs) IsSetQuery() bool { return p.Query != nil } -func (p *AuroraAdminQueryRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminQueryRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27217,57 +30279,57 @@ func (p *AuroraAdminQueryRecoveryArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminQueryRecoveryArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminQueryRecoveryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *AuroraAdminQueryRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("queryRecovery_args"); err != nil { +func (p *AuroraAdminQueryRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "queryRecovery_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminQueryRecoveryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminQueryRecoveryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -27300,14 +30362,14 @@ func (p *AuroraAdminQueryRecoveryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminQueryRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminQueryRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27315,58 +30377,58 @@ func (p *AuroraAdminQueryRecoveryResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminQueryRecoveryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminQueryRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminQueryRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("queryRecovery_result"); err != nil { +func (p *AuroraAdminQueryRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "queryRecovery_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminQueryRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminQueryRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27400,14 +30462,14 @@ func (p *AuroraAdminDeleteRecoveryTasksArgs) IsSetQuery() bool { return p.Query != nil } -func (p *AuroraAdminDeleteRecoveryTasksArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminDeleteRecoveryTasksArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27415,57 +30477,57 @@ func (p *AuroraAdminDeleteRecoveryTasksArgs) Read(iprot thrift.TProtocol) error switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminDeleteRecoveryTasksArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("deleteRecoveryTasks_args"); err != nil { +func (p *AuroraAdminDeleteRecoveryTasksArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "deleteRecoveryTasks_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminDeleteRecoveryTasksArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -27498,14 +30560,14 @@ func (p *AuroraAdminDeleteRecoveryTasksResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminDeleteRecoveryTasksResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminDeleteRecoveryTasksResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27513,58 +30575,58 @@ func (p *AuroraAdminDeleteRecoveryTasksResult) Read(iprot thrift.TProtocol) erro switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminDeleteRecoveryTasksResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("deleteRecoveryTasks_result"); err != nil { +func (p *AuroraAdminDeleteRecoveryTasksResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "deleteRecoveryTasks_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminDeleteRecoveryTasksResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminDeleteRecoveryTasksResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27584,39 +30646,39 @@ func NewAuroraAdminCommitRecoveryArgs() *AuroraAdminCommitRecoveryArgs { return &AuroraAdminCommitRecoveryArgs{} } -func (p *AuroraAdminCommitRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminCommitRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminCommitRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("commitRecovery_args"); err != nil { +func (p *AuroraAdminCommitRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "commitRecovery_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -27649,14 +30711,14 @@ func (p *AuroraAdminCommitRecoveryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminCommitRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminCommitRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27664,58 +30726,58 @@ func (p *AuroraAdminCommitRecoveryResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminCommitRecoveryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminCommitRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminCommitRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("commitRecovery_result"); err != nil { +func (p *AuroraAdminCommitRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "commitRecovery_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminCommitRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminCommitRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27735,39 +30797,39 @@ func NewAuroraAdminUnloadRecoveryArgs() *AuroraAdminUnloadRecoveryArgs { return &AuroraAdminUnloadRecoveryArgs{} } -func (p *AuroraAdminUnloadRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminUnloadRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminUnloadRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("unloadRecovery_args"); err != nil { +func (p *AuroraAdminUnloadRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "unloadRecovery_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -27800,14 +30862,14 @@ func (p *AuroraAdminUnloadRecoveryResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminUnloadRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminUnloadRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27815,58 +30877,58 @@ func (p *AuroraAdminUnloadRecoveryResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminUnloadRecoveryResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminUnloadRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminUnloadRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("unloadRecovery_result"); err != nil { +func (p *AuroraAdminUnloadRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "unloadRecovery_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminUnloadRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminUnloadRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -27900,14 +30962,14 @@ func (p *AuroraAdminStartMaintenanceArgs) IsSetHosts() bool { return p.Hosts != nil } -func (p *AuroraAdminStartMaintenanceArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminStartMaintenanceArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -27915,57 +30977,57 @@ func (p *AuroraAdminStartMaintenanceArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminStartMaintenanceArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminStartMaintenanceArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { + if err := p.Hosts.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) } return nil } -func (p *AuroraAdminStartMaintenanceArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startMaintenance_args"); err != nil { +func (p *AuroraAdminStartMaintenanceArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startMaintenance_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminStartMaintenanceArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminStartMaintenanceArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } - if err := p.Hosts.Write(oprot); err != nil { + if err := p.Hosts.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } return err } @@ -27998,14 +31060,14 @@ func (p *AuroraAdminStartMaintenanceResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminStartMaintenanceResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminStartMaintenanceResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28013,58 +31075,58 @@ func (p *AuroraAdminStartMaintenanceResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminStartMaintenanceResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminStartMaintenanceResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminStartMaintenanceResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startMaintenance_result"); err != nil { +func (p *AuroraAdminStartMaintenanceResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startMaintenance_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminStartMaintenanceResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminStartMaintenanceResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -28098,14 +31160,14 @@ func (p *AuroraAdminDrainHostsArgs) IsSetHosts() bool { return p.Hosts != nil } -func (p *AuroraAdminDrainHostsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminDrainHostsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28113,57 +31175,57 @@ func (p *AuroraAdminDrainHostsArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminDrainHostsArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminDrainHostsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { + if err := p.Hosts.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) } return nil } -func (p *AuroraAdminDrainHostsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("drainHosts_args"); err != nil { +func (p *AuroraAdminDrainHostsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "drainHosts_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminDrainHostsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminDrainHostsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } - if err := p.Hosts.Write(oprot); err != nil { + if err := p.Hosts.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } return err } @@ -28196,14 +31258,14 @@ func (p *AuroraAdminDrainHostsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminDrainHostsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminDrainHostsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28211,58 +31273,58 @@ func (p *AuroraAdminDrainHostsResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminDrainHostsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminDrainHostsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminDrainHostsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("drainHosts_result"); err != nil { +func (p *AuroraAdminDrainHostsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "drainHosts_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminDrainHostsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminDrainHostsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -28296,14 +31358,14 @@ func (p *AuroraAdminMaintenanceStatusArgs) IsSetHosts() bool { return p.Hosts != nil } -func (p *AuroraAdminMaintenanceStatusArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminMaintenanceStatusArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28311,57 +31373,57 @@ func (p *AuroraAdminMaintenanceStatusArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminMaintenanceStatusArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminMaintenanceStatusArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { + if err := p.Hosts.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) } return nil } -func (p *AuroraAdminMaintenanceStatusArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("maintenanceStatus_args"); err != nil { +func (p *AuroraAdminMaintenanceStatusArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "maintenanceStatus_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminMaintenanceStatusArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminMaintenanceStatusArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } - if err := p.Hosts.Write(oprot); err != nil { + if err := p.Hosts.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } return err } @@ -28394,14 +31456,14 @@ func (p *AuroraAdminMaintenanceStatusResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminMaintenanceStatusResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminMaintenanceStatusResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28409,58 +31471,58 @@ func (p *AuroraAdminMaintenanceStatusResult) Read(iprot thrift.TProtocol) error switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminMaintenanceStatusResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminMaintenanceStatusResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminMaintenanceStatusResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("maintenanceStatus_result"); err != nil { +func (p *AuroraAdminMaintenanceStatusResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "maintenanceStatus_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminMaintenanceStatusResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminMaintenanceStatusResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -28494,14 +31556,14 @@ func (p *AuroraAdminEndMaintenanceArgs) IsSetHosts() bool { return p.Hosts != nil } -func (p *AuroraAdminEndMaintenanceArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminEndMaintenanceArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28509,57 +31571,57 @@ func (p *AuroraAdminEndMaintenanceArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminEndMaintenanceArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminEndMaintenanceArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { + if err := p.Hosts.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) } return nil } -func (p *AuroraAdminEndMaintenanceArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("endMaintenance_args"); err != nil { +func (p *AuroraAdminEndMaintenanceArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "endMaintenance_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminEndMaintenanceArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminEndMaintenanceArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } - if err := p.Hosts.Write(oprot); err != nil { + if err := p.Hosts.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } return err } @@ -28592,14 +31654,14 @@ func (p *AuroraAdminEndMaintenanceResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminEndMaintenanceResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminEndMaintenanceResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28607,58 +31669,58 @@ func (p *AuroraAdminEndMaintenanceResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminEndMaintenanceResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminEndMaintenanceResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminEndMaintenanceResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("endMaintenance_result"); err != nil { +func (p *AuroraAdminEndMaintenanceResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "endMaintenance_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminEndMaintenanceResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminEndMaintenanceResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -28711,14 +31773,14 @@ func (p *AuroraAdminSlaDrainHostsArgs) IsSetDefaultSlaPolicy() bool { return p.DefaultSlaPolicy != nil } -func (p *AuroraAdminSlaDrainHostsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28726,67 +31788,67 @@ func (p *AuroraAdminSlaDrainHostsArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 2: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField2(iprot); err != nil { + if err := p.ReadField2(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } case 3: if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { + if err := p.ReadField3(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSlaDrainHostsArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminSlaDrainHostsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { + if err := p.Hosts.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) } return nil } -func (p *AuroraAdminSlaDrainHostsArgs) ReadField2(iprot thrift.TProtocol) error { +func (p *AuroraAdminSlaDrainHostsArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { p.DefaultSlaPolicy = &SlaPolicy{} - if err := p.DefaultSlaPolicy.Read(iprot); err != nil { + if err := p.DefaultSlaPolicy.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DefaultSlaPolicy), err) } return nil } -func (p *AuroraAdminSlaDrainHostsArgs) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { return thrift.PrependError("error reading field 3: ", err) } else { p.TimeoutSecs = v @@ -28794,49 +31856,49 @@ func (p *AuroraAdminSlaDrainHostsArgs) ReadField3(iprot thrift.TProtocol) error return nil } -func (p *AuroraAdminSlaDrainHostsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("slaDrainHosts_args"); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "slaDrainHosts_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminSlaDrainHostsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } - if err := p.Hosts.Write(oprot); err != nil { + if err := p.Hosts.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } return err } -func (p *AuroraAdminSlaDrainHostsArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("defaultSlaPolicy", thrift.STRUCT, 2); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultSlaPolicy", thrift.STRUCT, 2); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultSlaPolicy: ", p), err) } - if err := p.DefaultSlaPolicy.Write(oprot); err != nil { + if err := p.DefaultSlaPolicy.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DefaultSlaPolicy), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultSlaPolicy: ", p), err) } return err } -func (p *AuroraAdminSlaDrainHostsArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timeoutSecs", thrift.I64, 3); err != nil { +func (p *AuroraAdminSlaDrainHostsArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timeoutSecs", thrift.I64, 3); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timeoutSecs: ", p), err) } - if err := oprot.WriteI64(int64(p.TimeoutSecs)); err != nil { + if err := oprot.WriteI64(ctx, int64(p.TimeoutSecs)); err != nil { return thrift.PrependError(fmt.Sprintf("%T.timeoutSecs (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timeoutSecs: ", p), err) } return err } @@ -28869,14 +31931,14 @@ func (p *AuroraAdminSlaDrainHostsResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminSlaDrainHostsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSlaDrainHostsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -28884,58 +31946,58 @@ func (p *AuroraAdminSlaDrainHostsResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSlaDrainHostsResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminSlaDrainHostsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminSlaDrainHostsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("slaDrainHosts_result"); err != nil { +func (p *AuroraAdminSlaDrainHostsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "slaDrainHosts_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminSlaDrainHostsResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminSlaDrainHostsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -28955,39 +32017,39 @@ func NewAuroraAdminSnapshotArgs() *AuroraAdminSnapshotArgs { return &AuroraAdminSnapshotArgs{} } -func (p *AuroraAdminSnapshotArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSnapshotArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSnapshotArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("snapshot_args"); err != nil { +func (p *AuroraAdminSnapshotArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "snapshot_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -29020,14 +32082,14 @@ func (p *AuroraAdminSnapshotResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminSnapshotResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminSnapshotResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29035,58 +32097,58 @@ func (p *AuroraAdminSnapshotResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminSnapshotResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminSnapshotResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminSnapshotResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("snapshot_result"); err != nil { +func (p *AuroraAdminSnapshotResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "snapshot_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminSnapshotResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminSnapshotResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -29120,14 +32182,14 @@ func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) IsSetSettings() bool return p.Settings != nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29135,57 +32197,57 @@ func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Read(iprot thrift.TPr switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Settings = &ExplicitReconciliationSettings{} - if err := p.Settings.Read(iprot); err != nil { + if err := p.Settings.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerExplicitTaskReconciliation_args"); err != nil { +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerExplicitTaskReconciliation_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:settings: ", p), err) } - if err := p.Settings.Write(oprot); err != nil { + if err := p.Settings.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:settings: ", p), err) } return err } @@ -29218,14 +32280,14 @@ func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) IsSetSuccess() bool return p.Success != nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29233,58 +32295,58 @@ func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Read(iprot thrift.T switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerExplicitTaskReconciliation_result"); err != nil { +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerExplicitTaskReconciliation_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -29304,39 +32366,39 @@ func NewAuroraAdminTriggerImplicitTaskReconciliationArgs() *AuroraAdminTriggerIm return &AuroraAdminTriggerImplicitTaskReconciliationArgs{} } -func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } if fieldTypeId == thrift.STOP { break; } - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerImplicitTaskReconciliation_args"); err != nil { +func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerImplicitTaskReconciliation_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } @@ -29369,14 +32431,14 @@ func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) IsSetSuccess() bool return p.Success != nil } -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29384,58 +32446,58 @@ func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Read(iprot thrift.T switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerImplicitTaskReconciliation_result"); err != nil { +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerImplicitTaskReconciliation_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err @@ -29469,14 +32531,14 @@ func (p *AuroraAdminPruneTasksArgs) IsSetQuery() bool { return p.Query != nil } -func (p *AuroraAdminPruneTasksArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminPruneTasksArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29484,57 +32546,57 @@ func (p *AuroraAdminPruneTasksArgs) Read(iprot thrift.TProtocol) error { switch fieldId { case 1: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { + if err := p.ReadField1(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminPruneTasksArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *AuroraAdminPruneTasksArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { + if err := p.Query.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) } return nil } -func (p *AuroraAdminPruneTasksArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pruneTasks_args"); err != nil { +func (p *AuroraAdminPruneTasksArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pruneTasks_args"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField1(oprot); err != nil { return err } + if err := p.writeField1(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminPruneTasksArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { +func (p *AuroraAdminPruneTasksArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } - if err := p.Query.Write(oprot); err != nil { + if err := p.Query.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } return err } @@ -29567,14 +32629,14 @@ func (p *AuroraAdminPruneTasksResult) IsSetSuccess() bool { return p.Success != nil } -func (p *AuroraAdminPruneTasksResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { +func (p *AuroraAdminPruneTasksResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) } for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) if err != nil { return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) } @@ -29582,58 +32644,58 @@ func (p *AuroraAdminPruneTasksResult) Read(iprot thrift.TProtocol) error { switch fieldId { case 0: if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { + if err := p.ReadField0(ctx, iprot); err != nil { return err } } else { - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } default: - if err := iprot.Skip(fieldTypeId); err != nil { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { return err } } - if err := iprot.ReadFieldEnd(); err != nil { + if err := iprot.ReadFieldEnd(ctx); err != nil { return err } } - if err := iprot.ReadStructEnd(); err != nil { + if err := iprot.ReadStructEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } return nil } -func (p *AuroraAdminPruneTasksResult) ReadField0(iprot thrift.TProtocol) error { +func (p *AuroraAdminPruneTasksResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { + if err := p.Success.Read(ctx, iprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) } return nil } -func (p *AuroraAdminPruneTasksResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pruneTasks_result"); err != nil { +func (p *AuroraAdminPruneTasksResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pruneTasks_result"); err != nil { return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } if p != nil { - if err := p.writeField0(oprot); err != nil { return err } + if err := p.writeField0(ctx, oprot); err != nil { return err } } - if err := oprot.WriteFieldStop(); err != nil { + if err := oprot.WriteFieldStop(ctx); err != nil { return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { + if err := oprot.WriteStructEnd(ctx); err != nil { return thrift.PrependError("write struct stop error: ", err) } return nil } -func (p *AuroraAdminPruneTasksResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *AuroraAdminPruneTasksResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { + if err := p.Success.Write(ctx, oprot); err != nil { return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) } - if err := oprot.WriteFieldEnd(); err != nil { + if err := oprot.WriteFieldEnd(ctx); err != nil { return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } } return err diff --git a/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go b/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go index 9bd8b7e..d2d4441 100755 --- a/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go +++ b/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go @@ -1,5 +1,4 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main @@ -196,19 +195,19 @@ func main() { } argvalue0 := flag.Arg(1) value0 := argvalue0 - arg355 := flag.Arg(2) - mbTrans356 := thrift.NewTMemoryBufferLen(len(arg355)) - defer mbTrans356.Close() - _, err357 := mbTrans356.WriteString(arg355) - if err357 != nil { + arg405 := flag.Arg(2) + mbTrans406 := thrift.NewTMemoryBufferLen(len(arg405)) + defer mbTrans406.Close() + _, err407 := mbTrans406.WriteString(arg405) + if err407 != nil { Usage() return } - factory358 := thrift.NewTJSONProtocolFactory() - jsProt359 := factory358.GetProtocol(mbTrans356) + factory408 := thrift.NewTJSONProtocolFactory() + jsProt409 := factory408.GetProtocol(mbTrans406) argvalue1 := aurora.NewResourceAggregate() - err360 := argvalue1.Read(jsProt359) - if err360 != nil { + err410 := argvalue1.Read(context.Background(), jsProt409) + if err410 != nil { Usage() return } @@ -264,19 +263,19 @@ func main() { fmt.Fprintln(os.Stderr, "QueryRecovery requires 1 args") flag.Usage() } - arg363 := flag.Arg(1) - mbTrans364 := thrift.NewTMemoryBufferLen(len(arg363)) - defer mbTrans364.Close() - _, err365 := mbTrans364.WriteString(arg363) - if err365 != nil { + arg413 := flag.Arg(1) + mbTrans414 := thrift.NewTMemoryBufferLen(len(arg413)) + defer mbTrans414.Close() + _, err415 := mbTrans414.WriteString(arg413) + if err415 != nil { Usage() return } - factory366 := thrift.NewTJSONProtocolFactory() - jsProt367 := factory366.GetProtocol(mbTrans364) + factory416 := thrift.NewTJSONProtocolFactory() + jsProt417 := factory416.GetProtocol(mbTrans414) argvalue0 := aurora.NewTaskQuery() - err368 := argvalue0.Read(jsProt367) - if err368 != nil { + err418 := argvalue0.Read(context.Background(), jsProt417) + if err418 != nil { Usage() return } @@ -289,19 +288,19 @@ func main() { fmt.Fprintln(os.Stderr, "DeleteRecoveryTasks requires 1 args") flag.Usage() } - arg369 := flag.Arg(1) - mbTrans370 := thrift.NewTMemoryBufferLen(len(arg369)) - defer mbTrans370.Close() - _, err371 := mbTrans370.WriteString(arg369) - if err371 != nil { + arg419 := flag.Arg(1) + mbTrans420 := thrift.NewTMemoryBufferLen(len(arg419)) + defer mbTrans420.Close() + _, err421 := mbTrans420.WriteString(arg419) + if err421 != nil { Usage() return } - factory372 := thrift.NewTJSONProtocolFactory() - jsProt373 := factory372.GetProtocol(mbTrans370) + factory422 := thrift.NewTJSONProtocolFactory() + jsProt423 := factory422.GetProtocol(mbTrans420) argvalue0 := aurora.NewTaskQuery() - err374 := argvalue0.Read(jsProt373) - if err374 != nil { + err424 := argvalue0.Read(context.Background(), jsProt423) + if err424 != nil { Usage() return } @@ -330,19 +329,19 @@ func main() { fmt.Fprintln(os.Stderr, "StartMaintenance requires 1 args") flag.Usage() } - arg375 := flag.Arg(1) - mbTrans376 := thrift.NewTMemoryBufferLen(len(arg375)) - defer mbTrans376.Close() - _, err377 := mbTrans376.WriteString(arg375) - if err377 != nil { + arg425 := flag.Arg(1) + mbTrans426 := thrift.NewTMemoryBufferLen(len(arg425)) + defer mbTrans426.Close() + _, err427 := mbTrans426.WriteString(arg425) + if err427 != nil { Usage() return } - factory378 := thrift.NewTJSONProtocolFactory() - jsProt379 := factory378.GetProtocol(mbTrans376) + factory428 := thrift.NewTJSONProtocolFactory() + jsProt429 := factory428.GetProtocol(mbTrans426) argvalue0 := aurora.NewHosts() - err380 := argvalue0.Read(jsProt379) - if err380 != nil { + err430 := argvalue0.Read(context.Background(), jsProt429) + if err430 != nil { Usage() return } @@ -355,19 +354,19 @@ func main() { fmt.Fprintln(os.Stderr, "DrainHosts requires 1 args") flag.Usage() } - arg381 := flag.Arg(1) - mbTrans382 := thrift.NewTMemoryBufferLen(len(arg381)) - defer mbTrans382.Close() - _, err383 := mbTrans382.WriteString(arg381) - if err383 != nil { + arg431 := flag.Arg(1) + mbTrans432 := thrift.NewTMemoryBufferLen(len(arg431)) + defer mbTrans432.Close() + _, err433 := mbTrans432.WriteString(arg431) + if err433 != nil { Usage() return } - factory384 := thrift.NewTJSONProtocolFactory() - jsProt385 := factory384.GetProtocol(mbTrans382) + factory434 := thrift.NewTJSONProtocolFactory() + jsProt435 := factory434.GetProtocol(mbTrans432) argvalue0 := aurora.NewHosts() - err386 := argvalue0.Read(jsProt385) - if err386 != nil { + err436 := argvalue0.Read(context.Background(), jsProt435) + if err436 != nil { Usage() return } @@ -380,19 +379,19 @@ func main() { fmt.Fprintln(os.Stderr, "MaintenanceStatus requires 1 args") flag.Usage() } - arg387 := flag.Arg(1) - mbTrans388 := thrift.NewTMemoryBufferLen(len(arg387)) - defer mbTrans388.Close() - _, err389 := mbTrans388.WriteString(arg387) - if err389 != nil { + arg437 := flag.Arg(1) + mbTrans438 := thrift.NewTMemoryBufferLen(len(arg437)) + defer mbTrans438.Close() + _, err439 := mbTrans438.WriteString(arg437) + if err439 != nil { Usage() return } - factory390 := thrift.NewTJSONProtocolFactory() - jsProt391 := factory390.GetProtocol(mbTrans388) + factory440 := thrift.NewTJSONProtocolFactory() + jsProt441 := factory440.GetProtocol(mbTrans438) argvalue0 := aurora.NewHosts() - err392 := argvalue0.Read(jsProt391) - if err392 != nil { + err442 := argvalue0.Read(context.Background(), jsProt441) + if err442 != nil { Usage() return } @@ -405,19 +404,19 @@ func main() { fmt.Fprintln(os.Stderr, "EndMaintenance requires 1 args") flag.Usage() } - arg393 := flag.Arg(1) - mbTrans394 := thrift.NewTMemoryBufferLen(len(arg393)) - defer mbTrans394.Close() - _, err395 := mbTrans394.WriteString(arg393) - if err395 != nil { + arg443 := flag.Arg(1) + mbTrans444 := thrift.NewTMemoryBufferLen(len(arg443)) + defer mbTrans444.Close() + _, err445 := mbTrans444.WriteString(arg443) + if err445 != nil { Usage() return } - factory396 := thrift.NewTJSONProtocolFactory() - jsProt397 := factory396.GetProtocol(mbTrans394) + factory446 := thrift.NewTJSONProtocolFactory() + jsProt447 := factory446.GetProtocol(mbTrans444) argvalue0 := aurora.NewHosts() - err398 := argvalue0.Read(jsProt397) - if err398 != nil { + err448 := argvalue0.Read(context.Background(), jsProt447) + if err448 != nil { Usage() return } @@ -430,42 +429,42 @@ func main() { fmt.Fprintln(os.Stderr, "SlaDrainHosts requires 3 args") flag.Usage() } - arg399 := flag.Arg(1) - mbTrans400 := thrift.NewTMemoryBufferLen(len(arg399)) - defer mbTrans400.Close() - _, err401 := mbTrans400.WriteString(arg399) - if err401 != nil { + arg449 := flag.Arg(1) + mbTrans450 := thrift.NewTMemoryBufferLen(len(arg449)) + defer mbTrans450.Close() + _, err451 := mbTrans450.WriteString(arg449) + if err451 != nil { Usage() return } - factory402 := thrift.NewTJSONProtocolFactory() - jsProt403 := factory402.GetProtocol(mbTrans400) + factory452 := thrift.NewTJSONProtocolFactory() + jsProt453 := factory452.GetProtocol(mbTrans450) argvalue0 := aurora.NewHosts() - err404 := argvalue0.Read(jsProt403) - if err404 != nil { + err454 := argvalue0.Read(context.Background(), jsProt453) + if err454 != nil { Usage() return } value0 := argvalue0 - arg405 := flag.Arg(2) - mbTrans406 := thrift.NewTMemoryBufferLen(len(arg405)) - defer mbTrans406.Close() - _, err407 := mbTrans406.WriteString(arg405) - if err407 != nil { + arg455 := flag.Arg(2) + mbTrans456 := thrift.NewTMemoryBufferLen(len(arg455)) + defer mbTrans456.Close() + _, err457 := mbTrans456.WriteString(arg455) + if err457 != nil { Usage() return } - factory408 := thrift.NewTJSONProtocolFactory() - jsProt409 := factory408.GetProtocol(mbTrans406) + factory458 := thrift.NewTJSONProtocolFactory() + jsProt459 := factory458.GetProtocol(mbTrans456) argvalue1 := aurora.NewSlaPolicy() - err410 := argvalue1.Read(jsProt409) - if err410 != nil { + err460 := argvalue1.Read(context.Background(), jsProt459) + if err460 != nil { Usage() return } value1 := argvalue1 - argvalue2, err411 := (strconv.ParseInt(flag.Arg(3), 10, 64)) - if err411 != nil { + argvalue2, err461 := (strconv.ParseInt(flag.Arg(3), 10, 64)) + if err461 != nil { Usage() return } @@ -486,19 +485,19 @@ func main() { fmt.Fprintln(os.Stderr, "TriggerExplicitTaskReconciliation requires 1 args") flag.Usage() } - arg412 := flag.Arg(1) - mbTrans413 := thrift.NewTMemoryBufferLen(len(arg412)) - defer mbTrans413.Close() - _, err414 := mbTrans413.WriteString(arg412) - if err414 != nil { + arg462 := flag.Arg(1) + mbTrans463 := thrift.NewTMemoryBufferLen(len(arg462)) + defer mbTrans463.Close() + _, err464 := mbTrans463.WriteString(arg462) + if err464 != nil { Usage() return } - factory415 := thrift.NewTJSONProtocolFactory() - jsProt416 := factory415.GetProtocol(mbTrans413) + factory465 := thrift.NewTJSONProtocolFactory() + jsProt466 := factory465.GetProtocol(mbTrans463) argvalue0 := aurora.NewExplicitReconciliationSettings() - err417 := argvalue0.Read(jsProt416) - if err417 != nil { + err467 := argvalue0.Read(context.Background(), jsProt466) + if err467 != nil { Usage() return } @@ -519,19 +518,19 @@ func main() { fmt.Fprintln(os.Stderr, "PruneTasks requires 1 args") flag.Usage() } - arg418 := flag.Arg(1) - mbTrans419 := thrift.NewTMemoryBufferLen(len(arg418)) - defer mbTrans419.Close() - _, err420 := mbTrans419.WriteString(arg418) - if err420 != nil { + arg468 := flag.Arg(1) + mbTrans469 := thrift.NewTMemoryBufferLen(len(arg468)) + defer mbTrans469.Close() + _, err470 := mbTrans469.WriteString(arg468) + if err470 != nil { Usage() return } - factory421 := thrift.NewTJSONProtocolFactory() - jsProt422 := factory421.GetProtocol(mbTrans419) + factory471 := thrift.NewTJSONProtocolFactory() + jsProt472 := factory471.GetProtocol(mbTrans469) argvalue0 := aurora.NewTaskQuery() - err423 := argvalue0.Read(jsProt422) - if err423 != nil { + err473 := argvalue0.Read(context.Background(), jsProt472) + if err473 != nil { Usage() return } @@ -544,19 +543,19 @@ func main() { fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") flag.Usage() } - arg424 := flag.Arg(1) - mbTrans425 := thrift.NewTMemoryBufferLen(len(arg424)) - defer mbTrans425.Close() - _, err426 := mbTrans425.WriteString(arg424) - if err426 != nil { + arg474 := flag.Arg(1) + mbTrans475 := thrift.NewTMemoryBufferLen(len(arg474)) + defer mbTrans475.Close() + _, err476 := mbTrans475.WriteString(arg474) + if err476 != nil { Usage() return } - factory427 := thrift.NewTJSONProtocolFactory() - jsProt428 := factory427.GetProtocol(mbTrans425) + factory477 := thrift.NewTJSONProtocolFactory() + jsProt478 := factory477.GetProtocol(mbTrans475) argvalue0 := aurora.NewJobConfiguration() - err429 := argvalue0.Read(jsProt428) - if err429 != nil { + err479 := argvalue0.Read(context.Background(), jsProt478) + if err479 != nil { Usage() return } @@ -569,19 +568,19 @@ func main() { fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") flag.Usage() } - arg430 := flag.Arg(1) - mbTrans431 := thrift.NewTMemoryBufferLen(len(arg430)) - defer mbTrans431.Close() - _, err432 := mbTrans431.WriteString(arg430) - if err432 != nil { + arg480 := flag.Arg(1) + mbTrans481 := thrift.NewTMemoryBufferLen(len(arg480)) + defer mbTrans481.Close() + _, err482 := mbTrans481.WriteString(arg480) + if err482 != nil { Usage() return } - factory433 := thrift.NewTJSONProtocolFactory() - jsProt434 := factory433.GetProtocol(mbTrans431) + factory483 := thrift.NewTJSONProtocolFactory() + jsProt484 := factory483.GetProtocol(mbTrans481) argvalue0 := aurora.NewJobConfiguration() - err435 := argvalue0.Read(jsProt434) - if err435 != nil { + err485 := argvalue0.Read(context.Background(), jsProt484) + if err485 != nil { Usage() return } @@ -594,19 +593,19 @@ func main() { fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") flag.Usage() } - arg436 := flag.Arg(1) - mbTrans437 := thrift.NewTMemoryBufferLen(len(arg436)) - defer mbTrans437.Close() - _, err438 := mbTrans437.WriteString(arg436) - if err438 != nil { + arg486 := flag.Arg(1) + mbTrans487 := thrift.NewTMemoryBufferLen(len(arg486)) + defer mbTrans487.Close() + _, err488 := mbTrans487.WriteString(arg486) + if err488 != nil { Usage() return } - factory439 := thrift.NewTJSONProtocolFactory() - jsProt440 := factory439.GetProtocol(mbTrans437) + factory489 := thrift.NewTJSONProtocolFactory() + jsProt490 := factory489.GetProtocol(mbTrans487) argvalue0 := aurora.NewJobKey() - err441 := argvalue0.Read(jsProt440) - if err441 != nil { + err491 := argvalue0.Read(context.Background(), jsProt490) + if err491 != nil { Usage() return } @@ -619,19 +618,19 @@ func main() { fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") flag.Usage() } - arg442 := flag.Arg(1) - mbTrans443 := thrift.NewTMemoryBufferLen(len(arg442)) - defer mbTrans443.Close() - _, err444 := mbTrans443.WriteString(arg442) - if err444 != nil { + arg492 := flag.Arg(1) + mbTrans493 := thrift.NewTMemoryBufferLen(len(arg492)) + defer mbTrans493.Close() + _, err494 := mbTrans493.WriteString(arg492) + if err494 != nil { Usage() return } - factory445 := thrift.NewTJSONProtocolFactory() - jsProt446 := factory445.GetProtocol(mbTrans443) + factory495 := thrift.NewTJSONProtocolFactory() + jsProt496 := factory495.GetProtocol(mbTrans493) argvalue0 := aurora.NewJobKey() - err447 := argvalue0.Read(jsProt446) - if err447 != nil { + err497 := argvalue0.Read(context.Background(), jsProt496) + if err497 != nil { Usage() return } @@ -644,36 +643,36 @@ func main() { fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") flag.Usage() } - arg448 := flag.Arg(1) - mbTrans449 := thrift.NewTMemoryBufferLen(len(arg448)) - defer mbTrans449.Close() - _, err450 := mbTrans449.WriteString(arg448) - if err450 != nil { + arg498 := flag.Arg(1) + mbTrans499 := thrift.NewTMemoryBufferLen(len(arg498)) + defer mbTrans499.Close() + _, err500 := mbTrans499.WriteString(arg498) + if err500 != nil { Usage() return } - factory451 := thrift.NewTJSONProtocolFactory() - jsProt452 := factory451.GetProtocol(mbTrans449) + factory501 := thrift.NewTJSONProtocolFactory() + jsProt502 := factory501.GetProtocol(mbTrans499) argvalue0 := aurora.NewJobKey() - err453 := argvalue0.Read(jsProt452) - if err453 != nil { + err503 := argvalue0.Read(context.Background(), jsProt502) + if err503 != nil { Usage() return } value0 := argvalue0 - arg454 := flag.Arg(2) - mbTrans455 := thrift.NewTMemoryBufferLen(len(arg454)) - defer mbTrans455.Close() - _, err456 := mbTrans455.WriteString(arg454) - if err456 != nil { + arg504 := flag.Arg(2) + mbTrans505 := thrift.NewTMemoryBufferLen(len(arg504)) + defer mbTrans505.Close() + _, err506 := mbTrans505.WriteString(arg504) + if err506 != nil { Usage() return } - factory457 := thrift.NewTJSONProtocolFactory() - jsProt458 := factory457.GetProtocol(mbTrans455) - containerStruct1 := aurora.NewAuroraAdminRestartShardsArgs() - err459 := containerStruct1.ReadField2(jsProt458) - if err459 != nil { + factory507 := thrift.NewTJSONProtocolFactory() + jsProt508 := factory507.GetProtocol(mbTrans505) + containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() + err509 := containerStruct1.ReadField2(context.Background(), jsProt508) + if err509 != nil { Usage() return } @@ -687,36 +686,36 @@ func main() { fmt.Fprintln(os.Stderr, "KillTasks requires 3 args") flag.Usage() } - arg460 := flag.Arg(1) - mbTrans461 := thrift.NewTMemoryBufferLen(len(arg460)) - defer mbTrans461.Close() - _, err462 := mbTrans461.WriteString(arg460) - if err462 != nil { + arg510 := flag.Arg(1) + mbTrans511 := thrift.NewTMemoryBufferLen(len(arg510)) + defer mbTrans511.Close() + _, err512 := mbTrans511.WriteString(arg510) + if err512 != nil { Usage() return } - factory463 := thrift.NewTJSONProtocolFactory() - jsProt464 := factory463.GetProtocol(mbTrans461) + factory513 := thrift.NewTJSONProtocolFactory() + jsProt514 := factory513.GetProtocol(mbTrans511) argvalue0 := aurora.NewJobKey() - err465 := argvalue0.Read(jsProt464) - if err465 != nil { + err515 := argvalue0.Read(context.Background(), jsProt514) + if err515 != nil { Usage() return } value0 := argvalue0 - arg466 := flag.Arg(2) - mbTrans467 := thrift.NewTMemoryBufferLen(len(arg466)) - defer mbTrans467.Close() - _, err468 := mbTrans467.WriteString(arg466) - if err468 != nil { + arg516 := flag.Arg(2) + mbTrans517 := thrift.NewTMemoryBufferLen(len(arg516)) + defer mbTrans517.Close() + _, err518 := mbTrans517.WriteString(arg516) + if err518 != nil { Usage() return } - factory469 := thrift.NewTJSONProtocolFactory() - jsProt470 := factory469.GetProtocol(mbTrans467) - containerStruct1 := aurora.NewAuroraAdminKillTasksArgs() - err471 := containerStruct1.ReadField2(jsProt470) - if err471 != nil { + factory519 := thrift.NewTJSONProtocolFactory() + jsProt520 := factory519.GetProtocol(mbTrans517) + containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() + err521 := containerStruct1.ReadField2(context.Background(), jsProt520) + if err521 != nil { Usage() return } @@ -732,25 +731,25 @@ func main() { fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") flag.Usage() } - arg473 := flag.Arg(1) - mbTrans474 := thrift.NewTMemoryBufferLen(len(arg473)) - defer mbTrans474.Close() - _, err475 := mbTrans474.WriteString(arg473) - if err475 != nil { + arg523 := flag.Arg(1) + mbTrans524 := thrift.NewTMemoryBufferLen(len(arg523)) + defer mbTrans524.Close() + _, err525 := mbTrans524.WriteString(arg523) + if err525 != nil { Usage() return } - factory476 := thrift.NewTJSONProtocolFactory() - jsProt477 := factory476.GetProtocol(mbTrans474) + factory526 := thrift.NewTJSONProtocolFactory() + jsProt527 := factory526.GetProtocol(mbTrans524) argvalue0 := aurora.NewInstanceKey() - err478 := argvalue0.Read(jsProt477) - if err478 != nil { + err528 := argvalue0.Read(context.Background(), jsProt527) + if err528 != nil { Usage() return } value0 := argvalue0 - tmp1, err479 := (strconv.Atoi(flag.Arg(2))) - if err479 != nil { + tmp1, err529 := (strconv.Atoi(flag.Arg(2))) + if err529 != nil { Usage() return } @@ -764,19 +763,19 @@ func main() { fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") flag.Usage() } - arg480 := flag.Arg(1) - mbTrans481 := thrift.NewTMemoryBufferLen(len(arg480)) - defer mbTrans481.Close() - _, err482 := mbTrans481.WriteString(arg480) - if err482 != nil { + arg530 := flag.Arg(1) + mbTrans531 := thrift.NewTMemoryBufferLen(len(arg530)) + defer mbTrans531.Close() + _, err532 := mbTrans531.WriteString(arg530) + if err532 != nil { Usage() return } - factory483 := thrift.NewTJSONProtocolFactory() - jsProt484 := factory483.GetProtocol(mbTrans481) + factory533 := thrift.NewTJSONProtocolFactory() + jsProt534 := factory533.GetProtocol(mbTrans531) argvalue0 := aurora.NewJobConfiguration() - err485 := argvalue0.Read(jsProt484) - if err485 != nil { + err535 := argvalue0.Read(context.Background(), jsProt534) + if err535 != nil { Usage() return } @@ -789,19 +788,19 @@ func main() { fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") flag.Usage() } - arg486 := flag.Arg(1) - mbTrans487 := thrift.NewTMemoryBufferLen(len(arg486)) - defer mbTrans487.Close() - _, err488 := mbTrans487.WriteString(arg486) - if err488 != nil { + arg536 := flag.Arg(1) + mbTrans537 := thrift.NewTMemoryBufferLen(len(arg536)) + defer mbTrans537.Close() + _, err538 := mbTrans537.WriteString(arg536) + if err538 != nil { Usage() return } - factory489 := thrift.NewTJSONProtocolFactory() - jsProt490 := factory489.GetProtocol(mbTrans487) + factory539 := thrift.NewTJSONProtocolFactory() + jsProt540 := factory539.GetProtocol(mbTrans537) argvalue0 := aurora.NewJobUpdateRequest() - err491 := argvalue0.Read(jsProt490) - if err491 != nil { + err541 := argvalue0.Read(context.Background(), jsProt540) + if err541 != nil { Usage() return } @@ -816,19 +815,19 @@ func main() { fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") flag.Usage() } - arg493 := flag.Arg(1) - mbTrans494 := thrift.NewTMemoryBufferLen(len(arg493)) - defer mbTrans494.Close() - _, err495 := mbTrans494.WriteString(arg493) - if err495 != nil { + arg543 := flag.Arg(1) + mbTrans544 := thrift.NewTMemoryBufferLen(len(arg543)) + defer mbTrans544.Close() + _, err545 := mbTrans544.WriteString(arg543) + if err545 != nil { Usage() return } - factory496 := thrift.NewTJSONProtocolFactory() - jsProt497 := factory496.GetProtocol(mbTrans494) + factory546 := thrift.NewTJSONProtocolFactory() + jsProt547 := factory546.GetProtocol(mbTrans544) argvalue0 := aurora.NewJobUpdateKey() - err498 := argvalue0.Read(jsProt497) - if err498 != nil { + err548 := argvalue0.Read(context.Background(), jsProt547) + if err548 != nil { Usage() return } @@ -843,19 +842,19 @@ func main() { fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") flag.Usage() } - arg500 := flag.Arg(1) - mbTrans501 := thrift.NewTMemoryBufferLen(len(arg500)) - defer mbTrans501.Close() - _, err502 := mbTrans501.WriteString(arg500) - if err502 != nil { + arg550 := flag.Arg(1) + mbTrans551 := thrift.NewTMemoryBufferLen(len(arg550)) + defer mbTrans551.Close() + _, err552 := mbTrans551.WriteString(arg550) + if err552 != nil { Usage() return } - factory503 := thrift.NewTJSONProtocolFactory() - jsProt504 := factory503.GetProtocol(mbTrans501) + factory553 := thrift.NewTJSONProtocolFactory() + jsProt554 := factory553.GetProtocol(mbTrans551) argvalue0 := aurora.NewJobUpdateKey() - err505 := argvalue0.Read(jsProt504) - if err505 != nil { + err555 := argvalue0.Read(context.Background(), jsProt554) + if err555 != nil { Usage() return } @@ -870,19 +869,19 @@ func main() { fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") flag.Usage() } - arg507 := flag.Arg(1) - mbTrans508 := thrift.NewTMemoryBufferLen(len(arg507)) - defer mbTrans508.Close() - _, err509 := mbTrans508.WriteString(arg507) - if err509 != nil { + arg557 := flag.Arg(1) + mbTrans558 := thrift.NewTMemoryBufferLen(len(arg557)) + defer mbTrans558.Close() + _, err559 := mbTrans558.WriteString(arg557) + if err559 != nil { Usage() return } - factory510 := thrift.NewTJSONProtocolFactory() - jsProt511 := factory510.GetProtocol(mbTrans508) + factory560 := thrift.NewTJSONProtocolFactory() + jsProt561 := factory560.GetProtocol(mbTrans558) argvalue0 := aurora.NewJobUpdateKey() - err512 := argvalue0.Read(jsProt511) - if err512 != nil { + err562 := argvalue0.Read(context.Background(), jsProt561) + if err562 != nil { Usage() return } @@ -897,19 +896,19 @@ func main() { fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") flag.Usage() } - arg514 := flag.Arg(1) - mbTrans515 := thrift.NewTMemoryBufferLen(len(arg514)) - defer mbTrans515.Close() - _, err516 := mbTrans515.WriteString(arg514) - if err516 != nil { + arg564 := flag.Arg(1) + mbTrans565 := thrift.NewTMemoryBufferLen(len(arg564)) + defer mbTrans565.Close() + _, err566 := mbTrans565.WriteString(arg564) + if err566 != nil { Usage() return } - factory517 := thrift.NewTJSONProtocolFactory() - jsProt518 := factory517.GetProtocol(mbTrans515) + factory567 := thrift.NewTJSONProtocolFactory() + jsProt568 := factory567.GetProtocol(mbTrans565) argvalue0 := aurora.NewJobUpdateKey() - err519 := argvalue0.Read(jsProt518) - if err519 != nil { + err569 := argvalue0.Read(context.Background(), jsProt568) + if err569 != nil { Usage() return } @@ -924,19 +923,19 @@ func main() { fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") flag.Usage() } - arg521 := flag.Arg(1) - mbTrans522 := thrift.NewTMemoryBufferLen(len(arg521)) - defer mbTrans522.Close() - _, err523 := mbTrans522.WriteString(arg521) - if err523 != nil { + arg571 := flag.Arg(1) + mbTrans572 := thrift.NewTMemoryBufferLen(len(arg571)) + defer mbTrans572.Close() + _, err573 := mbTrans572.WriteString(arg571) + if err573 != nil { Usage() return } - factory524 := thrift.NewTJSONProtocolFactory() - jsProt525 := factory524.GetProtocol(mbTrans522) + factory574 := thrift.NewTJSONProtocolFactory() + jsProt575 := factory574.GetProtocol(mbTrans572) argvalue0 := aurora.NewJobUpdateKey() - err526 := argvalue0.Read(jsProt525) - if err526 != nil { + err576 := argvalue0.Read(context.Background(), jsProt575) + if err576 != nil { Usage() return } @@ -967,19 +966,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") flag.Usage() } - arg528 := flag.Arg(1) - mbTrans529 := thrift.NewTMemoryBufferLen(len(arg528)) - defer mbTrans529.Close() - _, err530 := mbTrans529.WriteString(arg528) - if err530 != nil { + arg578 := flag.Arg(1) + mbTrans579 := thrift.NewTMemoryBufferLen(len(arg578)) + defer mbTrans579.Close() + _, err580 := mbTrans579.WriteString(arg578) + if err580 != nil { Usage() return } - factory531 := thrift.NewTJSONProtocolFactory() - jsProt532 := factory531.GetProtocol(mbTrans529) + factory581 := thrift.NewTJSONProtocolFactory() + jsProt582 := factory581.GetProtocol(mbTrans579) argvalue0 := aurora.NewTaskQuery() - err533 := argvalue0.Read(jsProt532) - if err533 != nil { + err583 := argvalue0.Read(context.Background(), jsProt582) + if err583 != nil { Usage() return } @@ -992,19 +991,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") flag.Usage() } - arg534 := flag.Arg(1) - mbTrans535 := thrift.NewTMemoryBufferLen(len(arg534)) - defer mbTrans535.Close() - _, err536 := mbTrans535.WriteString(arg534) - if err536 != nil { + arg584 := flag.Arg(1) + mbTrans585 := thrift.NewTMemoryBufferLen(len(arg584)) + defer mbTrans585.Close() + _, err586 := mbTrans585.WriteString(arg584) + if err586 != nil { Usage() return } - factory537 := thrift.NewTJSONProtocolFactory() - jsProt538 := factory537.GetProtocol(mbTrans535) + factory587 := thrift.NewTJSONProtocolFactory() + jsProt588 := factory587.GetProtocol(mbTrans585) argvalue0 := aurora.NewTaskQuery() - err539 := argvalue0.Read(jsProt538) - if err539 != nil { + err589 := argvalue0.Read(context.Background(), jsProt588) + if err589 != nil { Usage() return } @@ -1017,19 +1016,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") flag.Usage() } - arg540 := flag.Arg(1) - mbTrans541 := thrift.NewTMemoryBufferLen(len(arg540)) - defer mbTrans541.Close() - _, err542 := mbTrans541.WriteString(arg540) - if err542 != nil { + arg590 := flag.Arg(1) + mbTrans591 := thrift.NewTMemoryBufferLen(len(arg590)) + defer mbTrans591.Close() + _, err592 := mbTrans591.WriteString(arg590) + if err592 != nil { Usage() return } - factory543 := thrift.NewTJSONProtocolFactory() - jsProt544 := factory543.GetProtocol(mbTrans541) + factory593 := thrift.NewTJSONProtocolFactory() + jsProt594 := factory593.GetProtocol(mbTrans591) argvalue0 := aurora.NewTaskQuery() - err545 := argvalue0.Read(jsProt544) - if err545 != nil { + err595 := argvalue0.Read(context.Background(), jsProt594) + if err595 != nil { Usage() return } @@ -1042,19 +1041,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") flag.Usage() } - arg546 := flag.Arg(1) - mbTrans547 := thrift.NewTMemoryBufferLen(len(arg546)) - defer mbTrans547.Close() - _, err548 := mbTrans547.WriteString(arg546) - if err548 != nil { + arg596 := flag.Arg(1) + mbTrans597 := thrift.NewTMemoryBufferLen(len(arg596)) + defer mbTrans597.Close() + _, err598 := mbTrans597.WriteString(arg596) + if err598 != nil { Usage() return } - factory549 := thrift.NewTJSONProtocolFactory() - jsProt550 := factory549.GetProtocol(mbTrans547) + factory599 := thrift.NewTJSONProtocolFactory() + jsProt600 := factory599.GetProtocol(mbTrans597) argvalue0 := aurora.NewJobKey() - err551 := argvalue0.Read(jsProt550) - if err551 != nil { + err601 := argvalue0.Read(context.Background(), jsProt600) + if err601 != nil { Usage() return } @@ -1087,19 +1086,19 @@ func main() { fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") flag.Usage() } - arg554 := flag.Arg(1) - mbTrans555 := thrift.NewTMemoryBufferLen(len(arg554)) - defer mbTrans555.Close() - _, err556 := mbTrans555.WriteString(arg554) - if err556 != nil { + arg604 := flag.Arg(1) + mbTrans605 := thrift.NewTMemoryBufferLen(len(arg604)) + defer mbTrans605.Close() + _, err606 := mbTrans605.WriteString(arg604) + if err606 != nil { Usage() return } - factory557 := thrift.NewTJSONProtocolFactory() - jsProt558 := factory557.GetProtocol(mbTrans555) + factory607 := thrift.NewTJSONProtocolFactory() + jsProt608 := factory607.GetProtocol(mbTrans605) argvalue0 := aurora.NewJobConfiguration() - err559 := argvalue0.Read(jsProt558) - if err559 != nil { + err609 := argvalue0.Read(context.Background(), jsProt608) + if err609 != nil { Usage() return } @@ -1112,19 +1111,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") flag.Usage() } - arg560 := flag.Arg(1) - mbTrans561 := thrift.NewTMemoryBufferLen(len(arg560)) - defer mbTrans561.Close() - _, err562 := mbTrans561.WriteString(arg560) - if err562 != nil { + arg610 := flag.Arg(1) + mbTrans611 := thrift.NewTMemoryBufferLen(len(arg610)) + defer mbTrans611.Close() + _, err612 := mbTrans611.WriteString(arg610) + if err612 != nil { Usage() return } - factory563 := thrift.NewTJSONProtocolFactory() - jsProt564 := factory563.GetProtocol(mbTrans561) + factory613 := thrift.NewTJSONProtocolFactory() + jsProt614 := factory613.GetProtocol(mbTrans611) argvalue0 := aurora.NewJobUpdateQuery() - err565 := argvalue0.Read(jsProt564) - if err565 != nil { + err615 := argvalue0.Read(context.Background(), jsProt614) + if err615 != nil { Usage() return } @@ -1137,19 +1136,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") flag.Usage() } - arg566 := flag.Arg(1) - mbTrans567 := thrift.NewTMemoryBufferLen(len(arg566)) - defer mbTrans567.Close() - _, err568 := mbTrans567.WriteString(arg566) - if err568 != nil { + arg616 := flag.Arg(1) + mbTrans617 := thrift.NewTMemoryBufferLen(len(arg616)) + defer mbTrans617.Close() + _, err618 := mbTrans617.WriteString(arg616) + if err618 != nil { Usage() return } - factory569 := thrift.NewTJSONProtocolFactory() - jsProt570 := factory569.GetProtocol(mbTrans567) + factory619 := thrift.NewTJSONProtocolFactory() + jsProt620 := factory619.GetProtocol(mbTrans617) argvalue0 := aurora.NewJobUpdateQuery() - err571 := argvalue0.Read(jsProt570) - if err571 != nil { + err621 := argvalue0.Read(context.Background(), jsProt620) + if err621 != nil { Usage() return } @@ -1162,19 +1161,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") flag.Usage() } - arg572 := flag.Arg(1) - mbTrans573 := thrift.NewTMemoryBufferLen(len(arg572)) - defer mbTrans573.Close() - _, err574 := mbTrans573.WriteString(arg572) - if err574 != nil { + arg622 := flag.Arg(1) + mbTrans623 := thrift.NewTMemoryBufferLen(len(arg622)) + defer mbTrans623.Close() + _, err624 := mbTrans623.WriteString(arg622) + if err624 != nil { Usage() return } - factory575 := thrift.NewTJSONProtocolFactory() - jsProt576 := factory575.GetProtocol(mbTrans573) + factory625 := thrift.NewTJSONProtocolFactory() + jsProt626 := factory625.GetProtocol(mbTrans623) argvalue0 := aurora.NewJobUpdateRequest() - err577 := argvalue0.Read(jsProt576) - if err577 != nil { + err627 := argvalue0.Read(context.Background(), jsProt626) + if err627 != nil { Usage() return } diff --git a/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go b/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go index 9bc3848..b4715d5 100755 --- a/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go +++ b/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go @@ -1,5 +1,4 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main @@ -176,19 +175,19 @@ func main() { fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") flag.Usage() } - arg163 := flag.Arg(1) - mbTrans164 := thrift.NewTMemoryBufferLen(len(arg163)) - defer mbTrans164.Close() - _, err165 := mbTrans164.WriteString(arg163) - if err165 != nil { + arg213 := flag.Arg(1) + mbTrans214 := thrift.NewTMemoryBufferLen(len(arg213)) + defer mbTrans214.Close() + _, err215 := mbTrans214.WriteString(arg213) + if err215 != nil { Usage() return } - factory166 := thrift.NewTJSONProtocolFactory() - jsProt167 := factory166.GetProtocol(mbTrans164) + factory216 := thrift.NewTJSONProtocolFactory() + jsProt217 := factory216.GetProtocol(mbTrans214) argvalue0 := aurora.NewJobConfiguration() - err168 := argvalue0.Read(jsProt167) - if err168 != nil { + err218 := argvalue0.Read(context.Background(), jsProt217) + if err218 != nil { Usage() return } @@ -201,19 +200,19 @@ func main() { fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") flag.Usage() } - arg169 := flag.Arg(1) - mbTrans170 := thrift.NewTMemoryBufferLen(len(arg169)) - defer mbTrans170.Close() - _, err171 := mbTrans170.WriteString(arg169) - if err171 != nil { + arg219 := flag.Arg(1) + mbTrans220 := thrift.NewTMemoryBufferLen(len(arg219)) + defer mbTrans220.Close() + _, err221 := mbTrans220.WriteString(arg219) + if err221 != nil { Usage() return } - factory172 := thrift.NewTJSONProtocolFactory() - jsProt173 := factory172.GetProtocol(mbTrans170) + factory222 := thrift.NewTJSONProtocolFactory() + jsProt223 := factory222.GetProtocol(mbTrans220) argvalue0 := aurora.NewJobConfiguration() - err174 := argvalue0.Read(jsProt173) - if err174 != nil { + err224 := argvalue0.Read(context.Background(), jsProt223) + if err224 != nil { Usage() return } @@ -226,19 +225,19 @@ func main() { fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") flag.Usage() } - arg175 := flag.Arg(1) - mbTrans176 := thrift.NewTMemoryBufferLen(len(arg175)) - defer mbTrans176.Close() - _, err177 := mbTrans176.WriteString(arg175) - if err177 != nil { + arg225 := flag.Arg(1) + mbTrans226 := thrift.NewTMemoryBufferLen(len(arg225)) + defer mbTrans226.Close() + _, err227 := mbTrans226.WriteString(arg225) + if err227 != nil { Usage() return } - factory178 := thrift.NewTJSONProtocolFactory() - jsProt179 := factory178.GetProtocol(mbTrans176) + factory228 := thrift.NewTJSONProtocolFactory() + jsProt229 := factory228.GetProtocol(mbTrans226) argvalue0 := aurora.NewJobKey() - err180 := argvalue0.Read(jsProt179) - if err180 != nil { + err230 := argvalue0.Read(context.Background(), jsProt229) + if err230 != nil { Usage() return } @@ -251,19 +250,19 @@ func main() { fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") flag.Usage() } - arg181 := flag.Arg(1) - mbTrans182 := thrift.NewTMemoryBufferLen(len(arg181)) - defer mbTrans182.Close() - _, err183 := mbTrans182.WriteString(arg181) - if err183 != nil { + arg231 := flag.Arg(1) + mbTrans232 := thrift.NewTMemoryBufferLen(len(arg231)) + defer mbTrans232.Close() + _, err233 := mbTrans232.WriteString(arg231) + if err233 != nil { Usage() return } - factory184 := thrift.NewTJSONProtocolFactory() - jsProt185 := factory184.GetProtocol(mbTrans182) + factory234 := thrift.NewTJSONProtocolFactory() + jsProt235 := factory234.GetProtocol(mbTrans232) argvalue0 := aurora.NewJobKey() - err186 := argvalue0.Read(jsProt185) - if err186 != nil { + err236 := argvalue0.Read(context.Background(), jsProt235) + if err236 != nil { Usage() return } @@ -276,36 +275,36 @@ func main() { fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") flag.Usage() } - arg187 := flag.Arg(1) - mbTrans188 := thrift.NewTMemoryBufferLen(len(arg187)) - defer mbTrans188.Close() - _, err189 := mbTrans188.WriteString(arg187) - if err189 != nil { + arg237 := flag.Arg(1) + mbTrans238 := thrift.NewTMemoryBufferLen(len(arg237)) + defer mbTrans238.Close() + _, err239 := mbTrans238.WriteString(arg237) + if err239 != nil { Usage() return } - factory190 := thrift.NewTJSONProtocolFactory() - jsProt191 := factory190.GetProtocol(mbTrans188) + factory240 := thrift.NewTJSONProtocolFactory() + jsProt241 := factory240.GetProtocol(mbTrans238) argvalue0 := aurora.NewJobKey() - err192 := argvalue0.Read(jsProt191) - if err192 != nil { + err242 := argvalue0.Read(context.Background(), jsProt241) + if err242 != nil { Usage() return } value0 := argvalue0 - arg193 := flag.Arg(2) - mbTrans194 := thrift.NewTMemoryBufferLen(len(arg193)) - defer mbTrans194.Close() - _, err195 := mbTrans194.WriteString(arg193) - if err195 != nil { + arg243 := flag.Arg(2) + mbTrans244 := thrift.NewTMemoryBufferLen(len(arg243)) + defer mbTrans244.Close() + _, err245 := mbTrans244.WriteString(arg243) + if err245 != nil { Usage() return } - factory196 := thrift.NewTJSONProtocolFactory() - jsProt197 := factory196.GetProtocol(mbTrans194) + factory246 := thrift.NewTJSONProtocolFactory() + jsProt247 := factory246.GetProtocol(mbTrans244) containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() - err198 := containerStruct1.ReadField2(jsProt197) - if err198 != nil { + err248 := containerStruct1.ReadField2(context.Background(), jsProt247) + if err248 != nil { Usage() return } @@ -319,36 +318,36 @@ func main() { fmt.Fprintln(os.Stderr, "KillTasks requires 3 args") flag.Usage() } - arg199 := flag.Arg(1) - mbTrans200 := thrift.NewTMemoryBufferLen(len(arg199)) - defer mbTrans200.Close() - _, err201 := mbTrans200.WriteString(arg199) - if err201 != nil { + arg249 := flag.Arg(1) + mbTrans250 := thrift.NewTMemoryBufferLen(len(arg249)) + defer mbTrans250.Close() + _, err251 := mbTrans250.WriteString(arg249) + if err251 != nil { Usage() return } - factory202 := thrift.NewTJSONProtocolFactory() - jsProt203 := factory202.GetProtocol(mbTrans200) + factory252 := thrift.NewTJSONProtocolFactory() + jsProt253 := factory252.GetProtocol(mbTrans250) argvalue0 := aurora.NewJobKey() - err204 := argvalue0.Read(jsProt203) - if err204 != nil { + err254 := argvalue0.Read(context.Background(), jsProt253) + if err254 != nil { Usage() return } value0 := argvalue0 - arg205 := flag.Arg(2) - mbTrans206 := thrift.NewTMemoryBufferLen(len(arg205)) - defer mbTrans206.Close() - _, err207 := mbTrans206.WriteString(arg205) - if err207 != nil { + arg255 := flag.Arg(2) + mbTrans256 := thrift.NewTMemoryBufferLen(len(arg255)) + defer mbTrans256.Close() + _, err257 := mbTrans256.WriteString(arg255) + if err257 != nil { Usage() return } - factory208 := thrift.NewTJSONProtocolFactory() - jsProt209 := factory208.GetProtocol(mbTrans206) + factory258 := thrift.NewTJSONProtocolFactory() + jsProt259 := factory258.GetProtocol(mbTrans256) containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() - err210 := containerStruct1.ReadField2(jsProt209) - if err210 != nil { + err260 := containerStruct1.ReadField2(context.Background(), jsProt259) + if err260 != nil { Usage() return } @@ -364,25 +363,25 @@ func main() { fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") flag.Usage() } - arg212 := flag.Arg(1) - mbTrans213 := thrift.NewTMemoryBufferLen(len(arg212)) - defer mbTrans213.Close() - _, err214 := mbTrans213.WriteString(arg212) - if err214 != nil { + arg262 := flag.Arg(1) + mbTrans263 := thrift.NewTMemoryBufferLen(len(arg262)) + defer mbTrans263.Close() + _, err264 := mbTrans263.WriteString(arg262) + if err264 != nil { Usage() return } - factory215 := thrift.NewTJSONProtocolFactory() - jsProt216 := factory215.GetProtocol(mbTrans213) + factory265 := thrift.NewTJSONProtocolFactory() + jsProt266 := factory265.GetProtocol(mbTrans263) argvalue0 := aurora.NewInstanceKey() - err217 := argvalue0.Read(jsProt216) - if err217 != nil { + err267 := argvalue0.Read(context.Background(), jsProt266) + if err267 != nil { Usage() return } value0 := argvalue0 - tmp1, err218 := (strconv.Atoi(flag.Arg(2))) - if err218 != nil { + tmp1, err268 := (strconv.Atoi(flag.Arg(2))) + if err268 != nil { Usage() return } @@ -396,19 +395,19 @@ func main() { fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") flag.Usage() } - arg219 := flag.Arg(1) - mbTrans220 := thrift.NewTMemoryBufferLen(len(arg219)) - defer mbTrans220.Close() - _, err221 := mbTrans220.WriteString(arg219) - if err221 != nil { + arg269 := flag.Arg(1) + mbTrans270 := thrift.NewTMemoryBufferLen(len(arg269)) + defer mbTrans270.Close() + _, err271 := mbTrans270.WriteString(arg269) + if err271 != nil { Usage() return } - factory222 := thrift.NewTJSONProtocolFactory() - jsProt223 := factory222.GetProtocol(mbTrans220) + factory272 := thrift.NewTJSONProtocolFactory() + jsProt273 := factory272.GetProtocol(mbTrans270) argvalue0 := aurora.NewJobConfiguration() - err224 := argvalue0.Read(jsProt223) - if err224 != nil { + err274 := argvalue0.Read(context.Background(), jsProt273) + if err274 != nil { Usage() return } @@ -421,19 +420,19 @@ func main() { fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") flag.Usage() } - arg225 := flag.Arg(1) - mbTrans226 := thrift.NewTMemoryBufferLen(len(arg225)) - defer mbTrans226.Close() - _, err227 := mbTrans226.WriteString(arg225) - if err227 != nil { + arg275 := flag.Arg(1) + mbTrans276 := thrift.NewTMemoryBufferLen(len(arg275)) + defer mbTrans276.Close() + _, err277 := mbTrans276.WriteString(arg275) + if err277 != nil { Usage() return } - factory228 := thrift.NewTJSONProtocolFactory() - jsProt229 := factory228.GetProtocol(mbTrans226) + factory278 := thrift.NewTJSONProtocolFactory() + jsProt279 := factory278.GetProtocol(mbTrans276) argvalue0 := aurora.NewJobUpdateRequest() - err230 := argvalue0.Read(jsProt229) - if err230 != nil { + err280 := argvalue0.Read(context.Background(), jsProt279) + if err280 != nil { Usage() return } @@ -448,19 +447,19 @@ func main() { fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") flag.Usage() } - arg232 := flag.Arg(1) - mbTrans233 := thrift.NewTMemoryBufferLen(len(arg232)) - defer mbTrans233.Close() - _, err234 := mbTrans233.WriteString(arg232) - if err234 != nil { + arg282 := flag.Arg(1) + mbTrans283 := thrift.NewTMemoryBufferLen(len(arg282)) + defer mbTrans283.Close() + _, err284 := mbTrans283.WriteString(arg282) + if err284 != nil { Usage() return } - factory235 := thrift.NewTJSONProtocolFactory() - jsProt236 := factory235.GetProtocol(mbTrans233) + factory285 := thrift.NewTJSONProtocolFactory() + jsProt286 := factory285.GetProtocol(mbTrans283) argvalue0 := aurora.NewJobUpdateKey() - err237 := argvalue0.Read(jsProt236) - if err237 != nil { + err287 := argvalue0.Read(context.Background(), jsProt286) + if err287 != nil { Usage() return } @@ -475,19 +474,19 @@ func main() { fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") flag.Usage() } - arg239 := flag.Arg(1) - mbTrans240 := thrift.NewTMemoryBufferLen(len(arg239)) - defer mbTrans240.Close() - _, err241 := mbTrans240.WriteString(arg239) - if err241 != nil { + arg289 := flag.Arg(1) + mbTrans290 := thrift.NewTMemoryBufferLen(len(arg289)) + defer mbTrans290.Close() + _, err291 := mbTrans290.WriteString(arg289) + if err291 != nil { Usage() return } - factory242 := thrift.NewTJSONProtocolFactory() - jsProt243 := factory242.GetProtocol(mbTrans240) + factory292 := thrift.NewTJSONProtocolFactory() + jsProt293 := factory292.GetProtocol(mbTrans290) argvalue0 := aurora.NewJobUpdateKey() - err244 := argvalue0.Read(jsProt243) - if err244 != nil { + err294 := argvalue0.Read(context.Background(), jsProt293) + if err294 != nil { Usage() return } @@ -502,19 +501,19 @@ func main() { fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") flag.Usage() } - arg246 := flag.Arg(1) - mbTrans247 := thrift.NewTMemoryBufferLen(len(arg246)) - defer mbTrans247.Close() - _, err248 := mbTrans247.WriteString(arg246) - if err248 != nil { + arg296 := flag.Arg(1) + mbTrans297 := thrift.NewTMemoryBufferLen(len(arg296)) + defer mbTrans297.Close() + _, err298 := mbTrans297.WriteString(arg296) + if err298 != nil { Usage() return } - factory249 := thrift.NewTJSONProtocolFactory() - jsProt250 := factory249.GetProtocol(mbTrans247) + factory299 := thrift.NewTJSONProtocolFactory() + jsProt300 := factory299.GetProtocol(mbTrans297) argvalue0 := aurora.NewJobUpdateKey() - err251 := argvalue0.Read(jsProt250) - if err251 != nil { + err301 := argvalue0.Read(context.Background(), jsProt300) + if err301 != nil { Usage() return } @@ -529,19 +528,19 @@ func main() { fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") flag.Usage() } - arg253 := flag.Arg(1) - mbTrans254 := thrift.NewTMemoryBufferLen(len(arg253)) - defer mbTrans254.Close() - _, err255 := mbTrans254.WriteString(arg253) - if err255 != nil { + arg303 := flag.Arg(1) + mbTrans304 := thrift.NewTMemoryBufferLen(len(arg303)) + defer mbTrans304.Close() + _, err305 := mbTrans304.WriteString(arg303) + if err305 != nil { Usage() return } - factory256 := thrift.NewTJSONProtocolFactory() - jsProt257 := factory256.GetProtocol(mbTrans254) + factory306 := thrift.NewTJSONProtocolFactory() + jsProt307 := factory306.GetProtocol(mbTrans304) argvalue0 := aurora.NewJobUpdateKey() - err258 := argvalue0.Read(jsProt257) - if err258 != nil { + err308 := argvalue0.Read(context.Background(), jsProt307) + if err308 != nil { Usage() return } @@ -556,19 +555,19 @@ func main() { fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") flag.Usage() } - arg260 := flag.Arg(1) - mbTrans261 := thrift.NewTMemoryBufferLen(len(arg260)) - defer mbTrans261.Close() - _, err262 := mbTrans261.WriteString(arg260) - if err262 != nil { + arg310 := flag.Arg(1) + mbTrans311 := thrift.NewTMemoryBufferLen(len(arg310)) + defer mbTrans311.Close() + _, err312 := mbTrans311.WriteString(arg310) + if err312 != nil { Usage() return } - factory263 := thrift.NewTJSONProtocolFactory() - jsProt264 := factory263.GetProtocol(mbTrans261) + factory313 := thrift.NewTJSONProtocolFactory() + jsProt314 := factory313.GetProtocol(mbTrans311) argvalue0 := aurora.NewJobUpdateKey() - err265 := argvalue0.Read(jsProt264) - if err265 != nil { + err315 := argvalue0.Read(context.Background(), jsProt314) + if err315 != nil { Usage() return } @@ -599,19 +598,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") flag.Usage() } - arg267 := flag.Arg(1) - mbTrans268 := thrift.NewTMemoryBufferLen(len(arg267)) - defer mbTrans268.Close() - _, err269 := mbTrans268.WriteString(arg267) - if err269 != nil { + arg317 := flag.Arg(1) + mbTrans318 := thrift.NewTMemoryBufferLen(len(arg317)) + defer mbTrans318.Close() + _, err319 := mbTrans318.WriteString(arg317) + if err319 != nil { Usage() return } - factory270 := thrift.NewTJSONProtocolFactory() - jsProt271 := factory270.GetProtocol(mbTrans268) + factory320 := thrift.NewTJSONProtocolFactory() + jsProt321 := factory320.GetProtocol(mbTrans318) argvalue0 := aurora.NewTaskQuery() - err272 := argvalue0.Read(jsProt271) - if err272 != nil { + err322 := argvalue0.Read(context.Background(), jsProt321) + if err322 != nil { Usage() return } @@ -624,19 +623,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") flag.Usage() } - arg273 := flag.Arg(1) - mbTrans274 := thrift.NewTMemoryBufferLen(len(arg273)) - defer mbTrans274.Close() - _, err275 := mbTrans274.WriteString(arg273) - if err275 != nil { + arg323 := flag.Arg(1) + mbTrans324 := thrift.NewTMemoryBufferLen(len(arg323)) + defer mbTrans324.Close() + _, err325 := mbTrans324.WriteString(arg323) + if err325 != nil { Usage() return } - factory276 := thrift.NewTJSONProtocolFactory() - jsProt277 := factory276.GetProtocol(mbTrans274) + factory326 := thrift.NewTJSONProtocolFactory() + jsProt327 := factory326.GetProtocol(mbTrans324) argvalue0 := aurora.NewTaskQuery() - err278 := argvalue0.Read(jsProt277) - if err278 != nil { + err328 := argvalue0.Read(context.Background(), jsProt327) + if err328 != nil { Usage() return } @@ -649,19 +648,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") flag.Usage() } - arg279 := flag.Arg(1) - mbTrans280 := thrift.NewTMemoryBufferLen(len(arg279)) - defer mbTrans280.Close() - _, err281 := mbTrans280.WriteString(arg279) - if err281 != nil { + arg329 := flag.Arg(1) + mbTrans330 := thrift.NewTMemoryBufferLen(len(arg329)) + defer mbTrans330.Close() + _, err331 := mbTrans330.WriteString(arg329) + if err331 != nil { Usage() return } - factory282 := thrift.NewTJSONProtocolFactory() - jsProt283 := factory282.GetProtocol(mbTrans280) + factory332 := thrift.NewTJSONProtocolFactory() + jsProt333 := factory332.GetProtocol(mbTrans330) argvalue0 := aurora.NewTaskQuery() - err284 := argvalue0.Read(jsProt283) - if err284 != nil { + err334 := argvalue0.Read(context.Background(), jsProt333) + if err334 != nil { Usage() return } @@ -674,19 +673,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") flag.Usage() } - arg285 := flag.Arg(1) - mbTrans286 := thrift.NewTMemoryBufferLen(len(arg285)) - defer mbTrans286.Close() - _, err287 := mbTrans286.WriteString(arg285) - if err287 != nil { + arg335 := flag.Arg(1) + mbTrans336 := thrift.NewTMemoryBufferLen(len(arg335)) + defer mbTrans336.Close() + _, err337 := mbTrans336.WriteString(arg335) + if err337 != nil { Usage() return } - factory288 := thrift.NewTJSONProtocolFactory() - jsProt289 := factory288.GetProtocol(mbTrans286) + factory338 := thrift.NewTJSONProtocolFactory() + jsProt339 := factory338.GetProtocol(mbTrans336) argvalue0 := aurora.NewJobKey() - err290 := argvalue0.Read(jsProt289) - if err290 != nil { + err340 := argvalue0.Read(context.Background(), jsProt339) + if err340 != nil { Usage() return } @@ -719,19 +718,19 @@ func main() { fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") flag.Usage() } - arg293 := flag.Arg(1) - mbTrans294 := thrift.NewTMemoryBufferLen(len(arg293)) - defer mbTrans294.Close() - _, err295 := mbTrans294.WriteString(arg293) - if err295 != nil { + arg343 := flag.Arg(1) + mbTrans344 := thrift.NewTMemoryBufferLen(len(arg343)) + defer mbTrans344.Close() + _, err345 := mbTrans344.WriteString(arg343) + if err345 != nil { Usage() return } - factory296 := thrift.NewTJSONProtocolFactory() - jsProt297 := factory296.GetProtocol(mbTrans294) + factory346 := thrift.NewTJSONProtocolFactory() + jsProt347 := factory346.GetProtocol(mbTrans344) argvalue0 := aurora.NewJobConfiguration() - err298 := argvalue0.Read(jsProt297) - if err298 != nil { + err348 := argvalue0.Read(context.Background(), jsProt347) + if err348 != nil { Usage() return } @@ -744,19 +743,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") flag.Usage() } - arg299 := flag.Arg(1) - mbTrans300 := thrift.NewTMemoryBufferLen(len(arg299)) - defer mbTrans300.Close() - _, err301 := mbTrans300.WriteString(arg299) - if err301 != nil { + arg349 := flag.Arg(1) + mbTrans350 := thrift.NewTMemoryBufferLen(len(arg349)) + defer mbTrans350.Close() + _, err351 := mbTrans350.WriteString(arg349) + if err351 != nil { Usage() return } - factory302 := thrift.NewTJSONProtocolFactory() - jsProt303 := factory302.GetProtocol(mbTrans300) + factory352 := thrift.NewTJSONProtocolFactory() + jsProt353 := factory352.GetProtocol(mbTrans350) argvalue0 := aurora.NewJobUpdateQuery() - err304 := argvalue0.Read(jsProt303) - if err304 != nil { + err354 := argvalue0.Read(context.Background(), jsProt353) + if err354 != nil { Usage() return } @@ -769,19 +768,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") flag.Usage() } - arg305 := flag.Arg(1) - mbTrans306 := thrift.NewTMemoryBufferLen(len(arg305)) - defer mbTrans306.Close() - _, err307 := mbTrans306.WriteString(arg305) - if err307 != nil { + arg355 := flag.Arg(1) + mbTrans356 := thrift.NewTMemoryBufferLen(len(arg355)) + defer mbTrans356.Close() + _, err357 := mbTrans356.WriteString(arg355) + if err357 != nil { Usage() return } - factory308 := thrift.NewTJSONProtocolFactory() - jsProt309 := factory308.GetProtocol(mbTrans306) + factory358 := thrift.NewTJSONProtocolFactory() + jsProt359 := factory358.GetProtocol(mbTrans356) argvalue0 := aurora.NewJobUpdateQuery() - err310 := argvalue0.Read(jsProt309) - if err310 != nil { + err360 := argvalue0.Read(context.Background(), jsProt359) + if err360 != nil { Usage() return } @@ -794,19 +793,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") flag.Usage() } - arg311 := flag.Arg(1) - mbTrans312 := thrift.NewTMemoryBufferLen(len(arg311)) - defer mbTrans312.Close() - _, err313 := mbTrans312.WriteString(arg311) - if err313 != nil { + arg361 := flag.Arg(1) + mbTrans362 := thrift.NewTMemoryBufferLen(len(arg361)) + defer mbTrans362.Close() + _, err363 := mbTrans362.WriteString(arg361) + if err363 != nil { Usage() return } - factory314 := thrift.NewTJSONProtocolFactory() - jsProt315 := factory314.GetProtocol(mbTrans312) + factory364 := thrift.NewTJSONProtocolFactory() + jsProt365 := factory364.GetProtocol(mbTrans362) argvalue0 := aurora.NewJobUpdateRequest() - err316 := argvalue0.Read(jsProt315) - if err316 != nil { + err366 := argvalue0.Read(context.Background(), jsProt365) + if err366 != nil { Usage() return } diff --git a/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go b/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go index 31aac65..e802328 100755 --- a/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go +++ b/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go @@ -1,5 +1,4 @@ -// Autogenerated by Thrift Compiler (0.13.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main @@ -180,19 +179,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") flag.Usage() } - arg82 := flag.Arg(1) - mbTrans83 := thrift.NewTMemoryBufferLen(len(arg82)) - defer mbTrans83.Close() - _, err84 := mbTrans83.WriteString(arg82) - if err84 != nil { + arg132 := flag.Arg(1) + mbTrans133 := thrift.NewTMemoryBufferLen(len(arg132)) + defer mbTrans133.Close() + _, err134 := mbTrans133.WriteString(arg132) + if err134 != nil { Usage() return } - factory85 := thrift.NewTJSONProtocolFactory() - jsProt86 := factory85.GetProtocol(mbTrans83) + factory135 := thrift.NewTJSONProtocolFactory() + jsProt136 := factory135.GetProtocol(mbTrans133) argvalue0 := aurora.NewTaskQuery() - err87 := argvalue0.Read(jsProt86) - if err87 != nil { + err137 := argvalue0.Read(context.Background(), jsProt136) + if err137 != nil { Usage() return } @@ -205,19 +204,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") flag.Usage() } - arg88 := flag.Arg(1) - mbTrans89 := thrift.NewTMemoryBufferLen(len(arg88)) - defer mbTrans89.Close() - _, err90 := mbTrans89.WriteString(arg88) - if err90 != nil { + arg138 := flag.Arg(1) + mbTrans139 := thrift.NewTMemoryBufferLen(len(arg138)) + defer mbTrans139.Close() + _, err140 := mbTrans139.WriteString(arg138) + if err140 != nil { Usage() return } - factory91 := thrift.NewTJSONProtocolFactory() - jsProt92 := factory91.GetProtocol(mbTrans89) + factory141 := thrift.NewTJSONProtocolFactory() + jsProt142 := factory141.GetProtocol(mbTrans139) argvalue0 := aurora.NewTaskQuery() - err93 := argvalue0.Read(jsProt92) - if err93 != nil { + err143 := argvalue0.Read(context.Background(), jsProt142) + if err143 != nil { Usage() return } @@ -230,19 +229,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") flag.Usage() } - arg94 := flag.Arg(1) - mbTrans95 := thrift.NewTMemoryBufferLen(len(arg94)) - defer mbTrans95.Close() - _, err96 := mbTrans95.WriteString(arg94) - if err96 != nil { + arg144 := flag.Arg(1) + mbTrans145 := thrift.NewTMemoryBufferLen(len(arg144)) + defer mbTrans145.Close() + _, err146 := mbTrans145.WriteString(arg144) + if err146 != nil { Usage() return } - factory97 := thrift.NewTJSONProtocolFactory() - jsProt98 := factory97.GetProtocol(mbTrans95) + factory147 := thrift.NewTJSONProtocolFactory() + jsProt148 := factory147.GetProtocol(mbTrans145) argvalue0 := aurora.NewTaskQuery() - err99 := argvalue0.Read(jsProt98) - if err99 != nil { + err149 := argvalue0.Read(context.Background(), jsProt148) + if err149 != nil { Usage() return } @@ -255,19 +254,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") flag.Usage() } - arg100 := flag.Arg(1) - mbTrans101 := thrift.NewTMemoryBufferLen(len(arg100)) - defer mbTrans101.Close() - _, err102 := mbTrans101.WriteString(arg100) - if err102 != nil { + arg150 := flag.Arg(1) + mbTrans151 := thrift.NewTMemoryBufferLen(len(arg150)) + defer mbTrans151.Close() + _, err152 := mbTrans151.WriteString(arg150) + if err152 != nil { Usage() return } - factory103 := thrift.NewTJSONProtocolFactory() - jsProt104 := factory103.GetProtocol(mbTrans101) + factory153 := thrift.NewTJSONProtocolFactory() + jsProt154 := factory153.GetProtocol(mbTrans151) argvalue0 := aurora.NewJobKey() - err105 := argvalue0.Read(jsProt104) - if err105 != nil { + err155 := argvalue0.Read(context.Background(), jsProt154) + if err155 != nil { Usage() return } @@ -300,19 +299,19 @@ func main() { fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") flag.Usage() } - arg108 := flag.Arg(1) - mbTrans109 := thrift.NewTMemoryBufferLen(len(arg108)) - defer mbTrans109.Close() - _, err110 := mbTrans109.WriteString(arg108) - if err110 != nil { + arg158 := flag.Arg(1) + mbTrans159 := thrift.NewTMemoryBufferLen(len(arg158)) + defer mbTrans159.Close() + _, err160 := mbTrans159.WriteString(arg158) + if err160 != nil { Usage() return } - factory111 := thrift.NewTJSONProtocolFactory() - jsProt112 := factory111.GetProtocol(mbTrans109) + factory161 := thrift.NewTJSONProtocolFactory() + jsProt162 := factory161.GetProtocol(mbTrans159) argvalue0 := aurora.NewJobConfiguration() - err113 := argvalue0.Read(jsProt112) - if err113 != nil { + err163 := argvalue0.Read(context.Background(), jsProt162) + if err163 != nil { Usage() return } @@ -325,19 +324,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") flag.Usage() } - arg114 := flag.Arg(1) - mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114)) - defer mbTrans115.Close() - _, err116 := mbTrans115.WriteString(arg114) - if err116 != nil { + arg164 := flag.Arg(1) + mbTrans165 := thrift.NewTMemoryBufferLen(len(arg164)) + defer mbTrans165.Close() + _, err166 := mbTrans165.WriteString(arg164) + if err166 != nil { Usage() return } - factory117 := thrift.NewTJSONProtocolFactory() - jsProt118 := factory117.GetProtocol(mbTrans115) + factory167 := thrift.NewTJSONProtocolFactory() + jsProt168 := factory167.GetProtocol(mbTrans165) argvalue0 := aurora.NewJobUpdateQuery() - err119 := argvalue0.Read(jsProt118) - if err119 != nil { + err169 := argvalue0.Read(context.Background(), jsProt168) + if err169 != nil { Usage() return } @@ -350,19 +349,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") flag.Usage() } - arg120 := flag.Arg(1) - mbTrans121 := thrift.NewTMemoryBufferLen(len(arg120)) - defer mbTrans121.Close() - _, err122 := mbTrans121.WriteString(arg120) - if err122 != nil { + arg170 := flag.Arg(1) + mbTrans171 := thrift.NewTMemoryBufferLen(len(arg170)) + defer mbTrans171.Close() + _, err172 := mbTrans171.WriteString(arg170) + if err172 != nil { Usage() return } - factory123 := thrift.NewTJSONProtocolFactory() - jsProt124 := factory123.GetProtocol(mbTrans121) + factory173 := thrift.NewTJSONProtocolFactory() + jsProt174 := factory173.GetProtocol(mbTrans171) argvalue0 := aurora.NewJobUpdateQuery() - err125 := argvalue0.Read(jsProt124) - if err125 != nil { + err175 := argvalue0.Read(context.Background(), jsProt174) + if err175 != nil { Usage() return } @@ -375,19 +374,19 @@ func main() { fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") flag.Usage() } - arg126 := flag.Arg(1) - mbTrans127 := thrift.NewTMemoryBufferLen(len(arg126)) - defer mbTrans127.Close() - _, err128 := mbTrans127.WriteString(arg126) - if err128 != nil { + arg176 := flag.Arg(1) + mbTrans177 := thrift.NewTMemoryBufferLen(len(arg176)) + defer mbTrans177.Close() + _, err178 := mbTrans177.WriteString(arg176) + if err178 != nil { Usage() return } - factory129 := thrift.NewTJSONProtocolFactory() - jsProt130 := factory129.GetProtocol(mbTrans127) + factory179 := thrift.NewTJSONProtocolFactory() + jsProt180 := factory179.GetProtocol(mbTrans177) argvalue0 := aurora.NewJobUpdateRequest() - err131 := argvalue0.Read(jsProt130) - if err131 != nil { + err181 := argvalue0.Read(context.Background(), jsProt180) + if err181 != nil { Usage() return } diff --git a/generateBindings.sh b/generateBindings.sh index 03acd6d..8cb5b9d 100755 --- a/generateBindings.sh +++ b/generateBindings.sh @@ -1,6 +1,6 @@ #! /bin/bash -THRIFT_VER=0.13.0 +THRIFT_VER=0.14.0 if [[ $(thrift -version | grep -e $THRIFT_VER -c) -ne 1 ]]; then echo "Warning: This wrapper has only been tested with version" $THRIFT_VER; diff --git a/go.mod b/go.mod index f59797d..3b3095f 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,10 @@ module github.com/aurora-scheduler/gorealis/v2 require ( - github.com/apache/thrift v0.13.0 + github.com/apache/thrift v0.14.0 github.com/pkg/errors v0.9.1 github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a github.com/stretchr/testify v1.5.0 ) -replace github.com/apache/thrift v0.13.0 => github.com/ridv/thrift v0.13.2 - -go 1.13 +go 1.16 From 425faf28b8c5ac886c91638fe3b69f11a07b9f45 Mon Sep 17 00:00:00 2001 From: lenhattan86 Date: Thu, 16 Sep 2021 16:29:25 -0700 Subject: [PATCH 15/23] Adds priority for aurora-scheduler (#13) Adds priority for task config --- job.go | 5 +++++ jobUpdate.go | 5 +++++ task.go | 9 ++++++++- task_test.go | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/job.go b/job.go index b553520..698ecfa 100644 --- a/job.go +++ b/job.go @@ -156,6 +156,11 @@ func (j *AuroraJob) IsService(isService bool) *AuroraJob { return j } +func (j *AuroraJob) Priority(priority int32) *AuroraJob { + j.task.Priority(priority) + return j +} + func (j *AuroraJob) TaskConfig() *aurora.TaskConfig { return j.task.TaskConfig() } diff --git a/jobUpdate.go b/jobUpdate.go index 3ef2cb4..0f231f2 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -221,6 +221,11 @@ func (j *JobUpdate) IsService(isService bool) *JobUpdate { return j } +func (j *JobUpdate) Priority(priority int32) *JobUpdate { + j.task.Priority(priority) + return j +} + func (j *JobUpdate) TaskConfig() *aurora.TaskConfig { return j.task.TaskConfig() } diff --git a/task.go b/task.go index e4037c3..e055190 100644 --- a/task.go +++ b/task.go @@ -78,7 +78,8 @@ func TaskFromThrift(config *aurora.TaskConfig) *AuroraTask { Role(config.Job.Role). Name(config.Job.Name). MaxFailure(config.MaxTaskFailures). - IsService(config.IsService) + IsService(config.IsService). + Priority(config.Priority) if config.Tier != nil { newTask.Tier(*config.Tier) @@ -287,6 +288,12 @@ func (t *AuroraTask) IsService(isService bool) *AuroraTask { return t } +//set priority for preemption or priority-queueing +func (t *AuroraTask) Priority(priority int32) *AuroraTask { + t.task.Priority = priority + return t +} + // Add a list of URIs with the same extract and cache configuration. Scheduler must have // --enable_mesos_fetcher flag enabled. Currently there is no duplicate detection. func (t *AuroraTask) AddURIs(extract bool, cache bool, values ...string) *AuroraTask { diff --git a/task_test.go b/task_test.go index 14d06c8..deaf7b1 100644 --- a/task_test.go +++ b/task_test.go @@ -34,6 +34,7 @@ func TestAuroraTask_Clone(t *testing.T) { RAM(643). Disk(1000). IsService(true). + Priority(1). AddPorts(10). Tier("preferred"). MaxFailure(23). From 306603795b077eedee0b0f1a2edccef1eae6d3ef Mon Sep 17 00:00:00 2001 From: lenhattan86 Date: Wed, 6 Oct 2021 22:37:54 -0700 Subject: [PATCH 16/23] fix unit test error for GetJobSummary --- realis_e2e_test.go | 56 +++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 884a485..d9c007e 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -824,50 +824,46 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { assert.NoError(t, r.KillJob(strategy.JobKey())) } -// Test configuring an executor that doesn't exist for CreateJob API func TestRealisClient_GetJobSummary(t *testing.T) { role := "vagrant" + env := "prod" + name := "GetJobSummaryJob" // Create a single job - job := realis.NewJobUpdate(). - Environment("prod"). + job := realis.NewJob(). + Environment(env). Role(role). - Name("TestGetJobSummary"). + Name(name). ThermosExecutor(thermosExec). CPU(.25). RAM(4). Disk(10). - InstanceCount(3). - WatchTime(20 * time.Second). - IsService(true). - BatchSize(2) - - result, err := r.CreateService(job) + InstanceCount(1). + IsService(false) + err := r.CreateJob(job) assert.NoError(t, err) - assert.NotNil(t, result) - var ok bool - var mErr error + success, err := r.MonitorScheduleStatus(job.JobKey(), + job.GetInstanceCount(), + aurora.ACTIVE_STATES, + 1*time.Second, + 150*time.Second) + assert.True(t, success) + assert.NoError(t, err) - if ok, mErr = r.MonitorJobUpdate(*result.GetKey(), 5*time.Second, 4*time.Minute); !ok || mErr != nil { - // Update may already be in a terminal state so don't check for error - err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") - - err = r.KillJob(job.JobKey()) - - assert.NoError(t, err) - } - - assert.True(t, ok) - assert.NoError(t, mErr) - // get job summary of the role - summary, mErr := r.GetJobSummary(role) - assert.NoError(t, mErr) + // get job summaries of the role + summary, err := r.GetJobSummary(role) + assert.NoError(t, err) assert.NotNil(t, summary) - assert.Equal(t, len(summary.Summaries), 1) + jobCount := 0 + for _, s := range summary.Summaries { + jobKey := s.Job.TaskConfig.Job + if jobKey.Environment == env && jobKey.Name == name { + jobCount++ + } + } + assert.Equal(t, 1, jobCount) - // Kill task test task after confirming it came up fine err = r.KillJob(job.JobKey()) - assert.NoError(t, err) } From fe664178ceb9fe51b0155b0af7be5dab05492ce6 Mon Sep 17 00:00:00 2001 From: lenhattan86 Date: Fri, 15 Oct 2021 12:18:26 -0700 Subject: [PATCH 17/23] Add tier & production in task config (#14) --- docs/getting-started.md | 6 +++++ docs/leveraging-the-library.md | 3 +++ examples/client.go | 9 ++++++++ examples/jsonClient.go | 2 ++ job.go | 5 +++++ jobUpdate.go | 5 +++++ realis_e2e_test.go | 40 ++++++++++++++++++++++++++++++---- task.go | 9 ++++++++ task_test.go | 1 + 9 files changed, 76 insertions(+), 4 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index b16ac3f..b894d06 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -247,6 +247,9 @@ job = realis.NewJob(). RAM(64). Disk(100). IsService(false). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1). AddLabel("fileName", "sample-app/docker-compose.yml"). @@ -291,6 +294,9 @@ job = realis.NewJob(). RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1) ``` diff --git a/docs/leveraging-the-library.md b/docs/leveraging-the-library.md index 464bddd..2165ae1 100644 --- a/docs/leveraging-the-library.md +++ b/docs/leveraging-the-library.md @@ -25,6 +25,9 @@ job = realis.NewJob(). RAM(64). Disk(100). IsService(false). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1). AddLabel("fileName", "sample-app/docker-compose.yml"). diff --git a/examples/client.go b/examples/client.go index f598562..367f785 100644 --- a/examples/client.go +++ b/examples/client.go @@ -124,6 +124,9 @@ func main() { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1). ThermosExecutor(thermosExec) @@ -138,6 +141,9 @@ func main() { RAM(512). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(4). AddLabel("fileName", "sample-app/docker-compose.yml"). @@ -151,6 +157,9 @@ func main() { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1) default: diff --git a/examples/jsonClient.go b/examples/jsonClient.go index 68ea1ca..c53516b 100644 --- a/examples/jsonClient.go +++ b/examples/jsonClient.go @@ -177,6 +177,8 @@ func main() { RAM(job.RAM). Disk(job.Disk). IsService(job.Service). + Tier("preemptible"). + Priority(0). InstanceCount(job.Instances). AddPorts(job.Ports) diff --git a/job.go b/job.go index 698ecfa..adf3958 100644 --- a/job.go +++ b/job.go @@ -161,6 +161,11 @@ func (j *AuroraJob) Priority(priority int32) *AuroraJob { return j } +func (j *AuroraJob) Production(production bool) *AuroraJob { + j.task.Production(production) + return j +} + func (j *AuroraJob) TaskConfig() *aurora.TaskConfig { return j.task.TaskConfig() } diff --git a/jobUpdate.go b/jobUpdate.go index 0f231f2..248a65d 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -226,6 +226,11 @@ func (j *JobUpdate) Priority(priority int32) *JobUpdate { return j } +func (j *JobUpdate) Production(production bool) *JobUpdate { + j.task.Production(production) + return j +} + func (j *JobUpdate) TaskConfig() *aurora.TaskConfig { return j.task.TaskConfig() } diff --git a/realis_e2e_test.go b/realis_e2e_test.go index d9c007e..63d9d03 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -100,6 +100,9 @@ func TestBadCredentials(t *testing.T) { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(2). AddPorts(1) @@ -232,6 +235,9 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(2). AddPorts(1) @@ -339,6 +345,9 @@ func TestRealisClient_CreateService_WithPulse_Thermos(t *testing.T) { Disk(100). ThermosExecutor(thermosExec). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(2). AddPorts(1). AddLabel("currentTime", time.Now().String()). @@ -424,6 +433,9 @@ func TestRealisClient_CreateService(t *testing.T) { InstanceCount(3). WatchTime(20 * time.Second). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). BatchSize(2) result, err := r.CreateService(job) @@ -488,6 +500,9 @@ func TestRealisClient_ScheduleCronJob_Thermos(t *testing.T) { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(1). AddPorts(1). CronSchedule("* * * * *"). @@ -704,6 +719,9 @@ func TestRealisClient_PartitionPolicy(t *testing.T) { RAM(64). Disk(100). IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). InstanceCount(2). BatchSize(2). PartitionPolicy(true, partitionDelay) @@ -734,7 +752,10 @@ func TestRealisClient_UpdateStrategies(t *testing.T) { RAM(4). Disk(10). InstanceCount(6). - IsService(true) + IsService(true). + Production(false). + Tier("preemptible"). + Priority(0) // Needed to populate the task config correctly assert.NoError(t, job.BuildThermosPayload()) @@ -798,7 +819,11 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { RAM(4). Disk(10). InstanceCount(6). - IsService(true) + IsService(true). + Production(false). + Tier("preemptible"). + Priority(0) + updateGroups := []int32{1, 2, 3} strategy := realis.JobUpdateFromAuroraTask(job.AuroraTask()). VariableBatchStrategy(true, updateGroups...). @@ -837,8 +862,15 @@ func TestRealisClient_GetJobSummary(t *testing.T) { CPU(.25). RAM(4). Disk(10). - InstanceCount(1). - IsService(false) + InstanceCount(3). + WatchTime(20 * time.Second). + IsService(true). + Production(false). + Tier("preemptible"). + Priority(0). + BatchSize(2) + + result, err := r.CreateService(job) err := r.CreateJob(job) assert.NoError(t, err) diff --git a/task.go b/task.go index e055190..e9aaa98 100644 --- a/task.go +++ b/task.go @@ -85,6 +85,10 @@ func TaskFromThrift(config *aurora.TaskConfig) *AuroraTask { newTask.Tier(*config.Tier) } + if config.Production != nil { + newTask.Production(*config.Production) + } + if config.ExecutorConfig != nil { newTask. ExecutorName(config.ExecutorConfig.Name). @@ -294,6 +298,11 @@ func (t *AuroraTask) Priority(priority int32) *AuroraTask { return t } +func (t *AuroraTask) Production(production bool) *AuroraTask { + t.task.Production = &production + return t +} + // Add a list of URIs with the same extract and cache configuration. Scheduler must have // --enable_mesos_fetcher flag enabled. Currently there is no duplicate detection. func (t *AuroraTask) AddURIs(extract bool, cache bool, values ...string) *AuroraTask { diff --git a/task_test.go b/task_test.go index deaf7b1..8c0a026 100644 --- a/task_test.go +++ b/task_test.go @@ -35,6 +35,7 @@ func TestAuroraTask_Clone(t *testing.T) { Disk(1000). IsService(true). Priority(1). + Production(false). AddPorts(10). Tier("preferred"). MaxFailure(23). From 907430768cd4df240ceca14158cd86cc51301fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A1n=20I=2E=20Del=20Valle?= Date: Wed, 20 Oct 2021 10:52:12 -0700 Subject: [PATCH 18/23] Misc. fixes for tests (#16) * Bumping up CI to go1.17 and enabling CI for PRs. * Adding go.sum now that issues seem to have gone away. * Bump up aurora to 0.25.0 and mesos to 1.9.0 * Fixing Mac tests. Adding extra time for killing thermos jobs. * Reduce the thermos overhead for unit tests Co-authored-by: lenhattan86 --- .github/workflows/main.yml | 10 ++++++++-- .gitignore | 3 --- docker-compose.yml | 7 ++++--- go.sum | 18 +++++++++++++++++ jobUpdate.go | 2 +- monitors.go | 7 ++++--- realis_e2e_test.go | 41 ++++++++++++++++---------------------- runTestsMac.sh | 2 +- 8 files changed, 53 insertions(+), 37 deletions(-) create mode 100644 go.sum diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 665cbd8..485b6e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,12 @@ name: CI -on: [push] +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: build: @@ -12,7 +18,7 @@ jobs: - name: Setup Go for use with actions uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.17 - name: Install goimports run: go get golang.org/x/tools/cmd/goimports - name: Set env with list of directories in repo containin go code diff --git a/.gitignore b/.gitignore index 6cd33c9..3f124ef 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,3 @@ _testmain.go # Example client build examples/client examples/jsonClient - -# Use checksum database -go.sum diff --git a/docker-compose.yml b/docker-compose.yml index f103d35..348b85b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: ipv4_address: 192.168.33.2 master: - image: rdelvalle/mesos-master:1.6.2 + image: quay.io/aurorascheduler/mesos-master:1.9.0 restart: on-failure ports: - "5050:5050" @@ -32,7 +32,7 @@ services: - zk agent-one: - image: rdelvalle/mesos-agent:1.6.2 + image: quay.io/aurorascheduler/mesos-agent:1.9.0 pid: host restart: on-failure ports: @@ -56,7 +56,7 @@ services: - zk aurora-one: - image: rdelvalle/aurora:0.22.0 + image: quay.io/aurorascheduler/scheduler:0.25.0 pid: host ports: - "8081:8081" @@ -70,6 +70,7 @@ services: -shiro_realm_modules=INI_AUTHNZ -shiro_ini_path=/etc/aurora/security.ini -min_required_instances_for_sla_check=1 + -thermos_executor_cpu=0.09 volumes: - ./.aurora-config:/etc/aurora networks: diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..9324c97 --- /dev/null +++ b/go.sum @@ -0,0 +1,18 @@ +github.com/apache/thrift v0.14.0 h1:vqZ2DP42i8th2OsgCcYZkirtbzvpZEFx53LiWDJXIAs= +github.com/apache/thrift v0.14.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a h1:EYL2xz/Zdo0hyqdZMXR4lmT2O11jDLTPCEqIe/FR6W4= +github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.0 h1:DMOzIV76tmoDNE9pX6RSN0aDtCYeCg5VueieJaAo1uw= +github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/jobUpdate.go b/jobUpdate.go index 248a65d..d880c29 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -77,7 +77,7 @@ func (j *JobUpdate) BatchSize(size int32) *JobUpdate { // Minimum number of seconds a shard must remain in RUNNING state before considered a success. func (j *JobUpdate) WatchTime(timeout time.Duration) *JobUpdate { - j.request.Settings.MinWaitInInstanceRunningMs = int32(timeout.Seconds() * 1000) + j.request.Settings.MinWaitInInstanceRunningMs = int32(timeout.Milliseconds()) return j } diff --git a/monitors.go b/monitors.go index 963c017..552d12e 100644 --- a/monitors.go +++ b/monitors.go @@ -245,7 +245,7 @@ func (c *Client) MonitorHostMaintenance(hosts []string, } } -// AutoPaused monitor is a special monitor for auto pause enabled batch updates. This monitor ensures that the update +// MonitorAutoPausedUpdate is a special monitor for auto pause enabled batch updates. This monitor ensures that the update // being monitored is capable of auto pausing and has auto pausing enabled. After verifying this information, // the monitor watches for the job to enter the ROLL_FORWARD_PAUSED state and calculates the current batch // the update is in using information from the update configuration. @@ -294,8 +294,9 @@ func (c *Client) MonitorAutoPausedUpdate(key aurora.JobUpdateKey, interval, time return -1, err } - // Summary 0 is assumed to exist because MonitorJobUpdateQuery will return an error if there is Summaries - if summary[0].State.Status != aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED { + // Summary 0 is assumed to exist because MonitorJobUpdateQuery will return an error if there is no summaries + if !(summary[0].State.Status == aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED || + summary[0].State.Status == aurora.JobUpdateStatus_ROLLED_FORWARD) { return -1, errors.Errorf("update is in a terminal state %v", summary[0].State.Status) } diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 63d9d03..4707a18 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -94,7 +94,7 @@ func TestBadCredentials(t *testing.T) { job := realis.NewJob(). Environment("prod"). Role("vagrant"). - Name("create_thermos_job_test"). + Name("create_thermos_job_bad_creds_test"). ThermosExecutor(thermosExec). CPU(.5). RAM(64). @@ -209,7 +209,6 @@ func TestValidAuroraURL(t *testing.T) { } func TestRealisClient_ReestablishConn(t *testing.T) { - // Test that we're able to tear down the old connection and create a new one. err := r.ReestablishConn() @@ -220,11 +219,9 @@ func TestGetCACerts(t *testing.T) { certs, err := realis.GetCerts("./examples/certs") assert.NoError(t, err) assert.Equal(t, len(certs.Subjects()), 2) - } func TestRealisClient_CreateJob_Thermos(t *testing.T) { - role := "vagrant" job := realis.NewJob(). Environment("prod"). @@ -251,7 +248,7 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) { // Fetch all Jobs result, err := r.GetJobs(role) - fmt.Printf("GetJobs length: %+v \n", len(result.Configs)) + fmt.Println("GetJobs length: ", len(result.Configs)) assert.Len(t, result.Configs, 1) assert.NoError(t, err) @@ -272,7 +269,7 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) { err := r.KillJob(job.JobKey()) assert.NoError(t, err) - success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 60*time.Second) + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) assert.True(t, success) assert.NoError(t, err) }) @@ -280,7 +277,6 @@ func TestRealisClient_CreateJob_Thermos(t *testing.T) { // Test configuring an executor that doesn't exist for CreateJob API func TestRealisClient_CreateJob_ExecutorDoesNotExist(t *testing.T) { - // Create a single job job := realis.NewJob(). Environment("prod"). @@ -299,7 +295,6 @@ func TestRealisClient_CreateJob_ExecutorDoesNotExist(t *testing.T) { // Test configuring an executor that doesn't exist for CreateJob API func TestRealisClient_GetPendingReason(t *testing.T) { - env := "prod" role := "vagrant" name := "pending_reason_test" @@ -333,7 +328,6 @@ func TestRealisClient_GetPendingReason(t *testing.T) { } func TestRealisClient_CreateService_WithPulse_Thermos(t *testing.T) { - fmt.Println("Creating service") role := "vagrant" job := realis.NewJobUpdate(). @@ -813,18 +807,15 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { job := realis.NewJob(). Environment("prod"). Role("vagrant"). - Name("BatchAwareAutoPauseTest"). + Name("batch_aware_auto_pause_test"). ThermosExecutor(thermosExec). CPU(.01). RAM(4). Disk(10). InstanceCount(6). - IsService(true). - Production(false). - Tier("preemptible"). - Priority(0) + IsService(true) - updateGroups := []int32{1, 2, 3} + updateGroups := []int32{1, 3} strategy := realis.JobUpdateFromAuroraTask(job.AuroraTask()). VariableBatchStrategy(true, updateGroups...). InstanceCount(6). @@ -837,22 +828,28 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { key := *result.GetKey() for i := range updateGroups { - curStep, mErr := r.MonitorAutoPausedUpdate(key, time.Second*5, time.Second*240) + curStep, mErr := r.MonitorAutoPausedUpdate(key, time.Second*5, time.Minute*5) if mErr != nil { + fmt.Println(mErr) // Update may already be in a terminal state so don't check for error - assert.NoError(t, r.AbortJobUpdate(key, "Monitor timed out.")) + _ = r.AbortJobUpdate(key, "Monitor timed out.") } assert.Equal(t, i, curStep) - require.NoError(t, r.ResumeJobUpdate(key, "auto resuming test")) + + if i != len(updateGroups)-1 { + require.NoError(t, err) + require.NoError(t, r.ResumeJobUpdate(key, "auto resuming test")) + } } + assert.NoError(t, r.AbortJobUpdate(key, "")) assert.NoError(t, r.KillJob(strategy.JobKey())) } func TestRealisClient_GetJobSummary(t *testing.T) { role := "vagrant" env := "prod" - name := "GetJobSummaryJob" + name := "test_get_job_summary" // Create a single job job := realis.NewJob(). Environment(env). @@ -863,14 +860,10 @@ func TestRealisClient_GetJobSummary(t *testing.T) { RAM(4). Disk(10). InstanceCount(3). - WatchTime(20 * time.Second). IsService(true). Production(false). Tier("preemptible"). - Priority(0). - BatchSize(2) - - result, err := r.CreateService(job) + Priority(0) err := r.CreateJob(job) assert.NoError(t, err) diff --git a/runTestsMac.sh b/runTestsMac.sh index c54994a..2791ada 100644 --- a/runTestsMac.sh +++ b/runTestsMac.sh @@ -1,4 +1,4 @@ #!/bin/bash # Since we run our docker compose setup in bridge mode to be able to run on MacOS, we have to launch a Docker container within the bridge network in order to avoid any routing issues. -docker run --rm -t -v $(pwd):/go/src/github.com/aurora-scheduler/gorealis --network gorealis_aurora_cluster golang:1.13-stretch go test -v github.com/aurora-scheduler/gorealis $@ +docker run --rm -t -w /gorealis -v $GOPATH/pkg:/go/pkg -v $(pwd):/gorealis --network gorealis_aurora_cluster golang:1.17-buster go test -v github.com/aurora-scheduler/gorealis/v2 $@ From 5d0998647a80fd1461563881928833b819c7b429 Mon Sep 17 00:00:00 2001 From: "Tan N. Le" Date: Mon, 1 Nov 2021 18:15:51 -0700 Subject: [PATCH 19/23] default policy for slaDrainHosts (#17) --- realis_admin.go | 12 ++++++++++++ realis_config.go | 10 ++++++++++ realis_e2e_test.go | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/realis_admin.go b/realis_admin.go index 9530031..f2759ea 100644 --- a/realis_admin.go +++ b/realis_admin.go @@ -59,6 +59,18 @@ func (c *Client) SLADrainHosts(policy *aurora.SlaPolicy, timeout int64, hosts .. return nil, errors.New("no hosts provided to drain") } + if policy == nil || policy.CountSetFieldsSlaPolicy() == 0 { + policy = &defaultSlaPolicy + c.logger.Printf("Warning: start draining with default sla policy %v", policy) + } + + if timeout < 0 { + c.logger.Printf("Warning: timeout %d secs is invalid, draining with default timeout %d secs", + timeout, + defaultSlaDrainTimeoutSecs) + timeout = defaultSlaDrainTimeoutSecs + } + drainList := aurora.NewHosts() drainList.HostNames = hosts diff --git a/realis_config.go b/realis_config.go index 7bb09fc..4b2b96f 100644 --- a/realis_config.go +++ b/realis_config.go @@ -19,6 +19,7 @@ import ( "time" "github.com/apache/thrift/lib/go/thrift" + "github.com/aurora-scheduler/gorealis/v2/gen-go/apache/aurora" ) type clientConfig struct { @@ -48,6 +49,15 @@ var defaultBackoff = Backoff{ Jitter: 0.1, } +var defaultSlaPolicy = aurora.SlaPolicy{ + PercentageSlaPolicy: &aurora.PercentageSlaPolicy{ + Percentage: 66, + DurationSecs: 300, + }, +} + +const defaultSlaDrainTimeoutSecs = 900 + type TransportProtocol int const ( diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 4707a18..55fab19 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -612,6 +612,39 @@ func TestRealisClient_SLADrainHosts(t *testing.T) { 5*time.Second, 10*time.Second) assert.NoError(t, err) + + // slaDrainHosts goes with default policy if no policy is specified + _, err = r.SLADrainHosts(nil, 30, hosts...) + if err != nil { + fmt.Printf("error: %+v\n", err.Error()) + os.Exit(1) + } + hostResults, err = r.MonitorHostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1*time.Second, + 50*time.Second) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.NoError(t, err) + + _, err = r.EndMaintenance(hosts...) + assert.NoError(t, err) + + _, err = r.SLADrainHosts(&aurora.SlaPolicy{}, 30, hosts...) + if err != nil { + fmt.Printf("error: %+v\n", err.Error()) + os.Exit(1) + } + hostResults, err = r.MonitorHostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1*time.Second, + 50*time.Second) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.NoError(t, err) + + _, err = r.EndMaintenance(hosts...) + assert.NoError(t, err) } // Test multiple go routines using a single connection From 4258634ccf2f675e00c36b6fadbd2b927901b5e2 Mon Sep 17 00:00:00 2001 From: "Tan N. Le" Date: Thu, 28 Jul 2022 19:27:53 -0700 Subject: [PATCH 20/23] Capacity report (#18) - pull capacity report via /offers endpoint. - calculate how many tasks (with resource and constraints) can be fit in the cluster. examples of using the above 2 features are in aurora-scheduler/australis#33 --- docker-compose.yml | 53 ++++- offer.go | 434 ++++++++++++++++++++++++++++++++++++++ realis.go | 6 + realis_e2e_test.go | 509 ++++++++++++++++++++++++++++++++++++++++++++- util.go | 20 ++ 5 files changed, 1012 insertions(+), 10 deletions(-) create mode 100644 offer.go diff --git a/docker-compose.yml b/docker-compose.yml index 348b85b..6fd40ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,10 +41,11 @@ services: MESOS_MASTER: zk://192.168.33.2:2181/mesos MESOS_CONTAINERIZERS: docker,mesos MESOS_PORT: 5051 - MESOS_HOSTNAME: localhost + MESOS_HOSTNAME: agent-one MESOS_RESOURCES: ports(*):[11000-11999] MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' MESOS_WORK_DIR: /tmp/mesos + MESOS_ATTRIBUTES: 'host:agent-one;rack:1;zone:west' networks: aurora_cluster: ipv4_address: 192.168.33.4 @@ -55,6 +56,56 @@ services: depends_on: - zk + agent-two: + image: quay.io/aurorascheduler/mesos-agent:1.9.0 + pid: host + restart: on-failure + ports: + - "5052:5051" + environment: + MESOS_MASTER: zk://192.168.33.2:2181/mesos + MESOS_CONTAINERIZERS: docker,mesos + MESOS_PORT: 5051 + MESOS_HOSTNAME: agent-two + MESOS_RESOURCES: ports(*):[11000-11999] + MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' + MESOS_WORK_DIR: /tmp/mesos + MESOS_ATTRIBUTES: 'host:agent-two;rack:2;zone:west' + networks: + aurora_cluster: + ipv4_address: 192.168.33.5 + + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - zk + + agent-three: + image: quay.io/aurorascheduler/mesos-agent:1.9.0 + pid: host + restart: on-failure + ports: + - "5053:5051" + environment: + MESOS_MASTER: zk://192.168.33.2:2181/mesos + MESOS_CONTAINERIZERS: docker,mesos + MESOS_PORT: 5051 + MESOS_HOSTNAME: agent-three + MESOS_RESOURCES: ports(*):[11000-11999] + MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' + MESOS_WORK_DIR: /tmp/mesos + MESOS_ATTRIBUTES: 'host:agent-three;rack:2;zone:west;dedicated:vagrant/bar' + networks: + aurora_cluster: + ipv4_address: 192.168.33.6 + + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - zk + aurora-one: image: quay.io/aurorascheduler/scheduler:0.25.0 pid: host diff --git a/offer.go b/offer.go new file mode 100644 index 0000000..6f5346f --- /dev/null +++ b/offer.go @@ -0,0 +1,434 @@ +/** + * Licensed 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 realis + +import ( + "bytes" + "crypto/tls" + "encoding/json" + "fmt" + "net/http" + "strings" + + "github.com/aurora-scheduler/gorealis/v2/gen-go/apache/aurora" +) + +// Offers on [aurora-scheduler]/offers endpoint +type Offer struct { + ID struct { + Value string `json:"value"` + } `json:"id"` + FrameworkID struct { + Value string `json:"value"` + } `json:"framework_id"` + AgentID struct { + Value string `json:"value"` + } `json:"agent_id"` + Hostname string `json:"hostname"` + URL struct { + Scheme string `json:"scheme"` + Address struct { + Hostname string `json:"hostname"` + IP string `json:"ip"` + Port int `json:"port"` + } `json:"address"` + Path string `json:"path"` + Query []interface{} `json:"query"` + } `json:"url"` + Resources []struct { + Name string `json:"name"` + Type string `json:"type"` + Ranges struct { + Range []struct { + Begin int `json:"begin"` + End int `json:"end"` + } `json:"range"` + } `json:"ranges,omitempty"` + Role string `json:"role"` + Reservations []interface{} `json:"reservations"` + Scalar struct { + Value float64 `json:"value"` + } `json:"scalar,omitempty"` + } `json:"resources"` + Attributes []struct { + Name string `json:"name"` + Type string `json:"type"` + Text struct { + Value string `json:"value"` + } `json:"text"` + } `json:"attributes"` + ExecutorIds []struct { + Value string `json:"value"` + } `json:"executor_ids"` +} + +// hosts on [aurora-scheduler]/maintenance endpoint +type MaintenanceList struct { + Drained []string `json:"DRAINED"` + Scheduled []string `json:"SCHEDULED"` + Draining map[string][]string `json:"DRAINING"` +} + +type OfferCount map[float64]int64 +type OfferGroupReport map[string]OfferCount +type OfferReport map[string]OfferGroupReport + +// MaintenanceHosts list all the hosts under maintenance +func (c *Client) MaintenanceHosts() ([]string, error) { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: c.config.insecureSkipVerify}, + } + + request := &http.Client{Transport: tr} + + resp, err := request.Get(fmt.Sprintf("%s/maintenance", c.GetSchedulerURL())) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + buf := new(bytes.Buffer) + if _, err := buf.ReadFrom(resp.Body); err != nil { + return nil, err + } + + var list MaintenanceList + + if err := json.Unmarshal(buf.Bytes(), &list); err != nil { + return nil, err + } + + hosts := append(list.Drained, list.Scheduled...) + + for drainingHost := range list.Draining { + hosts = append(hosts, drainingHost) + } + + return hosts, nil +} + +// Offers pulls data from /offers endpoint +func (c *Client) Offers() ([]Offer, error) { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: c.config.insecureSkipVerify}, + } + + request := &http.Client{Transport: tr} + + resp, err := request.Get(fmt.Sprintf("%s/offers", c.GetSchedulerURL())) + if err != nil { + return []Offer{}, err + } + defer resp.Body.Close() + + buf := new(bytes.Buffer) + if _, err := buf.ReadFrom(resp.Body); err != nil { + return nil, err + } + + var offers []Offer + + if err := json.Unmarshal(buf.Bytes(), &offers); err != nil { + return []Offer{}, err + } + + return offers, nil +} + +// AvailOfferReport returns a detailed summary of offers available for use. +// For example, 2 nodes offer 32 cpus and 10 nodes offer 1 cpus. +func (c *Client) AvailOfferReport() (OfferReport, error) { + maintHosts, err := c.MaintenanceHosts() + if err != nil { + return nil, err + } + + maintHostSet := map[string]bool{} + for _, h := range maintHosts { + maintHostSet[h] = true + } + + // Get a list of offers + offers, err := c.Offers() + if err != nil { + return nil, err + } + + report := OfferReport{} + + for _, o := range offers { + if maintHostSet[o.Hostname] { + continue + } + + group := "non-dedicated" + for _, a := range o.Attributes { + if a.Name == "dedicated" { + group = a.Text.Value + break + } + } + + if _, ok := report[group]; !ok { + report[group] = map[string]OfferCount{} + } + + for _, r := range o.Resources { + + if _, ok := report[group][r.Name]; !ok { + report[group][r.Name] = OfferCount{} + } + + val := 0.0 + switch r.Type { + case "SCALAR": + val = r.Scalar.Value + case "RANGES": + for _, pr := range r.Ranges.Range { + val += float64(pr.End - pr.Begin + 1) + } + default: + return nil, fmt.Errorf("%s is not supported", r.Type) + } + + report[group][r.Name][val]++ + } + } + + return report, nil +} + +// FitTasks computes the number tasks can be fit in a list of offer +func (c *Client) FitTasks(taskConfig *aurora.TaskConfig, offers []Offer) (int64, error) { + // count the number of tasks per limit contraint: limit.name -> limit.value -> count + limitCounts := map[string]map[string]int64{} + for _, c := range taskConfig.Constraints { + if c.Constraint.Limit != nil { + limitCounts[c.Name] = map[string]int64{} + } + } + + request := ResourcesToMap(taskConfig.Resources) + + // validate resource request + if len(request) == 0 { + return -1, fmt.Errorf("Resource request %v must not be empty", request) + } + + isValid := false + for _, resVal := range request { + if resVal > 0 { + isValid = true + break + } + } + + if !isValid { + return -1, fmt.Errorf("Resource request %v is not valid", request) + } + + // pull the list of hosts under maintenance + maintHosts, err := c.MaintenanceHosts() + if err != nil { + return -1, err + } + + maintHostSet := map[string]bool{} + for _, h := range maintHosts { + maintHostSet[h] = true + } + + numTasks := int64(0) + + for _, o := range offers { + // skip the hosts under maintenance + if maintHostSet[o.Hostname] { + continue + } + + numTasksPerOffer := int64(-1) + + for resName, resVal := range request { + // skip as we can fit a infinite number of tasks with 0 demand. + if resVal == 0 { + continue + } + + avail := 0.0 + for _, r := range o.Resources { + if r.Name != resName { + continue + } + + switch r.Type { + case "SCALAR": + avail = r.Scalar.Value + case "RANGES": + for _, pr := range r.Ranges.Range { + avail += float64(pr.End - pr.Begin + 1) + } + default: + return -1, fmt.Errorf("%s is not supported", r.Type) + } + } + + numTasksPerResource := int64(avail / resVal) + + if numTasksPerResource < numTasksPerOffer || numTasksPerOffer < 0 { + numTasksPerOffer = numTasksPerResource + } + } + + numTasks += fitConstraints(taskConfig, &o, limitCounts, numTasksPerOffer) + } + + return numTasks, nil +} + +func fitConstraints(taskConfig *aurora.TaskConfig, + offer *Offer, + limitCounts map[string]map[string]int64, + numTasksPerOffer int64) int64 { + + // check dedicated attributes vs. constraints + if !isDedicated(offer, taskConfig.Job.Role, taskConfig.Constraints) { + return 0 + } + + limitConstraints := []*aurora.Constraint{} + + for _, c := range taskConfig.Constraints { + // look for corresponding attribute + attFound := false + for _, a := range offer.Attributes { + if a.Name == c.Name { + attFound = true + } + } + + // constraint not found in offer's attributes + if !attFound { + return 0 + } + + if c.Constraint.Value != nil && !valueConstraint(offer, c) { + // value constraint is not satisfied + return 0 + } else if c.Constraint.Limit != nil { + limitConstraints = append(limitConstraints, c) + limit := limitConstraint(offer, c, limitCounts) + + if numTasksPerOffer > limit && limit >= 0 { + numTasksPerOffer = limit + } + } + } + + // update limitCounts + for _, c := range limitConstraints { + for _, a := range offer.Attributes { + if a.Name == c.Name { + limitCounts[a.Name][a.Text.Value] += numTasksPerOffer + } + } + } + + return numTasksPerOffer +} + +func isDedicated(offer *Offer, role string, constraints []*aurora.Constraint) bool { + // get all dedicated attributes of an offer + dedicatedAtts := map[string]bool{} + for _, a := range offer.Attributes { + if a.Name == "dedicated" { + dedicatedAtts[a.Text.Value] = true + } + } + + if len(dedicatedAtts) == 0 { + return true + } + + // check if constraints are matching dedicated attributes + matched := false + for _, c := range constraints { + if c.Name == "dedicated" && c.Constraint.Value != nil { + found := false + + for _, v := range c.Constraint.Value.Values { + if dedicatedAtts[v] && strings.HasPrefix(v, fmt.Sprintf("%s/", role)) { + found = true + break + } + } + + if found { + matched = true + } else { + return false + } + } + } + + return matched +} + +// valueConstraint checks Value Contraints of task if the are matched by the offer. +// more details can be found here https://aurora.apache.org/documentation/latest/features/constraints/ +func valueConstraint(offer *Offer, constraint *aurora.Constraint) bool { + matched := false + + for _, a := range offer.Attributes { + if a.Name == constraint.Name { + for _, v := range constraint.Constraint.Value.Values { + matched = (a.Text.Value == v && !constraint.Constraint.Value.Negated) || + (a.Text.Value != v && constraint.Constraint.Value.Negated) + + if matched { + break + } + } + + if matched { + break + } + } + } + + return matched +} + +// limitConstraint limits the number of pods on a group which has the same attribute. +// more details can be found here https://aurora.apache.org/documentation/latest/features/constraints/ +func limitConstraint(offer *Offer, constraint *aurora.Constraint, limitCounts map[string]map[string]int64) int64 { + limit := int64(-1) + for _, a := range offer.Attributes { + // limit constraint found + if a.Name == constraint.Name { + curr := limitCounts[a.Name][a.Text.Value] + currLimit := int64(constraint.Constraint.Limit.Limit) + + if curr >= currLimit { + return 0 + } + + if currLimit-curr < limit || limit < 0 { + limit = currLimit - curr + } + } + } + + return limit +} diff --git a/realis.go b/realis.go index a7c536e..9d8428f 100644 --- a/realis.go +++ b/realis.go @@ -147,6 +147,8 @@ func NewClient(options ...ClientOption) (*Client, error) { return nil, errors.New("incomplete Options -- url, cluster.json, or Zookeeper address required") } + config.url = url + url, err = validateAuroraAddress(url) if err != nil { return nil, errors.Wrap(err, "unable to create realis object, invalid url") @@ -841,3 +843,7 @@ func (c *Client) RollbackJobUpdate(key aurora.JobUpdateKey, message string) erro } return nil } + +func (c *Client) GetSchedulerURL() string { + return c.config.url +} diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 55fab19..bf95f72 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -325,6 +325,10 @@ func TestRealisClient_GetPendingReason(t *testing.T) { err = r.KillJob(job.JobKey()) assert.NoError(t, err) + + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) } func TestRealisClient_CreateService_WithPulse_Thermos(t *testing.T) { @@ -410,6 +414,10 @@ pulseLoop: err = r.KillJob(job.JobKey()) assert.NoError(t, err) + + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) } // Test configuring an executor that doesn't exist for CreateJob API @@ -454,7 +462,10 @@ func TestRealisClient_CreateService(t *testing.T) { // Kill task test task after confirming it came up fine err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) assert.NoError(t, err) } @@ -513,10 +524,17 @@ func TestRealisClient_ScheduleCronJob_Thermos(t *testing.T) { t.Run("TestRealisClient_DeschedulerCronJob_Thermos", func(t *testing.T) { err := r.DescheduleCronJob(job.JobKey()) assert.NoError(t, err) + + err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) }) } func TestRealisClient_StartMaintenance(t *testing.T) { - hosts := []string{"localhost"} + hosts := []string{"agent-one"} _, err := r.StartMaintenance(hosts...) assert.NoError(t, err) @@ -526,7 +544,7 @@ func TestRealisClient_StartMaintenance(t *testing.T) { []aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED}, 1*time.Second, 50*time.Second) - assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true}, hostResults) assert.NoError(t, err) _, err = r.EndMaintenance(hosts...) @@ -542,7 +560,7 @@ func TestRealisClient_StartMaintenance(t *testing.T) { } func TestRealisClient_DrainHosts(t *testing.T) { - hosts := []string{"localhost"} + hosts := []string{"agent-one"} _, err := r.DrainHosts(hosts...) assert.NoError(t, err) @@ -552,7 +570,7 @@ func TestRealisClient_DrainHosts(t *testing.T) { []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, 1*time.Second, 50*time.Second) - assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true}, hostResults) assert.NoError(t, err) t.Run("TestRealisClient_MonitorNontransitioned", func(t *testing.T) { @@ -565,7 +583,7 @@ func TestRealisClient_DrainHosts(t *testing.T) { // Assert monitor returned an error that was not nil, and also a list of the non-transitioned hosts assert.Error(t, err) - assert.Equal(t, map[string]bool{"localhost": true, "IMAGINARY_HOST": false}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true, "IMAGINARY_HOST": false}, hostResults) }) t.Run("TestRealisClient_EndMaintenance", func(t *testing.T) { @@ -584,7 +602,7 @@ func TestRealisClient_DrainHosts(t *testing.T) { } func TestRealisClient_SLADrainHosts(t *testing.T) { - hosts := []string{"localhost"} + hosts := []string{"agent-one"} policy := aurora.SlaPolicy{PercentageSlaPolicy: &aurora.PercentageSlaPolicy{Percentage: 50.0}} _, err := r.SLADrainHosts(&policy, 30, hosts...) @@ -599,7 +617,7 @@ func TestRealisClient_SLADrainHosts(t *testing.T) { []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, 1*time.Second, 50*time.Second) - assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true}, hostResults) assert.NoError(t, err) _, err = r.EndMaintenance(hosts...) @@ -624,7 +642,7 @@ func TestRealisClient_SLADrainHosts(t *testing.T) { []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, 1*time.Second, 50*time.Second) - assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true}, hostResults) assert.NoError(t, err) _, err = r.EndMaintenance(hosts...) @@ -640,7 +658,7 @@ func TestRealisClient_SLADrainHosts(t *testing.T) { []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, 1*time.Second, 50*time.Second) - assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + assert.Equal(t, map[string]bool{"agent-one": true}, hostResults) assert.NoError(t, err) _, err = r.EndMaintenance(hosts...) @@ -681,6 +699,9 @@ func TestRealisClient_SessionThreadSafety(t *testing.T) { err = r.KillJob(job.JobKey()) assert.NoError(t, err) + success, err = r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) }() } @@ -767,6 +788,12 @@ func TestRealisClient_PartitionPolicy(t *testing.T) { assert.NoError(t, err) } + err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) } func TestRealisClient_UpdateStrategies(t *testing.T) { @@ -831,6 +858,10 @@ func TestRealisClient_UpdateStrategies(t *testing.T) { assert.NoError(t, r.AbortJobUpdate(key, "Monitor timed out.")) } assert.NoError(t, r.KillJob(strategy.jobUpdate.JobKey())) + + success, err := r.MonitorInstances(strategy.jobUpdate.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) }) } } @@ -877,6 +908,10 @@ func TestRealisClient_BatchAwareAutoPause(t *testing.T) { } assert.NoError(t, r.AbortJobUpdate(key, "")) assert.NoError(t, r.KillJob(strategy.JobKey())) + + success, err := r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) } func TestRealisClient_GetJobSummary(t *testing.T) { @@ -924,4 +959,460 @@ func TestRealisClient_GetJobSummary(t *testing.T) { err = r.KillJob(job.JobKey()) assert.NoError(t, err) + + success, err = r.MonitorInstances(job.JobKey(), 0, 1*time.Second, 90*time.Second) + assert.True(t, success) + assert.NoError(t, err) +} + +func TestRealisClient_Offers(t *testing.T) { + var offers []realis.Offer + + // since offers are being recycled, it take a few tries to get all of them. + i := 0 + for ; len(offers) < 3 && i < 5; i++ { + offers, _ = r.Offers() + time.Sleep(5 * time.Second) + } + + assert.NotEqual(t, i, 5) +} + +func TestRealisClient_MaintenanceHosts(t *testing.T) { + offers, err := r.Offers() + assert.NoError(t, err) + + for i := 0; i < len(offers); i++ { + _, err := r.DrainHosts(offers[i].Hostname) + assert.NoError(t, err) + + hosts, err := r.MaintenanceHosts() + assert.Equal(t, i+1, len(hosts)) + } + + // clean up + for i := 0; i < len(offers); i++ { + _, err := r.EndMaintenance(offers[i].Hostname) + assert.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = r.MonitorHostMaintenance( + []string{offers[i].Hostname}, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5*time.Second, + 10*time.Second) + assert.NoError(t, err) + } +} + +func TestRealisClient_AvailOfferReport(t *testing.T) { + var offers []realis.Offer + + i := 0 + for ; len(offers) < 3 && i < 5; i++ { + offers, _ = r.Offers() + time.Sleep(5 * time.Second) + } + + assert.NotEqual(t, i, 3) + + capacity, err := r.AvailOfferReport() + assert.NoError(t, err) + + // 2 groups for non-dedicated & dedicated + assert.Equal(t, 2, len(capacity)) + // 4 resources: cpus, disk, mem, ports + assert.Equal(t, 4, len(capacity["non-dedicated"])) +} + +func TestRealisClient_FitTasks(t *testing.T) { + var offers []realis.Offer + + i := 0 + for ; len(offers) < 3 && i < 5; i++ { + offers, _ = r.Offers() + time.Sleep(5 * time.Second) + } + + assert.NotEqual(t, i, 5) + + cpuPerOffer := 0.0 + for _, r := range offers[0].Resources { + if r.Name == "cpus" { + cpuPerOffer = r.Scalar.Value + } + } + + // make sure all offers have no running executor + for _, o := range offers { + assert.Equal(t, o.ExecutorIds[:0], o.ExecutorIds) + } + + validCpu := cpuPerOffer / 2 + inValidCpu := cpuPerOffer + 1 + gpu := int64(1) + + tests := []struct { + message string + role string + request aurora.Resource + constraints []*aurora.Constraint + expected int64 + isError bool + }{ + { + message: "task with gpu request", + role: "vagrant", + request: aurora.Resource{ + NumGpus: &gpu, + }, + expected: 0, + isError: false, + }, + { + message: "empty resource request", + role: "vagrant", + request: aurora.Resource{}, + expected: -1, + isError: true, + }, + { + message: "valid resource request", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + expected: 4, + isError: false, + }, + { + message: "invalid cpu request", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &inValidCpu, + }, + expected: 0, + isError: false, + }, + { + message: "dedicated constraint", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + + constraints: []*aurora.Constraint{ + { + Name: "dedicated", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"vagrant/bar"}, + }, + }, + }, + }, + expected: 2, + isError: false, + }, + { + message: "dedicated constraint with unauthorized role", + role: "unauthorized", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "dedicated", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"vagrant/bar"}, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "value constraint on zone", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "zone", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"west"}, + }, + }, + }, + }, + expected: 4, + isError: false, + }, + { + message: "negative value constraint on zone", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "zone", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: true, + Values: []string{"west"}, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "negative value constraint on host", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: true, + Values: []string{"agent-one"}, + }, + }, + }, + }, + expected: 2, + isError: false, + }, + { + message: "value constraint on unavailable zone", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "zone", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"east"}, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "value constraint on unavailable attribute", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "os", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"windows"}, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "1 value constraint with 2 values", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"agent-one", "agent-two"}, + }, + }, + }, + }, + expected: 4, + isError: false, + }, + { + message: "2 value constraints", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"agent-one"}, + }, + }, + }, + { + Name: "rack", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"2"}, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "limit constraint on host", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + }, + expected: 2, + isError: false, + }, + { + message: "limit constraint on zone", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "zone", + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + }, + expected: 1, + isError: false, + }, + { + message: "limit constraint on zone & host", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + { + Name: "zone", + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + }, + expected: 1, + isError: false, + }, + { + message: "limit constraint on unavailable zone", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "gpu-host", // no host has gpu-host attribute + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + }, + expected: 0, + isError: false, + }, + { + message: "limit & dedicated constraint", + role: "vagrant", + request: aurora.Resource{ + NumCpus: &validCpu, + }, + constraints: []*aurora.Constraint{ + { + Name: "dedicated", + Constraint: &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: false, + Values: []string{"vagrant/bar"}, + }, + }, + }, + { + Name: "host", + Constraint: &aurora.TaskConstraint{ + Limit: &aurora.LimitConstraint{ + Limit: 1, + }, + }, + }, + }, + expected: 1, + isError: false, + }, + } + + for _, tc := range tests { + task := aurora.NewTaskConfig() + task.Resources = []*aurora.Resource{&tc.request} + task.Constraints = tc.constraints + task.Job = &aurora.JobKey{ + Role: tc.role, + } + + numTasks, err := r.FitTasks(task, offers) + + if !tc.isError { + assert.NoError(t, err) + assert.Equal(t, tc.expected, numTasks, tc.message) + } else { + assert.Error(t, err) + } + } } diff --git a/util.go b/util.go index 90e3dcf..f993aaa 100644 --- a/util.go +++ b/util.go @@ -104,3 +104,23 @@ func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int { } return batchCount } + +func ResourcesToMap(resources []*aurora.Resource) map[string]float64 { + result := map[string]float64{} + + for _, resource := range resources { + if resource.NumCpus != nil { + result["cpus"] += *resource.NumCpus + } else if resource.RamMb != nil { + result["mem"] += float64(*resource.RamMb) + } else if resource.DiskMb != nil { + result["disk"] += float64(*resource.DiskMb) + } else if resource.NamedPort != nil { + result["ports"]++ + } else if resource.NumGpus != nil { + result["gpus"] += float64(*resource.NumGpus) + } + } + + return result +} From e33a2d99d8a3931ad0179019b52dc588f354febb Mon Sep 17 00:00:00 2001 From: "Tan N. Le" Date: Tue, 2 Aug 2022 09:55:36 -0700 Subject: [PATCH 21/23] release 2.28.0 (#19) --- .auroraversion | 2 +- realis.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.auroraversion b/.auroraversion index 8854156..4e8f395 100644 --- a/.auroraversion +++ b/.auroraversion @@ -1 +1 @@ -0.21.0 +0.26.0 diff --git a/realis.go b/realis.go index 9d8428f..1219e92 100644 --- a/realis.go +++ b/realis.go @@ -36,7 +36,7 @@ import ( "github.com/pkg/errors" ) -const VERSION = "2.22.1" +const VERSION = "2.28.0" type Client struct { config *clientConfig From 8db625730f2eaa49e0b1fef267c4b4339cd2e915 Mon Sep 17 00:00:00 2001 From: lawwong1 <105893156+lawwong1@users.noreply.github.com> Date: Wed, 24 Aug 2022 08:51:12 -0700 Subject: [PATCH 22/23] Support Australis API to get aurora master nodes and mesos master nodes (#20) --- clusters.go | 2 + clusters_test.go | 1 + examples/clusters.json | 1 + realis_e2e_test.go | 29 ++++++ zk.go | 205 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 238 insertions(+) diff --git a/clusters.go b/clusters.go index 49e93f6..c0e81dd 100644 --- a/clusters.go +++ b/clusters.go @@ -28,6 +28,7 @@ type Cluster struct { ZK string `json:"zk"` ZKPort int `json:"zk_port"` SchedZKPath string `json:"scheduler_zk_path"` + MesosZKPath string `json:"mesos_zk_path"` SchedURI string `json:"scheduler_uri"` ProxyURL string `json:"proxy_url"` AuthMechanism string `json:"auth_mechanism"` @@ -61,6 +62,7 @@ func GetDefaultClusterFromZKUrl(zkURL string) *Cluster { AuthMechanism: "UNAUTHENTICATED", ZK: zkURL, SchedZKPath: "/aurora/scheduler", + MesosZKPath: "/mesos", AgentRunDir: "latest", AgentRoot: "/var/lib/mesos", } diff --git a/clusters_test.go b/clusters_test.go index 48b2f03..f0bfd54 100644 --- a/clusters_test.go +++ b/clusters_test.go @@ -32,6 +32,7 @@ func TestLoadClusters(t *testing.T) { assert.Equal(t, clusters["devcluster"].Name, "devcluster") assert.Equal(t, clusters["devcluster"].ZK, "192.168.33.7") assert.Equal(t, clusters["devcluster"].SchedZKPath, "/aurora/scheduler") + assert.Equal(t, clusters["devcluster"].MesosZKPath, "/mesos") assert.Equal(t, clusters["devcluster"].AuthMechanism, "UNAUTHENTICATED") assert.Equal(t, clusters["devcluster"].AgentRunDir, "latest") assert.Equal(t, clusters["devcluster"].AgentRoot, "/var/lib/mesos") diff --git a/examples/clusters.json b/examples/clusters.json index c456bd8..33723a5 100644 --- a/examples/clusters.json +++ b/examples/clusters.json @@ -2,6 +2,7 @@ "name": "devcluster", "zk": "192.168.33.7", "scheduler_zk_path": "/aurora/scheduler", + "mesos_zk_path": "/mesos", "auth_mechanism": "UNAUTHENTICATED", "slave_run_directory": "latest", "slave_root": "/var/lib/mesos" diff --git a/realis_e2e_test.go b/realis_e2e_test.go index bf95f72..1f544d8 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -180,6 +180,35 @@ func TestLeaderFromZK(t *testing.T) { assert.Equal(t, "http://192.168.33.7:8081", url) } + +func TestMasterFromZK(t *testing.T) { + cluster := realis.GetDefaultClusterFromZKUrl("192.168.33.2:2181") + masterNodesMap, err := realis.MasterNodesFromZK(*cluster) + + assert.NoError(t, err) + + for _, hostnames := range masterNodesMap { + for _, hostname := range hostnames { + assert.NoError(t, err) + assert.Equal(t, "192.168.33.7", hostname) + } + } +} + +func TestMesosMasterFromZK(t *testing.T) { + cluster := realis.GetDefaultClusterFromZKUrl("192.168.33.2:2181") + masterNodesMap, err := realis.MesosMasterNodesFromZK(*cluster) + + assert.NoError(t, err) + + for _, hostnames := range masterNodesMap { + for _, hostname := range hostnames { + assert.NoError(t, err) + assert.Equal(t, "localhost", hostname) + } + } +} + func TestInvalidAuroraURL(t *testing.T) { for _, url := range []string{ "http://doesntexist.com:8081/apitest", diff --git a/zk.go b/zk.go index 9d5b659..b1c4ad4 100644 --- a/zk.go +++ b/zk.go @@ -286,3 +286,208 @@ func MesosFromZKOpts(options ...ZKOpt) (string, error) { return mesosURL, nil } + +// Retrieves current Aurora master nodes from ZK. +func MasterNodesFromZK(cluster Cluster) (map[string][]string, error) { + return MasterNodesFromZKOpts(ZKEndpoints(strings.Split(cluster.ZK, ",")...), ZKPath(cluster.SchedZKPath)) +} + +// Retrieves current Mesos master nodes/leader from ZK with a custom configuration. +func MasterNodesFromZKOpts(options ...ZKOpt) (map[string][]string, error) { + result := make(map[string][]string) + + // Load the default configuration for Zookeeper followed by overriding values with those provided by the caller. + config := &zkConfig{backoff: defaultBackoff, timeout: time.Second * 10, logger: NoopLogger{}} + for _, opt := range options { + opt(config) + } + + if len(config.endpoints) == 0 { + return nil, errors.New("no Zookeeper endpoints supplied") + } + + if config.path == "" { + return nil, errors.New("no Zookeeper path supplied") + } + + // Create a closure that allows us to use the ExponentialBackoff function. + retryErr := ExponentialBackoff(config.backoff, config.logger, func() (bool, error) { + + c, _, err := zk.Connect(config.endpoints, config.timeout, func(c *zk.Conn) { c.SetLogger(config.logger) }) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "Failed to connect to Zookeeper")) + } + + defer c.Close() + + // Open up descriptor for the ZK path given + children, _, _, err := c.ChildrenW(config.path) + if err != nil { + + // Sentinel error check as there is no other way to check. + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", config.path) + } + + return false, + NewTemporaryError(errors.Wrapf(err, "path %s doesn't exist on Zookeeper ", config.path)) + } + + // Get all the master nodes through all the children in the given path + serviceInst := new(ServiceInstance) + var hosts []string + for _, child := range children { + childPath := config.path + "/" + child + data, _, err := c.Get(childPath) + if err != nil { + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", childPath) + } + + return false, NewTemporaryError(errors.Wrap(err, "error fetching contents of leader")) + } + // Only leader is in json format. Have to parse data differently between member_ and not member_ + if strings.HasPrefix(child, "member_") { + err = json.Unmarshal([]byte(data), &serviceInst) + if err != nil { + return false, + NewTemporaryError(errors.Wrap(err, "unable to unmarshal contents of leader")) + } + // Should only be one endpoint. + // This should never be encountered as it would indicate Aurora + // writing bad info into Zookeeper but is kept here as a safety net. + if len(serviceInst.AdditionalEndpoints) > 1 { + return false, + NewTemporaryError( + errors.New("ambiguous endpoints in json blob, Aurora wrote bad info to ZK")) + } + + for _, v := range serviceInst.AdditionalEndpoints { + result["leader"] = append(result["leader"], v.Host) + } + } else { + // data is not in a json format + hosts = append(hosts, string(data)) + } + } + result["masterNodes"] = hosts + + // Master nodes data might not be available yet, try to fetch again. + if len(result["masterNodes"]) == 0 { + return false, NewTemporaryError(errors.New("no master nodes found")) + } + return true, nil + }) + + if retryErr != nil { + config.logger.Printf("Failed to get master nodes after %v attempts", config.backoff.Steps) + return nil, retryErr + } + + return result, nil +} + +// Retrieves current Mesos Aurora master nodes from ZK. +func MesosMasterNodesFromZK(cluster Cluster) (map[string][]string, error) { + return MesosMasterNodesFromZKOpts(ZKEndpoints(strings.Split(cluster.ZK, ",")...), ZKPath(cluster.MesosZKPath)) +} + +// Retrieves current mesos master nodes/leader from ZK with a custom configuration. +func MesosMasterNodesFromZKOpts(options ...ZKOpt) (map[string][]string, error) { + result := make(map[string][]string) + + // Load the default configuration for Zookeeper followed by overriding values with those provided by the caller.] + config := &zkConfig{backoff: defaultBackoff, timeout: time.Second * 10, logger: NoopLogger{}} + for _, opt := range options { + opt(config) + } + + if len(config.endpoints) == 0 { + return nil, errors.New("no Zookeeper endpoints supplied") + } + + if config.path == "" { + return nil, errors.New("no Zookeeper path supplied") + } + + // Create a closure that allows us to use the ExponentialBackoff function. + retryErr := ExponentialBackoff(config.backoff, config.logger, func() (bool, error) { + + c, _, err := zk.Connect(config.endpoints, config.timeout, func(c *zk.Conn) { c.SetLogger(config.logger) }) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "Failed to connect to Zookeeper")) + } + + defer c.Close() + + // Open up descriptor for the ZK path given + children, _, _, err := c.ChildrenW(config.path) + if err != nil { + + // Sentinel error check as there is no other way to check. + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", config.path) + } + + return false, + NewTemporaryError(errors.Wrapf(err, "path %s doesn't exist on Zookeeper ", config.path)) + } + + // Get all the master nodes through all the children in the given path + minScore := math.MaxInt64 + var mesosInstance MesosInstance + var hosts []string + for _, child := range children { + // Only the master nodes will start with json.info_ + if strings.HasPrefix(child, "json.info_") { + strs := strings.Split(child, "_") + if len(strs) < 2 { + config.logger.Printf("Zk node %v/%v's name is malformed.", config.path, child) + continue + } + score, err := strconv.Atoi(strs[1]) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "unable to read the zk node for Mesos.")) + } + + childPath := config.path + "/" + child + data, _, err := c.Get(childPath) + if err != nil { + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", childPath) + } + + return false, NewTemporaryError(errors.Wrap(err, "error fetching contents of leader")) + } + + err = json.Unmarshal([]byte(data), &mesosInstance) + if err != nil { + config.logger.Printf("%s", err) + return false, + NewTemporaryError(errors.Wrap(err, "unable to unmarshal contents of leader")) + } + // Combine all master nodes into comma-separated + // Return hostname instead of ip to be consistent with aurora master nodes + hosts = append(hosts, mesosInstance.Address.Hostname) + // get the leader from the child with the smallest score. + if score < minScore { + minScore = score + result["leader"] = append(result["leader"], mesosInstance.Address.Hostname) + } + } + } + result["masterNodes"] = hosts + // Master nodes data might not be available yet, try to fetch again. + if len(result["masterNodes"]) == 0 { + return false, NewTemporaryError(errors.New("no mesos master nodes found")) + } + return true, nil + }) + + if retryErr != nil { + config.logger.Printf("Failed to get mesos master nodes after %v attempts", config.backoff.Steps) + return nil, retryErr + } + + return result, nil +} From d2fd7b9ba9061fb601c0352e8a7feede090098bd Mon Sep 17 00:00:00 2001 From: lawwong1 <105893156+lawwong1@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:36:40 -0800 Subject: [PATCH 23/23] merge retry mechanism change from gorealis v1 to gorealis v2 (#21) --- .github/workflows/main.yml | 2 +- go.mod | 2 +- go.sum | 4 + helpers.go | 23 ++++ realis.go | 236 +++++++++++++++++++++++++++---------- realis_admin.go | 98 ++++++++------- realis_e2e_test.go | 68 ++++++++++- response/response.go | 4 + retry.go | 216 +++++++++++++++++++-------------- util.go | 2 +- 10 files changed, 449 insertions(+), 206 deletions(-) create mode 100644 helpers.go diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 485b6e4..eb459c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 diff --git a/go.mod b/go.mod index 3b3095f..c9c3dee 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ require ( github.com/apache/thrift v0.14.0 github.com/pkg/errors v0.9.1 github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a - github.com/stretchr/testify v1.5.0 + github.com/stretchr/testify v1.7.0 ) go 1.16 diff --git a/go.sum b/go.sum index 9324c97..d65a779 100644 --- a/go.sum +++ b/go.sum @@ -12,7 +12,11 @@ github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.0 h1:DMOzIV76tmoDNE9pX6RSN0aDtCYeCg5VueieJaAo1uw= github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/helpers.go b/helpers.go new file mode 100644 index 0000000..f1983db --- /dev/null +++ b/helpers.go @@ -0,0 +1,23 @@ +package realis + +import ( + "context" + + "github.com/aurora-scheduler/gorealis/v2/gen-go/apache/aurora" +) + +func (r *Client) JobExists(key aurora.JobKey) (bool, error) { + resp, err := r.client.GetConfigSummary(context.TODO(), &key) + if err != nil { + return false, err + } + + return resp != nil && + resp.GetResult_() != nil && + resp.GetResult_().GetConfigSummaryResult_() != nil && + resp.GetResult_().GetConfigSummaryResult_().GetSummary() != nil && + resp.GetResult_().GetConfigSummaryResult_().GetSummary().GetGroups() != nil && + len(resp.GetResult_().GetConfigSummaryResult_().GetSummary().GetGroups()) > 0 && + resp.GetResponseCode() == aurora.ResponseCode_OK, + nil +} diff --git a/realis.go b/realis.go index 1219e92..c331918 100644 --- a/realis.go +++ b/realis.go @@ -315,11 +315,13 @@ func (c *Client) GetInstanceIds(key aurora.JobKey, states []aurora.ScheduleStatu Statuses: states, } - c.logger.DebugPrintf("GetTasksWithoutConfigs Thrift Payload: %+v\n", taskQ) + c.logger.DebugPrintf("GetInstanceIds Thrift Payload: %+v\n", taskQ) resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetTasksWithoutConfigs(context.TODO(), taskQ) - }) + }, + nil, + ) // If we encountered an error we couldn't recover from by retrying, return an error to the user if retryErr != nil { @@ -341,8 +343,13 @@ func (c *Client) GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (* resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.readonlyClient.GetJobUpdateSummaries(context.TODO(), jobUpdateQuery) - }) + }, + nil, + ) + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetGetJobUpdateSummariesResult_() == nil { + return nil, errors.New("unexpected response from scheduler") + } if retryErr != nil { return nil, errors.Wrap(retryErr, "error getting job update summaries from Aurora Scheduler") } @@ -354,8 +361,12 @@ func (c *Client) GetJobSummary(role string) (*aurora.JobSummaryResult_, error) { resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.readonlyClient.GetJobSummary(context.TODO(), role) - }) - + }, + nil, + ) + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetJobSummaryResult_() == nil { + return nil, errors.New("unexpected response from scheduler") + } if retryErr != nil { return nil, errors.Wrap(retryErr, "error getting job summaries from Aurora Scheduler") } @@ -365,21 +376,20 @@ func (c *Client) GetJobSummary(role string) (*aurora.JobSummaryResult_, error) { func (c *Client) GetJobs(role string) (*aurora.GetJobsResult_, error) { - var result *aurora.GetJobsResult_ - resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.readonlyClient.GetJobs(context.TODO(), role) - }) + }, + nil, + ) if retryErr != nil { - return result, errors.Wrap(retryErr, "error getting Jobs from Aurora Scheduler") + return nil, errors.Wrap(retryErr, "error getting Jobs from Aurora Scheduler") + } + if resp == nil || resp.GetResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - if resp.GetResult_() != nil { - result = resp.GetResult_().GetJobsResult_ - } - - return result, nil + return resp.GetResult_().GetJobsResult_, nil } // Kill specific instances of a job. Returns true, nil if a task was actually killed as a result of this API call. @@ -389,19 +399,19 @@ func (c *Client) KillInstances(key aurora.JobKey, instances ...int32) (bool, err resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.KillTasks(context.TODO(), &key, instances, "") - }) + }, + nil, + ) if retryErr != nil { return false, errors.Wrap(retryErr, "error sending Kill command to Aurora Scheduler") } - if len(resp.GetDetails()) > 0 { + if resp == nil || len(resp.GetDetails()) > 0 { c.logger.Println("KillTasks was called but no tasks killed as a result.") return false, nil - } else { - return true, nil } - + return true, nil } func (c *Client) RealisConfig() *clientConfig { @@ -416,7 +426,9 @@ func (c *Client) KillJob(key aurora.JobKey) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { // Giving the KillTasks thrift call an empty set tells the Aurora scheduler to kill all active shards return c.client.KillTasks(context.TODO(), &key, nil, "") - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Kill command to Aurora Scheduler") @@ -438,9 +450,27 @@ func (c *Client) CreateJob(auroraJob *AuroraJob) error { return errors.Wrap(err, "unable to create Thermos payload") } - _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { - return c.client.CreateJob(context.TODO(), auroraJob.JobConfig()) - }) + // Response is checked by the thrift retry code + _, retryErr := c.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return c.client.CreateJob(context.TODO(), auroraJob.JobConfig()) + }, + // On a client timeout, attempt to verify that payload made to the Scheduler by + // trying to get the config summary for the job key + func() (*aurora.Response, bool) { + exists, err := c.JobExists(auroraJob.JobKey()) + if err != nil { + c.logger.Print("verification failed ", err) + } + + if exists { + return &aurora.Response{ResponseCode: aurora.ResponseCode_OK}, true + } + + return nil, false + }, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Create command to Aurora Scheduler") @@ -471,7 +501,9 @@ func (c *Client) ScheduleCronJob(auroraJob *AuroraJob) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.ScheduleCronJob(context.TODO(), auroraJob.JobConfig()) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Cron AuroraJob Schedule message to Aurora Scheduler") @@ -485,7 +517,9 @@ func (c *Client) DescheduleCronJob(key aurora.JobKey) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.DescheduleCronJob(context.TODO(), &key) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Cron AuroraJob De-schedule message to Aurora Scheduler") @@ -501,7 +535,9 @@ func (c *Client) StartCronJob(key aurora.JobKey) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.StartCronJob(context.TODO(), &key) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Start Cron AuroraJob message to Aurora Scheduler") @@ -516,7 +552,9 @@ func (c *Client) RestartInstances(key aurora.JobKey, instances ...int32) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.RestartShards(context.TODO(), &key, instances) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Restart command to Aurora Scheduler") @@ -537,16 +575,17 @@ func (c *Client) RestartJob(key aurora.JobKey) error { if len(instanceIds) > 0 { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.RestartShards(context.TODO(), &key, instanceIds) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending Restart command to Aurora Scheduler") } return nil - } else { - return errors.New("no tasks in the Active state") } + return errors.New("no tasks in the Active state") } // Update all tasks under a job configuration. Currently gorealis doesn't support for canary deployments. @@ -558,34 +597,80 @@ func (c *Client) StartJobUpdate(updateJob *JobUpdate, message string) (*aurora.S c.logger.DebugPrintf("StartJobUpdate Thrift Payload: %+v %v\n", updateJob, message) - resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { - return c.client.StartJobUpdate(nil, updateJob.request, message) - }) + resp, retryErr := c.thriftCallWithRetries(false, + func() (*aurora.Response, error) { + return c.client.StartJobUpdate(context.TODO(), updateJob.request, message) + }, + func() (*aurora.Response, bool) { + key := updateJob.JobKey() + summariesResp, err := c.readonlyClient.GetJobUpdateSummaries( + context.TODO(), + &aurora.JobUpdateQuery{ + JobKey: &key, + UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES, + Limit: 1, + }) + + if err != nil { + c.logger.Print("verification failed ", err) + return nil, false + } + + summaries := response.JobUpdateSummaries(summariesResp) + if len(summaries) == 0 { + return nil, false + } + + return &aurora.Response{ + ResponseCode: aurora.ResponseCode_OK, + Result_: &aurora.Result_{ + StartJobUpdateResult_: &aurora.StartJobUpdateResult_{ + UpdateSummary: summaries[0], + Key: summaries[0].Key, + }, + }, + }, true + }, + ) if retryErr != nil { + // A timeout took place when attempting this call, attempt to recover + if IsTimeout(retryErr) { + return nil, retryErr + } + return nil, errors.Wrap(retryErr, "error sending StartJobUpdate command to Aurora Scheduler") } - - if resp.GetResult_() != nil && resp.GetResult_().GetStartJobUpdateResult_() != nil { - return resp.GetResult_().GetStartJobUpdateResult_(), nil + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetStartJobUpdateResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + return resp.GetResult_().GetStartJobUpdateResult_(), nil } -// Abort AuroraJob Update on Aurora. Requires the updateId which can be obtained on the Aurora web UI. +// AbortJobUpdate terminates a job update in the scheduler. +// It requires the updateId which can be obtained on the Aurora web UI. +// This API is meant to be synchronous. It will attempt to wait until the update transitions to the aborted state. +// However, if the job update does not transition to the ABORT state an error will be returned. func (c *Client) AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) error { c.logger.DebugPrintf("AbortJobUpdate Thrift Payload: %+v %v\n", updateKey, message) _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.AbortJobUpdate(context.TODO(), &updateKey, message) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending AbortJobUpdate command to Aurora Scheduler") } - return nil + // Make this call synchronous by blocking until it job has successfully transitioned to aborted + _, err := c.MonitorJobUpdateStatus( + updateKey, + []aurora.JobUpdateStatus{aurora.JobUpdateStatus_ABORTED}, + time.Second*5, + time.Minute) + return err } // Pause AuroraJob Update. UpdateID is returned from StartJobUpdate or the Aurora web UI. @@ -605,7 +690,9 @@ func (c *Client) PauseJobUpdate(updateKey *aurora.JobUpdateKey, message string) _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.PauseJobUpdate(nil, updateKeyLocal, message) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending PauseJobUpdate command to Aurora Scheduler") @@ -632,7 +719,9 @@ func (c *Client) ResumeJobUpdate(updateKey aurora.JobUpdateKey, message string) _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.ResumeJobUpdate(context.TODO(), &updateKey, message) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending ResumeJobUpdate command to Aurora Scheduler") @@ -653,18 +742,19 @@ func (c *Client) PulseJobUpdate(updateKey aurora.JobUpdateKey) (aurora.JobUpdate resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.PulseJobUpdate(context.TODO(), &updateKey) - }) + }, + nil, + ) if retryErr != nil { return aurora.JobUpdatePulseStatus(0), errors.Wrap(retryErr, "error sending PulseJobUpdate command to Aurora Scheduler") } - if resp.GetResult_() != nil && resp.GetResult_().GetPulseJobUpdateResult_() != nil { - return resp.GetResult_().GetPulseJobUpdateResult_().GetStatus(), nil - } else { - return aurora.JobUpdatePulseStatus(0), errors.New("thrift error, field was nil unexpectedly") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetPulseJobUpdateResult_() == nil { + return aurora.JobUpdatePulseStatus(0), errors.New("unexpected response from scheduler") } + return resp.GetResult_().GetPulseJobUpdateResult_().GetStatus(), nil } // Scale up the number of instances under a job configuration using the configuration for specific @@ -681,7 +771,9 @@ func (c *Client) AddInstances(instKey aurora.InstanceKey, count int32) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.AddInstances(context.TODO(), &instKey, count) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "error sending AddInstances command to Aurora Scheduler") @@ -726,11 +818,16 @@ func (c *Client) GetTaskStatus(query *aurora.TaskQuery) ([]*aurora.ScheduledTask resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetTasksStatus(context.TODO(), query) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task status") } + if resp == nil { + return nil, errors.New("unexpected response from scheduler") + } return response.ScheduleStatusResult(resp).GetTasks(), nil } @@ -742,29 +839,32 @@ func (c *Client) GetPendingReason(query *aurora.TaskQuery) ([]*aurora.PendingRea resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetPendingReason(context.TODO(), query) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for pending Reasons") } - var result []*aurora.PendingReason - - if resp.GetResult_() != nil { - result = resp.GetResult_().GetGetPendingReasonResult_().GetReasons() + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetGetPendingReasonResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - return result, nil + return resp.GetResult_().GetGetPendingReasonResult_().GetReasons(), nil } -// Get information about task including without a task configuration object +// GetTasksWithoutConfigs gets information about task including without a task configuration object. +// This is a more lightweight version of GetTaskStatus but contains less information as a result. func (c *Client) GetTasksWithoutConfigs(query *aurora.TaskQuery) ([]*aurora.ScheduledTask, error) { c.logger.DebugPrintf("GetTasksWithoutConfigs Thrift Payload: %+v\n", query) resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetTasksWithoutConfigs(context.TODO(), query) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task status without configs") @@ -791,7 +891,9 @@ func (c *Client) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.TaskConfig resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetTasksStatus(context.TODO(), taskQ) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task configuration") @@ -817,17 +919,19 @@ func (c *Client) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) ([]*aurora. resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.GetJobUpdateDetails(context.TODO(), &updateQuery) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to get job update details") } - if resp.GetResult_() != nil && resp.GetResult_().GetGetJobUpdateDetailsResult_() != nil { - return resp.GetResult_().GetGetJobUpdateDetailsResult_().GetDetailsList(), nil - } else { - return nil, errors.New("unknown Thrift error, field is nil.") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetGetJobUpdateDetailsResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } + + return resp.GetResult_().GetGetJobUpdateDetailsResult_().GetDetailsList(), nil } func (c *Client) RollbackJobUpdate(key aurora.JobUpdateKey, message string) error { @@ -836,7 +940,9 @@ func (c *Client) RollbackJobUpdate(key aurora.JobUpdateKey, message string) erro _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.client.RollbackJobUpdate(context.TODO(), &key, message) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to roll back job update") diff --git a/realis_admin.go b/realis_admin.go index f2759ea..f100f46 100644 --- a/realis_admin.go +++ b/realis_admin.go @@ -37,17 +37,19 @@ func (c *Client) DrainHosts(hosts ...string) ([]*aurora.HostStatus, error) { resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.DrainHosts(context.TODO(), drainList) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to recover connection") } - if resp.GetResult_() != nil && resp.GetResult_().GetDrainHostsResult_() != nil { - return resp.GetResult_().GetDrainHostsResult_().GetStatuses(), nil - } else { - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetDrainHostsResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } + + return resp.GetResult_().GetDrainHostsResult_().GetStatuses(), nil } // Start SLA Aware Drain. @@ -78,17 +80,19 @@ func (c *Client) SLADrainHosts(policy *aurora.SlaPolicy, timeout int64, hosts .. resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.SlaDrainHosts(context.TODO(), drainList, policy, timeout) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to recover connection") } - if resp.GetResult_() != nil && resp.GetResult_().GetDrainHostsResult_() != nil { - return resp.GetResult_().GetDrainHostsResult_().GetStatuses(), nil - } else { - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetDrainHostsResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } + + return resp.GetResult_().GetDrainHostsResult_().GetStatuses(), nil } func (c *Client) StartMaintenance(hosts ...string) ([]*aurora.HostStatus, error) { @@ -104,17 +108,19 @@ func (c *Client) StartMaintenance(hosts ...string) ([]*aurora.HostStatus, error) resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.StartMaintenance(context.TODO(), hostList) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to recover connection") } - if resp.GetResult_() != nil && resp.GetResult_().GetStartMaintenanceResult_() != nil { - return resp.GetResult_().GetStartMaintenanceResult_().GetStatuses(), nil - } else { - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetStartMaintenanceResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } + + return resp.GetResult_().GetStartMaintenanceResult_().GetStatuses(), nil } func (c *Client) EndMaintenance(hosts ...string) ([]*aurora.HostStatus, error) { @@ -130,24 +136,20 @@ func (c *Client) EndMaintenance(hosts ...string) ([]*aurora.HostStatus, error) { resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.EndMaintenance(context.TODO(), hostList) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to recover connection") } - - if resp.GetResult_() != nil && resp.GetResult_().GetEndMaintenanceResult_() != nil { - return resp.GetResult_().GetEndMaintenanceResult_().GetStatuses(), nil - } else { - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetEndMaintenanceResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - + return resp.GetResult_().GetEndMaintenanceResult_().GetStatuses(), nil } func (c *Client) MaintenanceStatus(hosts ...string) (*aurora.MaintenanceStatusResult_, error) { - - var result *aurora.MaintenanceStatusResult_ - if len(hosts) == 0 { return nil, errors.New("no hosts provided to get maintenance status from") } @@ -161,17 +163,18 @@ func (c *Client) MaintenanceStatus(hosts ...string) (*aurora.MaintenanceStatusRe // and continue trying to resend command until we run out of retries. resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.MaintenanceStatus(context.TODO(), hostList) - }) + }, + nil, + ) if retryErr != nil { - return result, errors.Wrap(retryErr, "unable to recover connection") + return nil, errors.Wrap(retryErr, "unable to recover connection") + } + if resp == nil || resp.GetResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - if resp.GetResult_() != nil { - result = resp.GetResult_().GetMaintenanceStatusResult_() - } - - return result, nil + return resp.GetResult_().GetMaintenanceStatusResult_(), nil } // SetQuota sets a quota aggregate for the given role @@ -189,7 +192,9 @@ func (c *Client) SetQuota(role string, cpu *float64, ramMb *int64, diskMb *int64 _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.SetQuota(context.TODO(), role, quota) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to set role quota") @@ -203,17 +208,18 @@ func (c *Client) GetQuota(role string) (*aurora.GetQuotaResult_, error) { resp, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.GetQuota(context.TODO(), role) - }) + }, + nil, + ) if retryErr != nil { return nil, errors.Wrap(retryErr, "unable to get role quota") } - if resp.GetResult_() != nil { - return resp.GetResult_().GetGetQuotaResult_(), nil - } else { - return nil, errors.New("thrift error: Field in response is nil unexpectedly.") + if resp == nil || resp.GetResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } + return resp.GetResult_().GetGetQuotaResult_(), nil } // Force Aurora Scheduler to perform a snapshot and write to Mesos log @@ -221,7 +227,9 @@ func (c *Client) Snapshot() error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.Snapshot(context.TODO()) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to recover connection") @@ -235,7 +243,9 @@ func (c *Client) PerformBackup() error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.PerformBackup(context.TODO()) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to recover connection") @@ -249,7 +259,9 @@ func (c *Client) ForceImplicitTaskReconciliation() error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.TriggerImplicitTaskReconciliation(context.TODO()) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to recover connection") @@ -270,7 +282,9 @@ func (c *Client) ForceExplicitTaskReconciliation(batchSize *int32) error { _, retryErr := c.thriftCallWithRetries(false, func() (*aurora.Response, error) { return c.adminClient.TriggerExplicitTaskReconciliation(context.TODO(), settings) - }) + }, + nil, + ) if retryErr != nil { return errors.Wrap(retryErr, "unable to recover connection") diff --git a/realis_e2e_test.go b/realis_e2e_test.go index 1f544d8..5893491 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -477,13 +477,15 @@ func TestRealisClient_CreateService(t *testing.T) { var ok bool var mErr error - if ok, mErr = r.MonitorJobUpdate(*result.GetKey(), 5*time.Second, 4*time.Minute); !ok || mErr != nil { - // Update may already be in a terminal state so don't check for error - err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") + if result != nil { + if ok, mErr = r.MonitorJobUpdate(*result.GetKey(), 5*time.Second, 4*time.Minute); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") - err = r.KillJob(job.JobKey()) + err = r.KillJob(job.JobKey()) - assert.NoError(t, err) + assert.NoError(t, err) + } } assert.True(t, ok) @@ -1445,3 +1447,59 @@ func TestRealisClient_FitTasks(t *testing.T) { } } } + +func TestRealisClient_JobExists(t *testing.T) { + role := "vagrant" + env := "prod" + name := "test_job_exists" + // Create a good single job + job := realis.NewJob(). + Environment(env). + Role(role). + Name(name). + ThermosExecutor(thermosExec). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(3). + IsService(true). + Production(false). + Tier("preemptible"). + Priority(0) + + // Check if job exists before creating + exists, err := r.JobExists(job.JobKey()) + assert.NoError(t, err) + assert.False(t, exists) + + err = r.CreateJob(job) + assert.NoError(t, err) + + exists, err = r.JobExists(job.JobKey()) + assert.NoError(t, err) + assert.True(t, exists) + + // Create a single bad job + badJob := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("executordoesntexist"). + ExecutorName("idontexist"). + ExecutorData(""). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(1) + + // Check if job exists before creating + exists, err = r.JobExists(badJob.JobKey()) + assert.NoError(t, err) + assert.False(t, exists) + + err = r.CreateJob(badJob) + assert.Error(t, err) + + exists, err = r.JobExists(badJob.JobKey()) + assert.NoError(t, err) + assert.False(t, exists) +} diff --git a/response/response.go b/response/response.go index 1663b1b..15081ec 100644 --- a/response/response.go +++ b/response/response.go @@ -35,6 +35,10 @@ func ScheduleStatusResult(resp *aurora.Response) *aurora.ScheduleStatusResult_ { } func JobUpdateSummaries(resp *aurora.Response) []*aurora.JobUpdateSummary { + if resp == nil || resp.GetResult_() == nil || resp.GetResult_().GetGetJobUpdateSummariesResult_() == nil { + return nil + } + return resp.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries() } diff --git a/retry.go b/retry.go index 9860e42..f5b0918 100644 --- a/retry.go +++ b/retry.go @@ -17,10 +17,7 @@ package realis import ( "io" "math/rand" - "net/http" "net/url" - "strconv" - "strings" "time" "github.com/apache/thrift/lib/go/thrift" @@ -29,9 +26,11 @@ import ( "github.com/pkg/errors" ) +// Backoff determines how the retry mechanism should react after each failure and how many failures it should +// tolerate. type Backoff struct { Duration time.Duration // the base duration - Factor float64 // Duration is multipled by factor each iteration + Factor float64 // Duration is multiplied by a factor each iteration Jitter float64 // The amount of jitter applied each iteration Steps int // Exit with error after this many steps } @@ -53,18 +52,15 @@ func Jitter(duration time.Duration, maxFactor float64) time.Duration { // if the loop should be aborted. type ConditionFunc func() (done bool, err error) -// Modified version of the Kubernetes exponential-backoff code. -// ExponentialBackoff repeats a condition check with exponential backoff. -// -// It checks the condition up to Steps times, increasing the wait by multiplying -// the previous duration by Factor. +// ExponentialBackoff is a modified version of the Kubernetes exponential-backoff code. +// It repeats a condition check with exponential backoff and checks the condition up to +// Steps times, increasing the wait by multiplying the previous duration by Factor. // // If Jitter is greater than zero, a random amount of each duration is added // (between duration and duration*(1+jitter)). // // If the condition never returns true, ErrWaitTimeout is returned. Errors // do not cause the function to return. - func ExponentialBackoff(backoff Backoff, logger Logger, condition ConditionFunc) error { var err error var ok bool @@ -98,10 +94,9 @@ func ExponentialBackoff(backoff Backoff, logger Logger, condition ConditionFunc) // If the error is temporary, continue retrying. if !IsTemporary(err) { return err - } else { - // Print out the temporary error we experienced. - logger.Println(err) } + // Print out the temporary error we experienced. + logger.Println(err) } } @@ -112,19 +107,28 @@ func ExponentialBackoff(backoff Backoff, logger Logger, condition ConditionFunc) // Provide more information to the user wherever possible if err != nil { return newRetryError(errors.Wrap(err, "ran out of retries"), curStep) - } else { - return newRetryError(errors.New("ran out of retries"), curStep) } + + return newRetryError(errors.New("ran out of retries"), curStep) } type auroraThriftCall func() (resp *aurora.Response, err error) +// verifyOntimeout defines the type of function that will be used to verify whether a Thirft call to the Scheduler +// made it to the scheduler or not. In general, these types of functions will have to interact with the scheduler +// through the very same Thrift API which previously encountered a time-out from the client. +// This means that the functions themselves should be kept to a minimum number of Thrift calls. +// It should also be noted that this is a best effort mechanism and +// is likely to fail for the same reasons that the original call failed. +type verifyOnTimeout func() (*aurora.Response, bool) + // Duplicates the functionality of ExponentialBackoff but is specifically targeted towards ThriftCalls. -func (c *Client) thriftCallWithRetries(returnOnTimeout bool, thriftCall auroraThriftCall) (*aurora.Response, error) { +func (c *Client) thriftCallWithRetries(returnOnTimeout bool, thriftCall auroraThriftCall, + verifyOnTimeout verifyOnTimeout) (*aurora.Response, error) { var resp *aurora.Response var clientErr error var curStep int - var timeouts int + timeouts := 0 backoff := c.config.backoff duration := backoff.Duration @@ -138,7 +142,10 @@ func (c *Client) thriftCallWithRetries(returnOnTimeout bool, thriftCall auroraTh adjusted = Jitter(duration, backoff.Jitter) } - c.logger.Printf("A retryable error occurred during thrift call, backing off for %v before retry %v\n", adjusted, curStep) + c.logger.Printf( + "A retryable error occurred during thrift call, backing off for %v before retry %v", + adjusted, + curStep) time.Sleep(adjusted) duration = time.Duration(float64(duration) * backoff.Factor) @@ -153,105 +160,132 @@ func (c *Client) thriftCallWithRetries(returnOnTimeout bool, thriftCall auroraTh resp, clientErr = thriftCall() - c.logger.TracePrintf("Aurora Thrift Call ended resp: %v clientErr: %v\n", resp, clientErr) + c.logger.TracePrintf("Aurora Thrift Call ended resp: %v clientErr: %v", resp, clientErr) }() // Check if our thrift call is returning an error. This is a retryable event as we don't know // if it was caused by network issues. if clientErr != nil { - // Print out the error to the user - c.logger.Printf("Client Error: %v\n", clientErr) + c.logger.Printf("Client Error: %v", clientErr) - // Determine if error is a temporary URL error by going up the stack - e, ok := clientErr.(thrift.TTransportException) - if ok { - c.logger.DebugPrint("Encountered a transport exception") + temporary, timedout := isConnectionError(clientErr) + if !temporary && c.RealisConfig().failOnPermanentErrors { + return nil, errors.Wrap(clientErr, "permanent connection error") + } - // TODO(rdelvalle): Figure out a better way to obtain the error code as this is a very brittle solution - // 401 Unauthorized means the wrong username and password were provided - if strings.Contains(e.Error(), strconv.Itoa(http.StatusUnauthorized)) { - return nil, errors.Wrap(clientErr, "wrong username or password provided") - } - - e, ok := e.Err().(*url.Error) - if ok { - // EOF error occurs when the server closes the read buffer of the client. This is common - // when the server is overloaded and should be retried. All other errors that are permanent - // will not be retried. - if e.Err != io.EOF && !e.Temporary() && c.RealisConfig().failOnPermanentErrors { - return nil, errors.Wrap(clientErr, "permanent connection error") - } - // Corner case where thrift payload was received by Aurora but connection timedout before Aurora was - // able to reply. In this case we will return whatever response was received and a TimedOut behaving - // error. Users can take special action on a timeout by using IsTimedout and reacting accordingly. - if e.Timeout() { - timeouts++ - c.logger.DebugPrintf( - "Client closed connection (timedout) %d times before server responded,"+ - " consider increasing connection timeout", - timeouts) - if returnOnTimeout { - return resp, - newTimedoutError(errors.New("client connection closed before server answer")) - } - } - } + // There exists a corner case where thrift payload was received by Aurora but + // connection timed out before Aurora was able to reply. + // Users can take special action on a timeout by using IsTimedout and reacting accordingly + // if they have configured the client to return on a timeout. + if timedout && returnOnTimeout { + return resp, newTimedoutError(errors.New("client connection closed before server answer")) } // In the future, reestablish connection should be able to check if it is actually possible // to make a thrift call to Aurora. For now, a reconnect should always lead to a retry. // Ignoring error due to the fact that an error should be retried regardless - _ = c.ReestablishConn() - - } else { - - // If there was no client error, but the response is nil, something went wrong. - // Ideally, we'll never encounter this but we're placing a safeguard here. - if resp == nil { - return nil, errors.New("response from aurora is nil") + reestablishErr := c.ReestablishConn() + if reestablishErr != nil { + c.logger.DebugPrintf("error re-establishing connection ", reestablishErr) } - // Check Response Code from thrift and make a decision to continue retrying or not. - switch responseCode := resp.GetResponseCode(); responseCode { + // If users did not opt for a return on timeout in order to react to a timedout error, + // attempt to verify that the call made it to the scheduler after the connection was re-established. + if timedout { + timeouts++ + c.logger.DebugPrintf( + "Client closed connection %d times before server responded, "+ + "consider increasing connection timeout", + timeouts) - // If the thrift call succeeded, stop retrying - case aurora.ResponseCode_OK: - return resp, nil - - // If the response code is transient, continue retrying - case aurora.ResponseCode_ERROR_TRANSIENT: - c.logger.Println("Aurora replied with Transient error code, retrying") - continue - - // Failure scenarios, these indicate a bad payload or a bad clientConfig. Stop retrying. - case aurora.ResponseCode_INVALID_REQUEST, - aurora.ResponseCode_ERROR, - aurora.ResponseCode_AUTH_FAILED, - aurora.ResponseCode_JOB_UPDATING_ERROR: - c.logger.Printf("Terminal Response Code %v from Aurora, won't retry\n", resp.GetResponseCode().String()) - return resp, errors.New(response.CombineMessage(resp)) - - // The only case that should fall down to here is a WARNING response code. - // It is currently not used as a response in the scheduler so it is unknown how to handle it. - default: - c.logger.DebugPrintf("unhandled response code %v received from Aurora\n", responseCode) - return nil, errors.Errorf("unhandled response code from Aurora %v", responseCode.String()) + // Allow caller to provide a function which checks if the original call was successful before + // it timed out. + if verifyOnTimeout != nil { + if verifyResp, ok := verifyOnTimeout(); ok { + c.logger.Print("verified that the call went through successfully after a client timeout") + // Response here might be different than the original as it is no longer constructed + // by the scheduler but mimicked. + // This is OK since the scheduler is very unlikely to change responses at this point in its + // development cycle but we must be careful to not return an incorrectly constructed response. + return verifyResp, nil + } + } } + + // Retry the thrift payload + continue } + // If there was no client error, but the response is nil, something went wrong. + // Ideally, we'll never encounter this but we're placing a safeguard here. + if resp == nil { + return nil, errors.New("response from aurora is nil") + } + + // Check Response Code from thrift and make a decision to continue retrying or not. + switch responseCode := resp.GetResponseCode(); responseCode { + + // If the thrift call succeeded, stop retrying + case aurora.ResponseCode_OK: + return resp, nil + + // If the response code is transient, continue retrying + case aurora.ResponseCode_ERROR_TRANSIENT: + c.logger.Println("Aurora replied with Transient error code, retrying") + continue + + // Failure scenarios, these indicate a bad payload or a bad clientConfig. Stop retrying. + case aurora.ResponseCode_INVALID_REQUEST, + aurora.ResponseCode_ERROR, + aurora.ResponseCode_AUTH_FAILED, + aurora.ResponseCode_JOB_UPDATING_ERROR: + c.logger.Printf("Terminal Response Code %v from Aurora, won't retry\n", resp.GetResponseCode().String()) + return resp, errors.New(response.CombineMessage(resp)) + + // The only case that should fall down to here is a WARNING response code. + // It is currently not used as a response in the scheduler so it is unknown how to handle it. + default: + c.logger.DebugPrintf("unhandled response code %v received from Aurora\n", responseCode) + return nil, errors.Errorf("unhandled response code from Aurora %v", responseCode.String()) + } } - c.logger.DebugPrintf("it took %v retries to complete this operation\n", curStep) - if curStep > 1 { - c.config.logger.Printf("retried this thrift call %d time(s)", curStep) + c.config.logger.Printf("this thrift call was retried %d time(s)", curStep) } // Provide more information to the user wherever possible. if clientErr != nil { return nil, newRetryError(errors.Wrap(clientErr, "ran out of retries, including latest error"), curStep) - } else { - return nil, newRetryError(errors.New("ran out of retries"), curStep) } + + return nil, newRetryError(errors.New("ran out of retries"), curStep) +} + +// isConnectionError processes the error received by the client. +// The return values indicate whether this was determined to be a temporary error +// and whether it was determined to be a timeout error +func isConnectionError(err error) (bool, bool) { + + // Determine if error is a temporary URL error by going up the stack + transportException, ok := err.(thrift.TTransportException) + if !ok { + return false, false + } + + urlError, ok := transportException.Err().(*url.Error) + if !ok { + return false, false + } + + // EOF error occurs when the server closes the read buffer of the client. This is common + // when the server is overloaded and we consider it temporary. + // All other which are not temporary as per the member function Temporary(), + // are considered not temporary (permanent). + if urlError.Err != io.EOF && !urlError.Temporary() { + return false, false + } + + return true, urlError.Timeout() } diff --git a/util.go b/util.go index f993aaa..a822b3f 100644 --- a/util.go +++ b/util.go @@ -40,7 +40,7 @@ func init() { } } -// TerminalJobUpdateStates returns a slice containing all the terminal states an update may end up in. +// TerminalUpdateStates returns a slice containing all the terminal states an update may be in. // This is a function in order to avoid having a slice that can be accidentally mutated. func TerminalUpdateStates() []aurora.JobUpdateStatus { return []aurora.JobUpdateStatus{