From 4975ad55405e929fd1cd17f61ba6716d044535ee Mon Sep 17 00:00:00 2001 From: Abhishek Parwal Date: Sat, 25 Apr 2020 09:28:56 -0700 Subject: [PATCH 1/5] parallelize resolve module --- codegen/module.go | 123 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 17 deletions(-) diff --git a/codegen/module.go b/codegen/module.go index fa97426d6..cac119854 100644 --- a/codegen/module.go +++ b/codegen/module.go @@ -568,27 +568,51 @@ func (system *ModuleSystem) ResolveModules( return nil, errors.Wrapf(err, "error getting default dependencies for class %s", className) } - runner := parallelize.NewUnboundedRunner(len(system.moduleSearchPaths[className])) - resolvedModulesCopy := copyResolveModule(resolvedModules) for _, moduleDirectoryGlob := range system.moduleSearchPaths[className] { - f := func(moduleDirectoryGlob interface{}) (interface{}, error) { - result := system.resolveModule(baseDirectory, moduleDirectoryGlob.(string), className, packageRoot, - targetGenDir, defaultDependencies, resolvedModulesCopy) - return result.module, result.err + moduleDirectoriesAbs, err := filepath.Glob(filepath.Join(baseDirectory, moduleDirectoryGlob)) + if err != nil { + return nil, errors.Wrapf(err, "error globbing %q", moduleDirectoryGlob) } - wrk := ¶llelize.SingleParamWork{Data: moduleDirectoryGlob, Func: f} - runner.SubmitWork(wrk) - } - results, err := runner.GetResult() - if err != nil { - return nil, err - } - for _, result := range results { - if result == nil { - continue + runner := parallelize.NewUnboundedRunner(len(moduleDirectoriesAbs)) + for _, moduleDirAbs := range moduleDirectoriesAbs { + f := system.getInstanceFunc(baseDirectory, className, packageRoot, targetGenDir, defaultDependencies, + moduleDirectoryGlob) + wrk := ¶llelize.SingleParamWork{Data: moduleDirAbs, Func: f} + runner.SubmitWork(wrk) + } + + results, err := runner.GetResult() + if err != nil { + return nil, err + } + for _, instanceInf := range results { + if instanceInf == nil { + continue + } + instance := instanceInf.(*ModuleInstance) + instanceMap := resolvedModules[instance.ClassName] + if instanceMap == nil { + instanceMap = map[string]*ModuleInstance{} + resolvedModules[instance.ClassName] = instanceMap + } + instanceMap[instance.InstanceName] = instance + } + + // Resolve dependencies for all classes + resolveErr := system.populateResolvedDependencies( + resolvedModules[className], + resolvedModules, + ) + if resolveErr != nil { + return nil, resolveErr + } + + // Resolved recursive dependencies for all classes + recursiveErr := system.populateRecursiveDependencies(resolvedModules[className]) + if recursiveErr != nil { + return nil, recursiveErr } - mergeResolveMap(result.(map[string]map[string]*ModuleInstance), resolvedModules, className) } } @@ -601,6 +625,71 @@ func (system *ModuleSystem) ResolveModules( return classArrayModuleMap, nil } +func (system *ModuleSystem) getInstanceFunc(baseDirectory string, className string, packageRoot string, targetGenDir string, defaultDependencies []ModuleDependency, moduleDirectoryGlob string) func(moduleDirAbsInf interface{}) (interface{}, error) { + f := func(moduleDirAbsInf interface{}) (interface{}, error) { + moduleDirAbs := moduleDirAbsInf.(string) + stat, err := os.Stat(moduleDirAbs) + if err != nil { + return nil, errors.Wrapf( + err, + "internal error: cannot stat %q", + moduleDirAbs, + ) + } + + if !stat.IsDir() { + // If a *-config.yaml file, or any other metadata file also matched the glob, skip it, since we are + // interested only in the containing directories. + return nil, nil + } + + moduleDir, err := filepath.Rel(baseDirectory, moduleDirAbs) + if err != nil { + return nil, errors.Wrapf( + err, + "internal error: cannot make %q relative to %q", + moduleDirAbs, + baseDirectory, + ) + } + + classConfigPath, _, _ := getConfigFilePath(moduleDirAbs, className) + if classConfigPath == "" { + fmt.Printf(" no class config found in %s directory\n", moduleDirAbs) + // No class config found in this directory, skip over it + return nil, nil + } + + instance, instanceErr := system.readInstance( + className, + packageRoot, + baseDirectory, + targetGenDir, + moduleDir, + moduleDirAbs, + defaultDependencies, + ) + if instanceErr != nil { + return nil, errors.Wrapf( + instanceErr, + "Error reading multi instance %q", + moduleDir, + ) + } + + if className != instance.ClassName { + return nil, fmt.Errorf( + "invariant: all instances in a multi-module directory %q are of type %q (violated by %q)", + moduleDirectoryGlob, + className, + moduleDir, + ) + } + return instance, nil + } + return f +} + func copyResolveModule(resolvedModules map[string]map[string]*ModuleInstance) map[string]map[string]*ModuleInstance { resolvedModulesCopy := map[string]map[string]*ModuleInstance{} for className, instanceMap := range resolvedModules { From 23c7802cdd845698aff9068fd47b40c2138d7712 Mon Sep 17 00:00:00 2001 From: Abhishek Parwal Date: Sat, 25 Apr 2020 23:21:49 -0700 Subject: [PATCH 2/5] selectively generate module code --- Makefile | 1 + codegen/module.go | 236 +- codegen/module_system.go | 6 +- codegen/module_test.go | 461 +- codegen/runner/runner.go | 36 +- codegen/template_test.go | 2 +- .../services/test-gateway/service-config.yaml | 9 + .../build/gen-code/clients/bar/bar/bar.go | 2 - .../gen-code/clients/bar/bar/bar_easyjson.go | 458 +- .../build/gen-code/clients/baz/baz/baz.go | 2 - examples/selective-gateway/app.go | 79 + examples/selective-gateway/build.yaml | 27 + .../build/clients/echo/echo.go | 164 + .../clients/echo/mock-client/mock_client.go | 57 + .../build/clients/echo/module/dependencies.go | 33 + .../bounce_bounce_method_bounce_tchannel.go | 178 + .../build/endpoints/bounce/endpoint.go | 56 + .../bounce_bounce_workflow_mock.go | 67 + .../endpoints/bounce/mock-workflow/type.go | 39 + .../endpoints/bounce/module/dependencies.go | 41 + .../bounce_bounce_method_bounce_tchannel.go | 41 + .../build/gen-code/clients/bar/bar/bar.go | 20250 ++++++++++++++++ .../gen-code/clients/bar/bar/bar_easyjson.go | 8366 +++++++ .../gen-code/clients/bar/bar/types_i64.go | 62 + .../clients/bar/bar/types_i64_easyjson.go | 22 + .../build/gen-code/clients/echo/echo.pb.go | 615 + .../gen-code/clients/echo/echo.pb.yarpc.go | 235 + .../gen-code/clients/foo/base/base/base.go | 143 + .../clients/foo/base/base/base_easyjson.go | 95 + .../build/gen-code/clients/foo/foo/foo.go | 824 + .../gen-code/clients/foo/foo/foo_easyjson.go | 356 + .../endpoints/bounce/bounce/bounce.go | 423 + .../endpoints/tchannel/echo/echo/echo.go | 423 + .../default_example/default_example.go | 47 + .../default_example/module/dependencies.go | 41 + .../default_example2/default_example2.go | 47 + .../default_example2/module/dependencies.go | 41 + .../services/selective-gateway/main/main.go | 116 + .../selective-gateway/main/main_test.go | 93 + .../mock-service/mock_init.go | 86 + .../mock-service/mock_service.go | 215 + .../selective-gateway/module/dependencies.go | 41 + .../services/selective-gateway/module/init.go | 95 + .../services/selective-gateway/service.go | 64 + .../clients/bar/client-config.json | 44 + .../clients/echo/client-config.yaml | 6 + .../selective-gateway/config/production.json | 30 + .../selective-gateway/config/production.yaml | 50 + examples/selective-gateway/config/test.json | 31 + examples/selective-gateway/config/test.yaml | 50 + .../selective-gateway/copyright_header.txt | 19 + .../endpoints/bounce/bounce.go | 56 + .../endpoints/bounce/bounce.yaml | 8 + .../endpoints/bounce/bounce_test.go | 40 + .../endpoints/bounce/endpoint-config.yaml | 8 + .../endpoints/tchannel/echo/echo.yaml | 8 + .../tchannel/echo/endpoint-config.yaml | 8 + .../idl/clients/bar/bar.thrift | 456 + .../idl/clients/echo/echo.proto | 15 + .../idl/clients/foo/base/base.thrift | 5 + .../idl/clients/foo/foo.thrift | 21 + .../idl/endpoints/bounce/bounce.thrift | 7 + .../idl/endpoints/tchannel/echo/echo.thrift | 7 + .../middlewares/default.yaml | 4 + .../default_example/default_example.go | 77 + .../default_example_schema.json | 5 + .../default_example/default_example_test.go | 40 + .../default_example/middleware-config.yaml | 8 + .../default_example2/default_example2.go | 77 + .../default_example2_schema.json | 5 + .../default_example2/default_example2_test.go | 40 + .../default_example2/middleware-config.yaml | 8 + .../selective-gateway/service-config.yaml | 8 + scripts/generate.sh | 4 + 74 files changed, 35323 insertions(+), 517 deletions(-) create mode 100644 codegen/test-service/services/test-gateway/service-config.yaml create mode 100644 examples/selective-gateway/app.go create mode 100644 examples/selective-gateway/build.yaml create mode 100644 examples/selective-gateway/build/clients/echo/echo.go create mode 100644 examples/selective-gateway/build/clients/echo/mock-client/mock_client.go create mode 100644 examples/selective-gateway/build/clients/echo/module/dependencies.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/endpoint.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/mock-workflow/bounce_bounce_workflow_mock.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/mock-workflow/type.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/module/dependencies.go create mode 100644 examples/selective-gateway/build/endpoints/bounce/workflow/bounce_bounce_method_bounce_tchannel.go create mode 100644 examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go create mode 100644 examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go create mode 100644 examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64.go create mode 100644 examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64_easyjson.go create mode 100644 examples/selective-gateway/build/gen-code/clients/echo/echo.pb.go create mode 100644 examples/selective-gateway/build/gen-code/clients/echo/echo.pb.yarpc.go create mode 100644 examples/selective-gateway/build/gen-code/clients/foo/base/base/base.go create mode 100644 examples/selective-gateway/build/gen-code/clients/foo/base/base/base_easyjson.go create mode 100644 examples/selective-gateway/build/gen-code/clients/foo/foo/foo.go create mode 100644 examples/selective-gateway/build/gen-code/clients/foo/foo/foo_easyjson.go create mode 100644 examples/selective-gateway/build/gen-code/endpoints/bounce/bounce/bounce.go create mode 100644 examples/selective-gateway/build/gen-code/endpoints/tchannel/echo/echo/echo.go create mode 100644 examples/selective-gateway/build/middlewares/default/default_example/default_example.go create mode 100644 examples/selective-gateway/build/middlewares/default/default_example/module/dependencies.go create mode 100644 examples/selective-gateway/build/middlewares/default/default_example2/default_example2.go create mode 100644 examples/selective-gateway/build/middlewares/default/default_example2/module/dependencies.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/main/main.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/main/main_test.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/mock-service/mock_init.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/module/dependencies.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/module/init.go create mode 100644 examples/selective-gateway/build/services/selective-gateway/service.go create mode 100644 examples/selective-gateway/clients/bar/client-config.json create mode 100644 examples/selective-gateway/clients/echo/client-config.yaml create mode 100644 examples/selective-gateway/config/production.json create mode 100644 examples/selective-gateway/config/production.yaml create mode 100644 examples/selective-gateway/config/test.json create mode 100644 examples/selective-gateway/config/test.yaml create mode 100644 examples/selective-gateway/copyright_header.txt create mode 100644 examples/selective-gateway/endpoints/bounce/bounce.go create mode 100644 examples/selective-gateway/endpoints/bounce/bounce.yaml create mode 100644 examples/selective-gateway/endpoints/bounce/bounce_test.go create mode 100644 examples/selective-gateway/endpoints/bounce/endpoint-config.yaml create mode 100644 examples/selective-gateway/endpoints/tchannel/echo/echo.yaml create mode 100644 examples/selective-gateway/endpoints/tchannel/echo/endpoint-config.yaml create mode 100644 examples/selective-gateway/idl/clients/bar/bar.thrift create mode 100644 examples/selective-gateway/idl/clients/echo/echo.proto create mode 100644 examples/selective-gateway/idl/clients/foo/base/base.thrift create mode 100644 examples/selective-gateway/idl/clients/foo/foo.thrift create mode 100644 examples/selective-gateway/idl/endpoints/bounce/bounce.thrift create mode 100644 examples/selective-gateway/idl/endpoints/tchannel/echo/echo.thrift create mode 100644 examples/selective-gateway/middlewares/default.yaml create mode 100644 examples/selective-gateway/middlewares/default/default_example/default_example.go create mode 100644 examples/selective-gateway/middlewares/default/default_example/default_example_schema.json create mode 100644 examples/selective-gateway/middlewares/default/default_example/default_example_test.go create mode 100644 examples/selective-gateway/middlewares/default/default_example/middleware-config.yaml create mode 100644 examples/selective-gateway/middlewares/default/default_example2/default_example2.go create mode 100644 examples/selective-gateway/middlewares/default/default_example2/default_example2_schema.json create mode 100644 examples/selective-gateway/middlewares/default/default_example2/default_example2_test.go create mode 100644 examples/selective-gateway/middlewares/default/default_example2/middleware-config.yaml create mode 100644 examples/selective-gateway/services/selective-gateway/service-config.yaml diff --git a/Makefile b/Makefile index daf463e10..c3d2a2402 100644 --- a/Makefile +++ b/Makefile @@ -122,6 +122,7 @@ generate: check-generate: @rm -f git-status.log rm -rf ./examples/example-gateway/build + rm -rf ./examples/selective-gateway/build make generate git status --porcelain > git-status.log @[ ! -s git-status.log ] || ( cat git-status.log ; git --no-pager diff ; [ ! -s git-status.log ] ); diff --git a/codegen/module.go b/codegen/module.go index cac119854..26c34f0bd 100644 --- a/codegen/module.go +++ b/codegen/module.go @@ -56,6 +56,7 @@ const yamlConfigSuffix = "-config.yaml" func NewModuleSystem( moduleSearchPaths map[string][]string, defaultDependencies map[string][]string, + selectiveBuilding bool, postGenHook ...PostGenHook, ) *ModuleSystem { return &ModuleSystem{ @@ -64,6 +65,7 @@ func NewModuleSystem( postGenHook: postGenHook, moduleSearchPaths: moduleSearchPaths, defaultDependencies: defaultDependencies, + selectiveBuilding: selectiveBuilding, } } @@ -74,6 +76,7 @@ type ModuleSystem struct { postGenHook []PostGenHook moduleSearchPaths map[string][]string defaultDependencies map[string][]string + selectiveBuilding bool } // PostGenHook provides a way to do work after the build is generated, @@ -690,140 +693,6 @@ func (system *ModuleSystem) getInstanceFunc(baseDirectory string, className stri return f } -func copyResolveModule(resolvedModules map[string]map[string]*ModuleInstance) map[string]map[string]*ModuleInstance { - resolvedModulesCopy := map[string]map[string]*ModuleInstance{} - for className, instanceMap := range resolvedModules { - instanceMapCopy := resolvedModulesCopy[className] - if instanceMapCopy == nil { - instanceMapCopy = map[string]*ModuleInstance{} - resolvedModulesCopy[className] = instanceMapCopy - } - for instanceName, instance := range instanceMap { - instanceMapCopy[instanceName] = instance - } - } - return resolvedModulesCopy -} - -type resolveResult struct { - err error - module map[string]map[string]*ModuleInstance -} - -func (system *ModuleSystem) resolveModule(baseDirectory string, moduleDirectoryGlob string, className string, - packageRoot string, targetGenDir string, defaultDependencies []ModuleDependency, - parentModule map[string]map[string]*ModuleInstance) resolveResult { - curModules := map[string]map[string]*ModuleInstance{} - mergeResolveMap(parentModule, curModules, "") - - moduleDirectoriesAbs, err := filepath.Glob(filepath.Join(baseDirectory, moduleDirectoryGlob)) - if err != nil { - return resolveResult{err: errors.Wrapf(err, "error globbing %q", moduleDirectoryGlob)} - } - - for _, moduleDirAbs := range moduleDirectoriesAbs { - stat, err := os.Stat(moduleDirAbs) - if err != nil { - return resolveResult{ - err: errors.Wrapf( - err, - "internal error: cannot stat %q", - moduleDirAbs, - ), - } - } - - if !stat.IsDir() { - // If a *-config.yaml file, or any other metadata file also matched the glob, skip it, since we are - // interested only in the containing directories. - continue - } - - moduleDir, err := filepath.Rel(baseDirectory, moduleDirAbs) - if err != nil { - return resolveResult{err: errors.Wrapf( - err, - "internal error: cannot make %q relative to %q", - moduleDirAbs, - baseDirectory, - )} - } - - classConfigPath, _, _ := getConfigFilePath(moduleDirAbs, className) - if classConfigPath == "" { - fmt.Printf(" no class config found in %s directory\n", moduleDirAbs) - // No class config found in this directory, skip over it - continue - } - - instance, instanceErr := system.readInstance( - className, - packageRoot, - baseDirectory, - targetGenDir, - moduleDir, - moduleDirAbs, - defaultDependencies, - ) - if instanceErr != nil { - return resolveResult{err: errors.Wrapf( - instanceErr, - "Error reading multi instance %q", - moduleDir, - )} - } - - instanceNameMap := curModules[instance.ClassName] - if instanceNameMap == nil { - instanceNameMap = map[string]*ModuleInstance{} - curModules[instance.ClassName] = instanceNameMap - } - instanceNameMap[instance.InstanceName] = instance - - if className != instance.ClassName { - return resolveResult{err: fmt.Errorf( - "invariant: all instances in a multi-module directory %q are of type %q (violated by %q)", - moduleDirectoryGlob, - className, - moduleDir, - )} - } - } - - // Resolve dependencies for all classes - resolveErr := system.populateResolvedDependencies( - curModules[className], - curModules, - ) - if resolveErr != nil { - return resolveResult{err: resolveErr} - } - - // Resolved recursive dependencies for all classes - recursiveErr := system.populateRecursiveDependencies(curModules[className]) - if recursiveErr != nil { - return resolveResult{err: recursiveErr} - } - return resolveResult{module: curModules} -} - -func mergeResolveMap(srcModuleMap map[string]map[string]*ModuleInstance, - destModuleMap map[string]map[string]*ModuleInstance, curClassName string) { - for srcClassName, srcInstanceMap := range srcModuleMap { - if curClassName != "" && curClassName != srcClassName { - continue - } - destInstanceMap := destModuleMap[srcClassName] - if destInstanceMap == nil { - destInstanceMap = map[string]*ModuleInstance{} - destModuleMap[srcClassName] = destInstanceMap - } - for srcInstanceName, srcInstance := range srcInstanceMap { - destModuleMap[srcClassName][srcInstanceName] = srcInstance - } - } -} - func (system *ModuleSystem) getDefaultDependencies( baseDirectory string, className string, @@ -1096,6 +965,7 @@ func (system *ModuleSystem) readInstance( JSONFileRaw: jsonRaw, YAMLFileRaw: raw, Config: config.Config, + SelectiveBuilding: config.SelectiveBuilding, }, nil } @@ -1274,9 +1144,15 @@ func (system *ModuleSystem) collectTransitiveDependencies( toBeBuiltModulesList[instance.ClassName] = append(toBeBuiltModulesList[instance.ClassName], instance) } + system.trimToSelectiveDependencies(toBeBuiltModulesList) + return toBeBuiltModulesList, nil } +func instanceFQN(instance *ModuleInstance) string { + return fmt.Sprintf("%s.%s", instance.ClassName, instance.InstanceName) +} + // IncrementalBuild is like Build but filtered to only the given module instances. func (system *ModuleSystem) IncrementalBuild( packageRoot string, @@ -1287,9 +1163,12 @@ func (system *ModuleSystem) IncrementalBuild( commitChange bool, ) (map[string][]*ModuleInstance, error) { - if len(instances) == 0 { - fmt.Println("Skipping build since no module dependency is provided") - return make(map[string][]*ModuleInstance), nil + if instances == nil || len(instances) == 0 { + for _, modules := range resolvedModules { + for _, instance := range modules { + instances = append(instances, instance.AsModuleDependency()) + } + } } toBeBuiltModules := make(map[string][]*ModuleInstance) @@ -1305,8 +1184,8 @@ func (system *ModuleSystem) IncrementalBuild( ch <- err } }(instance) - } + go func() { wg.Wait() close(ch) @@ -1326,7 +1205,8 @@ func (system *ModuleSystem) IncrementalBuild( // the SpecProvider interface, hence incremental build is not possible. if len(toBeBuiltModules) == 0 { var err error - toBeBuiltModules, err = system.collectTransitiveDependencies(instances, resolvedModules) + toBeBuiltModules, err = system.collectTransitiveDependencies(instances, + resolvedModules) if err != nil { // if incrementalBuild fails, perform a full build. fmt.Printf("Falling back to full build due to err: %s\n", err.Error()) @@ -1396,6 +1276,80 @@ func (system *ModuleSystem) IncrementalBuild( return toBeBuiltModules, nil } +func (system *ModuleSystem) trimToSelectiveDependencies(toBeBuiltModules map[string][]*ModuleInstance) { + if system.selectiveBuilding { + selectiveModuleInstances := system.getSelectiveModules(toBeBuiltModules) + toBuiltMap := flattenInstances(toBeBuiltModules) + for _, instance := range selectiveModuleInstances { + instance.ResolvedDependencies = resolvedSelectiveDependencies(instance, toBuiltMap) + instance.RecursiveDependencies = recursiveSelectiveDependencies(instance) + } + } +} + +func (system *ModuleSystem) getSelectiveModules(toBeBuiltModules map[string][]*ModuleInstance) map[string]*ModuleInstance { + selectiveModuleInstances := map[string]*ModuleInstance{} + for _, instances := range toBeBuiltModules { + for _, instance := range instances { + if instance.SelectiveBuilding { + selectiveModuleInstances[instanceFQN(instance)] = instance + } + } + } + return selectiveModuleInstances +} + +// recursiveSelectiveDependencies gets a recursive dependencies of direct dependencies including itself +func recursiveSelectiveDependencies(instance *ModuleInstance) map[string][]*ModuleInstance { + filteredRecursiveMap := map[string]*ModuleInstance{} + for _, resolvedDependencies := range instance.ResolvedDependencies { + for _, resolvedInstance := range resolvedDependencies { + for _, recursiveDependencies := range resolvedInstance.RecursiveDependencies { + for _, recursiveInstance := range recursiveDependencies { + filteredRecursiveMap[instanceFQN(recursiveInstance)] = recursiveInstance + } + } + filteredRecursiveMap[instanceFQN(resolvedInstance)] = resolvedInstance + } + } + + filteredRecursiveModules := map[string][]*ModuleInstance{} + for _, instance := range filteredRecursiveMap { + filteredRecursiveModules[instance.ClassName] = append(filteredRecursiveModules[instance.ClassName], instance) + } + return filteredRecursiveModules +} + +// resolvedSelectiveDependencies gets a subset of resolved dependencies ( +// direct) of a instance which needs to be built +func resolvedSelectiveDependencies(instance *ModuleInstance, toBuiltMap map[string]*ModuleInstance) map[string][]*ModuleInstance { + filteredResolvedModules := map[string][]*ModuleInstance{} + for _, resolvedDependencies := range instance.ResolvedDependencies { + for _, resolvedInstance := range resolvedDependencies { + if _, ok := toBuiltMap[instanceFQN(resolvedInstance)]; ok { + filteredResolvedModules[resolvedInstance.ClassName] = append( + filteredResolvedModules[resolvedInstance.ClassName], resolvedInstance) + } + } + } + // if after filtering there are no dependencies, we will default it to all dependencies. + // this is done as when a module alone changes toBuilt would not have any dependencies + if len(filteredResolvedModules) == 0 { + filteredResolvedModules = instance.ResolvedDependencies + } + return filteredResolvedModules +} + +func flattenInstances(resolvedModules map[string][]*ModuleInstance) map[string]*ModuleInstance { + flattenedMap := map[string]*ModuleInstance{} + for _, instances := range resolvedModules { + for _, instance := range instances { + flattenedMap[instanceFQN(instance)] = instance + } + } + return flattenedMap +} + // Build invokes the generator for a module instance and optionally writes the files to disk func (system *ModuleSystem) Build(packageRoot string, baseDirectory string, physicalGenDir string, instance *ModuleInstance, commitChange bool) error { @@ -1710,6 +1664,8 @@ type ModuleInstance struct { JSONFileRaw []byte // Deprecated // YAMLFileRaw is the raw YAML file read as bytes used for future parsing YAMLFileRaw []byte + // SelectiveBuilding allows the module to be built with subset of dependencies + SelectiveBuilding bool } func (instance *ModuleInstance) String() string { @@ -1761,6 +1717,8 @@ type ClassConfigBase struct { IsExportGenerated *bool `yaml:"IsExportGenerated,omitempty" json:"IsExportGenerated"` // Owner is the Name of the class instance owner Owner string `yaml:"owner,omitempty"` + // SelectiveBuilding allows the module to be built with subset of dependencies + SelectiveBuilding bool `yaml:"selectiveBuilding,omitempty" json:"selectiveBuilding"` } // ClassConfig maps onto a YAML configuration for a class type diff --git a/codegen/module_system.go b/codegen/module_system.go index b312f89d6..5e2db680b 100644 --- a/codegen/module_system.go +++ b/codegen/module_system.go @@ -241,6 +241,7 @@ func NewDefaultModuleSystemWithMockHook( serviceMock bool, configFile string, parallelizeFactor int, + selectiveBuilding bool, hooks ...PostGenHook, ) (*ModuleSystem, error) { t, err := NewDefaultTemplate() @@ -267,16 +268,17 @@ func NewDefaultModuleSystemWithMockHook( hooks = append(hooks, serviceMockGenHook) } - return NewDefaultModuleSystem(h, hooks...) + return NewDefaultModuleSystem(h, selectiveBuilding, hooks...) } // NewDefaultModuleSystem creates a fresh instance of the default zanzibar // module system (clients, endpoints, services) func NewDefaultModuleSystem( h *PackageHelper, + selectiveBuilding bool, hooks ...PostGenHook, ) (*ModuleSystem, error) { - system := NewModuleSystem(h.moduleSearchPaths, h.defaultDependencies, hooks...) + system := NewModuleSystem(h.moduleSearchPaths, h.defaultDependencies, selectiveBuilding, hooks...) tmpl, err := NewDefaultTemplate() if err != nil { diff --git a/codegen/module_test.go b/codegen/module_test.go index 1ea7b82e4..f7ef099da 100644 --- a/codegen/module_test.go +++ b/codegen/module_test.go @@ -113,6 +113,26 @@ func (*TestHTTPEndpointGenerator) ComputeSpec( }, nil } +type TestServiceSpec struct { + Info string +} + +type TestServiceGenerator struct{} + +func (*TestServiceGenerator) ComputeSpec( + instance *ModuleInstance, +) (interface{}, error) { + return &TestServiceSpec{ + Info: "gateway", + }, nil +} + +func (*TestServiceGenerator) Generate( + instance *ModuleInstance, +) (*BuildResult, error) { + return nil, nil +} + func TestExampleService(t *testing.T) { moduleSystem := NewModuleSystem( map[string][]string{ @@ -129,6 +149,7 @@ func TestExampleService(t *testing.T) { "service": {"services/*"}, }, map[string][]string{}, + false, ) var err error @@ -520,6 +541,405 @@ func TestExampleServiceIncremental(t *testing.T) { "service": {"services/*"}, }, map[string][]string{}, + false, + ) + var err error + + err = moduleSystem.RegisterClass(ModuleClass{ + Name: "client", + NamePlural: "clients", + ClassType: MultiModule, + }) + if err != nil { + t.Errorf("Unexpected error registering client class: %s", err) + } + + err = moduleSystem.RegisterClassType( + "client", + "http", + &TestHTTPClientGenerator{}, + ) + if err != nil { + t.Errorf("Unexpected error registering http client class type: %s", err) + } + + err = moduleSystem.RegisterClassType( + "client", + "tchannel", + &TestTChannelClientGenerator{}, + ) + if err != nil { + t.Errorf("Unexpected error registering tchannel client class type: %s", err) + } + + err = moduleSystem.RegisterClassType( + "client", + "grpc", + &TestGRPCClientGenerator{}, + ) + if err != nil { + t.Errorf("Unexpected error regarding grpc client class type :%s", err) + } + + err = moduleSystem.RegisterClass(ModuleClass{ + Name: "endpoint", + NamePlural: "endpoints", + ClassType: MultiModule, + DependsOn: []string{"client"}, + }) + if err != nil { + t.Errorf("Unexpected error registering endpoint class: %s", err) + } + + err = moduleSystem.RegisterClassType( + "endpoint", + "http", + &TestHTTPEndpointGenerator{}, + ) + if err != nil { + t.Errorf("Unexpected error registering http client class type: %s", err) + } + + err = moduleSystem.RegisterClassType( + "endpoint", + "http", + &TestHTTPEndpointGenerator{}, + ) + if err == nil { + t.Errorf("Expected double creation of http endpoint to error") + } + + err = moduleSystem.RegisterClass(ModuleClass{ + Name: "client", + NamePlural: "clients", + ClassType: MultiModule, + }) + if err == nil { + t.Errorf("Expected double definition of client class to error") + } + + packageRoot := "github.com/uber/zanzibar/codegen/test-service" + currentDir := getTestDirName() + testServiceDir := path.Join(currentDir, "test-service") + targetGenDir := path.Join(testServiceDir, "build") + + resolvedModules, err := moduleSystem.ResolveModules(packageRoot, testServiceDir, targetGenDir) + if err != nil { + t.Errorf("Unexpected error generating modukes %s", err) + } + + instances, err := moduleSystem.IncrementalBuild( + packageRoot, + testServiceDir, + targetGenDir, + []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example", + }, + { + ClassName: "client", + InstanceName: "example-grpc", + }, + }, + resolvedModules, + true, + ) + if err != nil { + t.Errorf("Unexpected error generating build %s", err) + } + + expectedClientDependency := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "client", + ClassType: "tchannel", + Directory: "clients/example-dependency", + InstanceName: "example-dependency", + JSONFileName: "", + YAMLFileName: "client-config.yaml", + PackageInfo: &PackageInfo{ + ExportName: "NewClient", + ExportType: "Client", + GeneratedPackageAlias: "exampledependencyClientGenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/clients/example-dependency", + IsExportGenerated: true, + PackageAlias: "exampledependencyClientStatic", + PackageName: "exampledependencyClient", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/clients/example-dependency", + }, + Dependencies: []ModuleDependency{}, + ResolvedDependencies: map[string][]*ModuleInstance{}, + RecursiveDependencies: map[string][]*ModuleInstance{}, + } + + expectedClientInstance := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "client", + ClassType: "http", + Directory: "clients/example", + InstanceName: "example", + JSONFileName: "", + YAMLFileName: "client-config.yaml", + PackageInfo: &PackageInfo{ + ExportName: "NewClient", + ExportType: "Client", + GeneratedPackageAlias: "exampleClientGenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/clients/example", + IsExportGenerated: true, + PackageAlias: "exampleClientStatic", + PackageName: "exampleClient", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/clients/example", + }, + Dependencies: []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example-dependency", + }, + }, + ResolvedDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientDependency, + }, + }, + RecursiveDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientDependency, + }, + }, + } + + expectedGRPCClientInstance := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "client", + ClassType: "grpc", + Directory: "clients/example-example", + InstanceName: "example-grpc", + JSONFileName: "", + YAMLFileName: "client-config.yaml", + PackageInfo: &PackageInfo{ + ExportName: "NewClient", + ExportType: "Client", + GeneratedPackageAlias: "exampleClientGenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/clients/example-grpc", + IsExportGenerated: true, + PackageAlias: "exampleClientStatic", + PackageName: "exampleClient", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/clients/example-grpc", + }, + Dependencies: []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example-dependency", + }, + }, + ResolvedDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientDependency, + }, + }, + RecursiveDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientDependency, + }, + }, + } + + expectedHealthEndpointInstance := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "endpoint", + ClassType: "http", + Directory: "endpoints/health", + InstanceName: "health", + JSONFileName: "endpoint-config.json", + YAMLFileName: "", + PackageInfo: &PackageInfo{ + ExportName: "NewEndpoint", + ExportType: "Endpoint", + GeneratedPackageAlias: "healthendpointgenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/endpoints/health", + IsExportGenerated: true, + PackageAlias: "healthendpointstatic", + PackageName: "healthendpoint", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/endpoints/health", + }, + Dependencies: []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example", + }, + }, + ResolvedDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientInstance, + }, + }, + RecursiveDependencies: map[string][]*ModuleInstance{ + "client": { + // Note that the dependencies are ordered + &expectedClientDependency, + &expectedClientInstance, + }, + }, + } + + expectedFooEndpointInstance := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "endpoint", + ClassType: "http", + Directory: "more-endpoints/foo", + InstanceName: "more-endpoints/foo", + JSONFileName: "", + YAMLFileName: "endpoint-config.yaml", + PackageInfo: &PackageInfo{ + ExportName: "NewEndpoint", + ExportType: "Endpoint", + GeneratedPackageAlias: "fooendpointgenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/more-endpoints/foo", + IsExportGenerated: true, + PackageAlias: "fooendpointstatic", + PackageName: "fooendpoint", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/more-endpoints/foo", + }, + Dependencies: []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example", + }, + }, + ResolvedDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientInstance, + }, + }, + RecursiveDependencies: map[string][]*ModuleInstance{ + "client": { + // Note that the dependencies are ordered + &expectedClientDependency, + &expectedClientInstance, + }, + }, + } + + expectedBarEndpointInstance := ModuleInstance{ + BaseDirectory: testServiceDir, + ClassName: "endpoint", + ClassType: "http", + Directory: "another/bar", + InstanceName: "another/bar", + JSONFileName: "", + YAMLFileName: "endpoint-config.yaml", + PackageInfo: &PackageInfo{ + ExportName: "NewEndpoint", + ExportType: "Endpoint", + GeneratedPackageAlias: "barendpointgenerated", + GeneratedPackagePath: "github.com/uber/zanzibar/codegen/test-service/build/another/bar", + IsExportGenerated: true, + PackageAlias: "barendpointstatic", + PackageName: "barendpoint", + PackagePath: "github.com/uber/zanzibar/codegen/test-service/another/bar", + }, + Dependencies: []ModuleDependency{ + { + ClassName: "client", + InstanceName: "example", + }, + }, + ResolvedDependencies: map[string][]*ModuleInstance{ + "client": { + &expectedClientInstance, + }, + }, + RecursiveDependencies: map[string][]*ModuleInstance{ + "client": { + // Note that the dependencies are ordered + &expectedClientDependency, + &expectedClientInstance, + }, + }, + } + + expectedClients := []*ModuleInstance{ + &expectedClientInstance, + &expectedGRPCClientInstance, + } + expectedEndpoints := []*ModuleInstance{ + &expectedHealthEndpointInstance, + &expectedFooEndpointInstance, + &expectedBarEndpointInstance, + } + + for className, classInstances := range instances { + sort.Slice(classInstances, func(i, j int) bool { + return classInstances[i].InstanceName < classInstances[j].InstanceName + }) + + sort.Slice(expectedEndpoints, func(i, j int) bool { + return expectedEndpoints[i].InstanceName < expectedEndpoints[j].InstanceName + }) + + sort.Slice(expectedClients, func(i, j int) bool { + return expectedClients[i].InstanceName < expectedClients[j].InstanceName + }) + + if className == "client" { + if len(classInstances) != len(expectedClients) { + t.Errorf( + "Expected %d client class instance but found %d", + len(expectedClients), + len(classInstances), + ) + } + + for _, instance := range expectedClients { + compareInstances(t, instance, expectedClients) + } + } else if className == "endpoint" { + if len(classInstances) != len(expectedEndpoints) { + t.Errorf( + "Expected %d endpoint class instance but found %d", + len(expectedEndpoints), + len(classInstances), + ) + } + + for _, instance := range classInstances { + compareInstances(t, instance, expectedEndpoints) + + clientDependency := instance.ResolvedDependencies["client"][0] + clientSpec, ok := clientDependency.GeneratedSpec().(*TestClientSpec) + if !ok { + t.Errorf("type casting failed %s\n", clientDependency) + } + + if clientSpec.Info != instance.ClassType { + t.Errorf( + "Expected client spec info on generated client spec", + ) + } + } + } else { + t.Errorf("Unexpected resolved class type %s", className) + } + } +} + +func TestExampleServiceIncrementalSelective(t *testing.T) { + moduleSystem := NewModuleSystem( + map[string][]string{ + "client": { + "clients/*", + "endpoints/*/*", + }, + "endpoint": { + "endpoints/*", + "another/*", + "more-endpoints/*", + }, + "middleware": {"middlewares/*"}, + "service": {"services/*"}, + }, + map[string][]string{}, + true, ) var err error @@ -596,6 +1016,20 @@ func TestExampleServiceIncremental(t *testing.T) { t.Errorf("Expected double definition of client class to error") } + if err := moduleSystem.RegisterClass(ModuleClass{ + Name: "service", + NamePlural: "services", + ClassType: MultiModule, + DependsOn: []string{"endpoint"}, + }); err != nil { + t.Errorf("Unexpected error registering service: %s", err) + } + + if err := moduleSystem.RegisterClassType("service", "gateway", + &TestServiceGenerator{}); err != nil { + t.Errorf("Unexpected error registering service class type: %s", err) + } + packageRoot := "github.com/uber/zanzibar/codegen/test-service" currentDir := getTestDirName() testServiceDir := path.Join(currentDir, "test-service") @@ -895,6 +1329,13 @@ func TestExampleServiceIncremental(t *testing.T) { ) } } + } else if className == "service" { + if len(classInstances) != 1 { + t.Errorf( + "Expected 1 service class instance but found %d", + len(classInstances), + ) + } } else { t.Errorf("Unexpected resolved class type %s", className) } @@ -914,6 +1355,7 @@ func TestDefaultDependency(t *testing.T) { "clients/*", }, }, + false, ) var err error @@ -1035,6 +1477,7 @@ func TestSingleDefaultDependency(t *testing.T) { "clients/example", }, }, + false, ) var err error @@ -1154,6 +1597,7 @@ func TestNoClassDefaultDependency(t *testing.T) { "clients/example", }, }, + false, ) var err error @@ -1324,7 +1768,7 @@ func TestSortDependencies(t *testing.T) { } func TestSortModuleClasses(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1357,7 +1801,7 @@ func TestSortModuleClasses(t *testing.T) { } func TestSortModuleClassesNoDeps(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1385,7 +1829,7 @@ func TestSortModuleClassesNoDeps(t *testing.T) { } func TestSortModuleClassesUndefined(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1404,7 +1848,7 @@ func TestSortModuleClassesUndefined(t *testing.T) { } func TestSortModuleClassesUndefined2(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1423,7 +1867,7 @@ func TestSortModuleClassesUndefined2(t *testing.T) { } func TestSortableModuleClassCycle(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1443,7 +1887,7 @@ func TestSortableModuleClassCycle(t *testing.T) { } func TestSortableModuleClassCycle2(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1463,7 +1907,7 @@ func TestSortableModuleClassCycle2(t *testing.T) { } func TestSortModuleClassesIndirectCycle(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1488,7 +1932,7 @@ func TestSortModuleClassesIndirectCycle(t *testing.T) { } func TestSortModuleClassesIndirectCycle2(t *testing.T) { - ms := NewModuleSystem(map[string][]string{}, map[string][]string{}) + ms := NewModuleSystem(map[string][]string{}, map[string][]string{}, false) err := ms.RegisterClass(ModuleClass{ Name: "a", NamePlural: "as", @@ -1932,6 +2376,7 @@ func TestModuleSearchDuplicateGlobs(t *testing.T) { moduleSystem := NewModuleSystem( map[string][]string{"client": {"clients/*", "clients/*"}}, map[string][]string{}, + false, ) var err error diff --git a/codegen/runner/runner.go b/codegen/runner/runner.go index cdc588690..be48b37cd 100644 --- a/codegen/runner/runner.go +++ b/codegen/runner/runner.go @@ -59,6 +59,7 @@ func main() { configFile := flag.String("config", "", "the config file path") moduleName := flag.String("instance", "", "") moduleClass := flag.String("type", "", "") + selectiveModule := flag.Bool("selective", false, "") flag.Parse() if *configFile == "" { @@ -112,7 +113,9 @@ func main() { config.MustGetStruct("moduleSearchPaths", &searchPaths) defaultDependencies := make(map[string][]string, 0) - config.MustGetStruct("defaultDependencies", &defaultDependencies) + if config.ContainsKey("defaultDependencies") { + config.MustGetStruct("defaultDependencies", &defaultDependencies) + } options := &codegen.PackageHelperOptions{ RelThriftRootDir: config.MustGetString("thriftRootDir"), @@ -148,9 +151,10 @@ func main() { if config.ContainsKey("parallelizeFactor") { parallelizeFactor = int(config.MustGetInt("parallelizeFactor")) } - moduleSystem, err = codegen.NewDefaultModuleSystemWithMockHook(packageHelper, true, true, true, "test.yaml", parallelizeFactor) + moduleSystem, err = codegen.NewDefaultModuleSystemWithMockHook(packageHelper, true, true, true, "test.yaml", + parallelizeFactor, true) } else { - moduleSystem, err = codegen.NewDefaultModuleSystem(packageHelper) + moduleSystem, err = codegen.NewDefaultModuleSystem(packageHelper, true) } checkError( err, fmt.Sprintf("Error creating module system %s", configRoot), @@ -170,13 +174,33 @@ func main() { } } } else { - //lint:ignore SA1019 Migration to incremental builds is ongoing - _, err = moduleSystem.GenerateBuild( + resolvedModules, err := moduleSystem.ResolveModules(packageHelper.PackageRoot(), configRoot, packageHelper.CodeGenTargetPath()) + checkError(err, "error resolving modules") + var dependencies []codegen.ModuleDependency + if *selectiveModule { + dependencies = getSelectiveModule() + } + _, err = moduleSystem.IncrementalBuild( packageHelper.PackageRoot(), configRoot, packageHelper.CodeGenTargetPath(), + dependencies, resolvedModules, true, ) + checkError(err, "Failed to generate module system components") + } +} + +func getSelectiveModule() []codegen.ModuleDependency { + dependencies := []codegen.ModuleDependency{ + { + ClassName: "endpoint", + InstanceName: "bounce", + }, + { + ClassName: "client", + InstanceName: "echo", + }, } - checkError(err, "Failed to generate module system components") + return dependencies } diff --git a/codegen/template_test.go b/codegen/template_test.go index b78dbdc12..95d82f871 100644 --- a/codegen/template_test.go +++ b/codegen/template_test.go @@ -74,7 +74,7 @@ func TestGenerateBar(t *testing.T) { return } - moduleSystem, err := codegen.NewDefaultModuleSystem(packageHelper) + moduleSystem, err := codegen.NewDefaultModuleSystem(packageHelper, false) if !assert.NoError(t, err, "failed to create module system", err) { return } diff --git a/codegen/test-service/services/test-gateway/service-config.yaml b/codegen/test-service/services/test-gateway/service-config.yaml new file mode 100644 index 000000000..3868a1fe7 --- /dev/null +++ b/codegen/test-service/services/test-gateway/service-config.yaml @@ -0,0 +1,9 @@ +name: test-gateway +type: gateway +config: {} +dependencies: + endpoint: + - health + - another/bar + - more-endpoints/foo +selectiveBuilding: true \ No newline at end of file diff --git a/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go b/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go index 1029d2a77..1a0ecfe52 100644 --- a/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go +++ b/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go @@ -19178,12 +19178,10 @@ func init() { Key *BarResponse Value string }, err error) { - if result.Success != nil { success = result.Success return } - err = errors.New("expected a non-void result") return } diff --git a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go index 81c71c069..114423bb8 100644 --- a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go +++ b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go @@ -1,6 +1,6 @@ // Code generated by zanzibar // @generated -// Checksum : 9zgP5K2Lb0boF4QiOt3OzQ== +// Checksum : g2CDkggDo3mVcd4T4A3CPQ== // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. package bar @@ -12,7 +12,6 @@ import ( easyjson "github.com/mailru/easyjson" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" - base "github.com/uber/zanzibar/examples/example-gateway/build/gen-code/clients/foo/base/base" foo "github.com/uber/zanzibar/examples/example-gateway/build/gen-code/clients/foo/foo" ) @@ -3844,7 +3843,7 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if out.FooException == nil { out.FooException = new(foo.FooException) } - easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(in, out.FooException) + (*out.FooException).UnmarshalEasyJSON(in) } default: in.SkipRecursive() @@ -3884,7 +3883,7 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo } else { out.RawString(prefix) } - easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(out, *in.FooException) + (*in.FooException).MarshalEasyJSON(out) } out.RawByte('}') } @@ -3912,53 +3911,6 @@ func (v *Bar_TooManyArgs_Result) UnmarshalJSON(data []byte) error { func (v *Bar_TooManyArgs_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs(l, v) } -func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(in *jlexer.Lexer, out *foo.FooException) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - var TeapotSet bool - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "teapot": - out.Teapot = string(in.String()) - TeapotSet = true - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } - if !TeapotSet { - in.AddError(fmt.Errorf("key 'teapot' is required")) - } -} -func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(out *jwriter.Writer, in foo.FooException) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"teapot\":" - out.RawString(prefix[1:]) - out.String(string(in.Teapot)) - } - out.RawByte('}') -} func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(in *jlexer.Lexer, out *Bar_TooManyArgs_Args) { isTopLevel := in.IsStart() if in.IsNull() { @@ -3998,7 +3950,7 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if out.Foo == nil { out.Foo = new(foo.FooStruct) } - easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(in, out.Foo) + (*out.Foo).UnmarshalEasyJSON(in) } default: in.SkipRecursive() @@ -4029,7 +3981,7 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if in.Foo != nil { const prefix string = ",\"foo\":" out.RawString(prefix) - easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(out, *in.Foo) + (*in.Foo).MarshalEasyJSON(out) } out.RawByte('}') } @@ -4057,214 +4009,6 @@ func (v *Bar_TooManyArgs_Args) UnmarshalJSON(data []byte) error { func (v *Bar_TooManyArgs_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(l, v) } -func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(in *jlexer.Lexer, out *foo.FooStruct) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - var FooStringSet bool - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "fooString": - out.FooString = string(in.String()) - FooStringSet = true - case "fooI32": - if in.IsNull() { - in.Skip() - out.FooI32 = nil - } else { - if out.FooI32 == nil { - out.FooI32 = new(int32) - } - *out.FooI32 = int32(in.Int32()) - } - case "fooI16": - if in.IsNull() { - in.Skip() - out.FooI16 = nil - } else { - if out.FooI16 == nil { - out.FooI16 = new(int16) - } - *out.FooI16 = int16(in.Int16()) - } - case "fooDouble": - if in.IsNull() { - in.Skip() - out.FooDouble = nil - } else { - if out.FooDouble == nil { - out.FooDouble = new(float64) - } - *out.FooDouble = float64(in.Float64()) - } - case "fooBool": - if in.IsNull() { - in.Skip() - out.FooBool = nil - } else { - if out.FooBool == nil { - out.FooBool = new(bool) - } - *out.FooBool = bool(in.Bool()) - } - case "fooMap": - if in.IsNull() { - in.Skip() - } else { - in.Delim('{') - if !in.IsDelim('}') { - out.FooMap = make(map[string]string) - } else { - out.FooMap = nil - } - for !in.IsDelim('}') { - key := string(in.String()) - in.WantColon() - var v46 string - v46 = string(in.String()) - (out.FooMap)[key] = v46 - in.WantComma() - } - in.Delim('}') - } - case "message": - if in.IsNull() { - in.Skip() - out.Message = nil - } else { - if out.Message == nil { - out.Message = new(base.Message) - } - easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(in, out.Message) - } - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } - if !FooStringSet { - in.AddError(fmt.Errorf("key 'fooString' is required")) - } -} -func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(out *jwriter.Writer, in foo.FooStruct) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"fooString\":" - out.RawString(prefix[1:]) - out.String(string(in.FooString)) - } - if in.FooI32 != nil { - const prefix string = ",\"fooI32\":" - out.RawString(prefix) - out.Int32(int32(*in.FooI32)) - } - if in.FooI16 != nil { - const prefix string = ",\"fooI16\":" - out.RawString(prefix) - out.Int16(int16(*in.FooI16)) - } - if in.FooDouble != nil { - const prefix string = ",\"fooDouble\":" - out.RawString(prefix) - out.Float64(float64(*in.FooDouble)) - } - if in.FooBool != nil { - const prefix string = ",\"fooBool\":" - out.RawString(prefix) - out.Bool(bool(*in.FooBool)) - } - if len(in.FooMap) != 0 { - const prefix string = ",\"fooMap\":" - out.RawString(prefix) - { - out.RawByte('{') - v47First := true - for v47Name, v47Value := range in.FooMap { - if v47First { - v47First = false - } else { - out.RawByte(',') - } - out.String(string(v47Name)) - out.RawByte(':') - out.String(string(v47Value)) - } - out.RawByte('}') - } - } - if in.Message != nil { - const prefix string = ",\"message\":" - out.RawString(prefix) - easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(out, *in.Message) - } - out.RawByte('}') -} -func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(in *jlexer.Lexer, out *base.Message) { - isTopLevel := in.IsStart() - if in.IsNull() { - if isTopLevel { - in.Consumed() - } - in.Skip() - return - } - var BodySet bool - in.Delim('{') - for !in.IsDelim('}') { - key := in.UnsafeString() - in.WantColon() - if in.IsNull() { - in.Skip() - in.WantComma() - continue - } - switch key { - case "body": - out.Body = string(in.String()) - BodySet = true - default: - in.SkipRecursive() - } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } - if !BodySet { - in.AddError(fmt.Errorf("key 'body' is required")) - } -} -func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(out *jwriter.Writer, in base.Message) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"body\":" - out.RawString(prefix[1:]) - out.String(string(in.Body)) - } - out.RawByte('}') -} func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarNormal(in *jlexer.Lexer, out *Bar_Normal_Result) { isTopLevel := in.IsStart() if in.IsNull() { @@ -5060,9 +4804,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.DemoIds = (out.DemoIds)[:0] } for !in.IsDelim(']') { - var v48 string - v48 = string(in.String()) - out.DemoIds = append(out.DemoIds, v48) + var v46 string + v46 = string(in.String()) + out.DemoIds = append(out.DemoIds, v46) in.WantComma() } in.Delim(']') @@ -5096,11 +4840,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Demos = (out.Demos)[:0] } for !in.IsDelim(']') { - var v49 DemoType + var v47 DemoType if data := in.Raw(); in.Ok() { - in.AddError((v49).UnmarshalJSON(data)) + in.AddError((v47).UnmarshalJSON(data)) } - out.Demos = append(out.Demos, v49) + out.Demos = append(out.Demos, v47) in.WantComma() } in.Delim(']') @@ -5129,11 +4873,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v50, v51 := range in.DemoIds { - if v50 > 0 { + for v48, v49 := range in.DemoIds { + if v48 > 0 { out.RawByte(',') } - out.String(string(v51)) + out.String(string(v49)) } out.RawByte(']') } @@ -5148,11 +4892,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v52, v53 := range in.Demos { - if v52 > 0 { + for v50, v51 := range in.Demos { + if v50 > 0 { out.RawByte(',') } - out.Raw((v53).MarshalJSON()) + out.Raw((v51).MarshalJSON()) } out.RawByte(']') } @@ -5737,9 +5481,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Foo = (out.Foo)[:0] } for !in.IsDelim(']') { - var v54 string - v54 = string(in.String()) - out.Foo = append(out.Foo, v54) + var v52 string + v52 = string(in.String()) + out.Foo = append(out.Foo, v52) in.WantComma() } in.Delim(']') @@ -5760,9 +5504,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Bar = (out.Bar)[:0] } for !in.IsDelim(']') { - var v55 int8 - v55 = int8(in.Int8()) - out.Bar = append(out.Bar, v55) + var v53 int8 + v53 = int8(in.Int8()) + out.Bar = append(out.Bar, v53) in.WantComma() } in.Delim(']') @@ -5803,11 +5547,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v56, v57 := range in.Foo { - if v56 > 0 { + for v54, v55 := range in.Foo { + if v54 > 0 { out.RawByte(',') } - out.String(string(v57)) + out.String(string(v55)) } out.RawByte(']') } @@ -5819,11 +5563,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v58, v59 := range in.Bar { - if v58 > 0 { + for v56, v57 := range in.Bar { + if v56 > 0 { out.RawByte(',') } - out.Int8(int8(v59)) + out.Int8(int8(v57)) } out.RawByte(']') } @@ -6927,9 +6671,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AListUUID = (out.AListUUID)[:0] } for !in.IsDelim(']') { - var v60 UUID - v60 = UUID(in.String()) - out.AListUUID = append(out.AListUUID, v60) + var v58 UUID + v58 = UUID(in.String()) + out.AListUUID = append(out.AListUUID, v58) in.WantComma() } in.Delim(']') @@ -6951,9 +6695,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptListUUID = (out.AnOptListUUID)[:0] } for !in.IsDelim(']') { - var v61 UUID - v61 = UUID(in.String()) - out.AnOptListUUID = append(out.AnOptListUUID, v61) + var v59 UUID + v59 = UUID(in.String()) + out.AnOptListUUID = append(out.AnOptListUUID, v59) in.WantComma() } in.Delim(']') @@ -6974,9 +6718,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AStringList = (out.AStringList)[:0] } for !in.IsDelim(']') { - var v62 string - v62 = string(in.String()) - out.AStringList = append(out.AStringList, v62) + var v60 string + v60 = string(in.String()) + out.AStringList = append(out.AStringList, v60) in.WantComma() } in.Delim(']') @@ -6998,9 +6742,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptStringList = (out.AnOptStringList)[:0] } for !in.IsDelim(']') { - var v63 string - v63 = string(in.String()) - out.AnOptStringList = append(out.AnOptStringList, v63) + var v61 string + v61 = string(in.String()) + out.AnOptStringList = append(out.AnOptStringList, v61) in.WantComma() } in.Delim(']') @@ -7021,9 +6765,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AUUIDList = (out.AUUIDList)[:0] } for !in.IsDelim(']') { - var v64 UUID - v64 = UUID(in.String()) - out.AUUIDList = append(out.AUUIDList, v64) + var v62 UUID + v62 = UUID(in.String()) + out.AUUIDList = append(out.AUUIDList, v62) in.WantComma() } in.Delim(']') @@ -7045,9 +6789,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptUUIDList = (out.AnOptUUIDList)[:0] } for !in.IsDelim(']') { - var v65 UUID - v65 = UUID(in.String()) - out.AnOptUUIDList = append(out.AnOptUUIDList, v65) + var v63 UUID + v63 = UUID(in.String()) + out.AnOptUUIDList = append(out.AnOptUUIDList, v63) in.WantComma() } in.Delim(']') @@ -7102,11 +6846,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AReqFruits = (out.AReqFruits)[:0] } for !in.IsDelim(']') { - var v66 Fruit + var v64 Fruit if data := in.Raw(); in.Ok() { - in.AddError((v66).UnmarshalJSON(data)) + in.AddError((v64).UnmarshalJSON(data)) } - out.AReqFruits = append(out.AReqFruits, v66) + out.AReqFruits = append(out.AReqFruits, v64) in.WantComma() } in.Delim(']') @@ -7128,11 +6872,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptDemos = (out.AnOptDemos)[:0] } for !in.IsDelim(']') { - var v67 DemoType + var v65 DemoType if data := in.Raw(); in.Ok() { - in.AddError((v67).UnmarshalJSON(data)) + in.AddError((v65).UnmarshalJSON(data)) } - out.AnOptDemos = append(out.AnOptDemos, v67) + out.AnOptDemos = append(out.AnOptDemos, v65) in.WantComma() } in.Delim(']') @@ -7280,11 +7024,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v68, v69 := range in.AListUUID { - if v68 > 0 { + for v66, v67 := range in.AListUUID { + if v66 > 0 { out.RawByte(',') } - out.String(string(v69)) + out.String(string(v67)) } out.RawByte(']') } @@ -7294,11 +7038,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v70, v71 := range in.AnOptListUUID { - if v70 > 0 { + for v68, v69 := range in.AnOptListUUID { + if v68 > 0 { out.RawByte(',') } - out.String(string(v71)) + out.String(string(v69)) } out.RawByte(']') } @@ -7310,11 +7054,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v72, v73 := range in.AStringList { - if v72 > 0 { + for v70, v71 := range in.AStringList { + if v70 > 0 { out.RawByte(',') } - out.String(string(v73)) + out.String(string(v71)) } out.RawByte(']') } @@ -7324,11 +7068,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v74, v75 := range in.AnOptStringList { - if v74 > 0 { + for v72, v73 := range in.AnOptStringList { + if v72 > 0 { out.RawByte(',') } - out.String(string(v75)) + out.String(string(v73)) } out.RawByte(']') } @@ -7340,11 +7084,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v76, v77 := range in.AUUIDList { - if v76 > 0 { + for v74, v75 := range in.AUUIDList { + if v74 > 0 { out.RawByte(',') } - out.String(string(v77)) + out.String(string(v75)) } out.RawByte(']') } @@ -7354,11 +7098,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v78, v79 := range in.AnOptUUIDList { - if v78 > 0 { + for v76, v77 := range in.AnOptUUIDList { + if v76 > 0 { out.RawByte(',') } - out.String(string(v79)) + out.String(string(v77)) } out.RawByte(']') } @@ -7390,11 +7134,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v80, v81 := range in.AReqFruits { - if v80 > 0 { + for v78, v79 := range in.AReqFruits { + if v78 > 0 { out.RawByte(',') } - out.Raw((v81).MarshalJSON()) + out.Raw((v79).MarshalJSON()) } out.RawByte(']') } @@ -7404,11 +7148,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v82, v83 := range in.AnOptDemos { - if v82 > 0 { + for v80, v81 := range in.AnOptDemos { + if v80 > 0 { out.RawByte(',') } - out.Raw((v83).MarshalJSON()) + out.Raw((v81).MarshalJSON()) } out.RawByte(']') } @@ -7776,9 +7520,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Nodes = (out.Nodes)[:0] } for !in.IsDelim(']') { - var v84 string - v84 = string(in.String()) - out.Nodes = append(out.Nodes, v84) + var v82 string + v82 = string(in.String()) + out.Nodes = append(out.Nodes, v82) in.WantComma() } in.Delim(']') @@ -7814,11 +7558,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v85, v86 := range in.Nodes { - if v85 > 0 { + for v83, v84 := range in.Nodes { + if v83 > 0 { out.RawByte(',') } - out.String(string(v86)) + out.String(string(v84)) } out.RawByte(']') } @@ -7897,9 +7641,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo for !in.IsDelim('}') { key := UUID(in.String()) in.WantColon() - var v87 int32 - v87 = int32(in.Int32()) - (out.MapIntWithRange)[key] = v87 + var v85 int32 + v85 = int32(in.Int32()) + (out.MapIntWithRange)[key] = v85 in.WantComma() } in.Delim('}') @@ -7914,9 +7658,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v88 int32 - v88 = int32(in.Int32()) - (out.MapIntWithoutRange)[key] = v88 + var v86 int32 + v86 = int32(in.Int32()) + (out.MapIntWithoutRange)[key] = v86 in.WantComma() } in.Delim('}') @@ -7994,16 +7738,16 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(`null`) } else { out.RawByte('{') - v90First := true - for v90Name, v90Value := range in.MapIntWithRange { - if v90First { - v90First = false + v88First := true + for v88Name, v88Value := range in.MapIntWithRange { + if v88First { + v88First = false } else { out.RawByte(',') } - out.String(string(v90Name)) + out.String(string(v88Name)) out.RawByte(':') - out.Int32(int32(v90Value)) + out.Int32(int32(v88Value)) } out.RawByte('}') } @@ -8015,16 +7759,16 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(`null`) } else { out.RawByte('{') - v91First := true - for v91Name, v91Value := range in.MapIntWithoutRange { - if v91First { - v91First = false + v89First := true + for v89Name, v89Value := range in.MapIntWithoutRange { + if v89First { + v89First = false } else { out.RawByte(',') } - out.String(string(v91Name)) + out.String(string(v89Name)) out.RawByte(':') - out.Int32(int32(v91Value)) + out.Int32(int32(v89Value)) } out.RawByte('}') } diff --git a/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go b/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go index 5ff3db320..4e483bbe7 100644 --- a/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go +++ b/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go @@ -8259,12 +8259,10 @@ func init() { Key *base.BazResponse Value string }, err error) { - if result.Success != nil { success = result.Success return } - err = errors.New("expected a non-void result") return } diff --git a/examples/selective-gateway/app.go b/examples/selective-gateway/app.go new file mode 100644 index 000000000..20c801867 --- /dev/null +++ b/examples/selective-gateway/app.go @@ -0,0 +1,79 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package app + +import ( + "net/textproto" + + "github.com/uber/zanzibar/runtime/jsonwrapper" + + "go.uber.org/zap" + + "context" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// AppOptions defines the custom application func +var AppOptions = &zanzibar.Options{ + GetContextScopeExtractors: getContextScopeTagExtractors, + GetContextFieldExtractors: getContextLogFieldExtractors, + JSONWrapper: jsonwrapper.NewDefaultJSONWrapper(), +} + +func getContextScopeTagExtractors() []zanzibar.ContextScopeTagsExtractor { + extractors := []zanzibar.ContextScopeTagsExtractor{ + getRequestTags, + } + + return extractors +} + +func getContextLogFieldExtractors() []zanzibar.ContextLogFieldsExtractor { + extractors := []zanzibar.ContextLogFieldsExtractor{ + getRequestFields, + } + + return extractors +} + +func getRequestTags(ctx context.Context) map[string]string { + tags := map[string]string{} + headers := zanzibar.GetEndpointRequestHeadersFromCtx(ctx) + tags["regionname"] = headers["Regionname"] + tags["device"] = headers["Device"] + tags["deviceversion"] = headers["Deviceversion"] + + return tags +} + +func getRequestFields(ctx context.Context) []zap.Field { + var fields []zap.Field + headers := zanzibar.GetEndpointRequestHeadersFromCtx(ctx) + + for k, v := range headers { + if textproto.CanonicalMIMEHeaderKey("x-token") == textproto.CanonicalMIMEHeaderKey(k) { + continue + } + fields = append(fields, zap.String(k, v)) + } + return fields +} diff --git a/examples/selective-gateway/build.yaml b/examples/selective-gateway/build.yaml new file mode 100644 index 000000000..7844a06c4 --- /dev/null +++ b/examples/selective-gateway/build.yaml @@ -0,0 +1,27 @@ +annotationPrefix: zanzibar +clientConfig: ./clients +copyrightHeader: ./copyright_header.txt +endpointConfig: ./endpoints +genCodePackage: github.com/uber/zanzibar/examples/selective-gateway/build/gen-code +genMock: true +middlewareConfig: ./middlewares +defaultMiddlewareConfig: ./middlewares/default +packageRoot: github.com/uber/zanzibar/examples/selective-gateway +targetGenDir: ./build +thriftRootDir: ./idl +traceKey: x-trace-id +moduleSearchPaths: + client: + - clients/* + - app/*/clients/* + middleware: + - middlewares/* + - middlewares/default/* + endpoint: + - endpoints/* + - endpoints/tchannel/* + - app/*/endpoints/* + service: + - services/* + - app/*/services/* + diff --git a/examples/selective-gateway/build/clients/echo/echo.go b/examples/selective-gateway/build/clients/echo/echo.go new file mode 100644 index 000000000..cb0adc28c --- /dev/null +++ b/examples/selective-gateway/build/clients/echo/echo.go @@ -0,0 +1,164 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package echoclient + +import ( + "context" + + "github.com/afex/hystrix-go/hystrix" + "go.uber.org/yarpc" + + module "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo/module" + gen "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/echo" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Client defines echo client interface. +type Client interface { + Echo( + ctx context.Context, + request *gen.Request, + opts ...yarpc.CallOption, + ) (*gen.Response, error) +} + +// echoClient is the gRPC client for downstream service. +type echoClient struct { + client gen.EchoYARPCClient + opts *zanzibar.GRPCClientOpts +} + +// NewClient returns a new gRPC client for service echo +func NewClient(deps *module.Dependencies) Client { + oc := deps.Default.GRPCClientDispatcher.MustOutboundConfig("echo") + var routingKey string + if deps.Default.Config.ContainsKey("clients.echo.routingKey") { + routingKey = deps.Default.Config.MustGetString("clients.echo.routingKey") + } + var requestUUIDHeaderKey string + if deps.Default.Config.ContainsKey("clients.echo.requestUUIDHeaderKey") { + requestUUIDHeaderKey = deps.Default.Config.MustGetString("clients.echo.requestUUIDHeaderKey") + } + timeoutInMS := int(deps.Default.Config.MustGetInt("clients.echo.timeout")) + methodNames := map[string]string{ + "Echo::Echo": "Echo", + } + return &echoClient{ + client: gen.NewEchoYARPCClient(oc), + opts: zanzibar.NewGRPCClientOpts( + deps.Default.Logger, + deps.Default.ContextMetrics, + deps.Default.ContextExtractor, + methodNames, + "echo", + "Echo", + routingKey, + requestUUIDHeaderKey, + configureCicruitBreaker(deps, timeoutInMS), + timeoutInMS, + ), + } +} + +func configureCicruitBreaker(deps *module.Dependencies, timeoutVal int) bool { + // circuitBreakerDisabled sets whether circuit-breaker should be disabled + circuitBreakerDisabled := false + if deps.Default.Config.ContainsKey("clients.echo.circuitBreakerDisabled") { + circuitBreakerDisabled = deps.Default.Config.MustGetBoolean("clients.echo.circuitBreakerDisabled") + } + if circuitBreakerDisabled { + return false + } + // sleepWindowInMilliseconds sets the amount of time, after tripping the circuit, + // to reject requests before allowing attempts again to determine if the circuit should again be closed + sleepWindowInMilliseconds := 5000 + if deps.Default.Config.ContainsKey("clients.echo.sleepWindowInMilliseconds") { + sleepWindowInMilliseconds = int(deps.Default.Config.MustGetInt("clients.echo.sleepWindowInMilliseconds")) + } + // maxConcurrentRequests sets how many requests can be run at the same time, beyond which requests are rejected + maxConcurrentRequests := 20 + if deps.Default.Config.ContainsKey("clients.echo.maxConcurrentRequests") { + maxConcurrentRequests = int(deps.Default.Config.MustGetInt("clients.echo.maxConcurrentRequests")) + } + // errorPercentThreshold sets the error percentage at or above which the circuit should trip open + errorPercentThreshold := 20 + if deps.Default.Config.ContainsKey("clients.echo.errorPercentThreshold") { + errorPercentThreshold = int(deps.Default.Config.MustGetInt("clients.echo.errorPercentThreshold")) + } + // requestVolumeThreshold sets a minimum number of requests that will trip the circuit in a rolling window of 10s + // For example, if the value is 20, then if only 19 requests are received in the rolling window of 10 seconds + // the circuit will not trip open even if all 19 failed. + requestVolumeThreshold := 20 + if deps.Default.Config.ContainsKey("clients.echo.requestVolumeThreshold") { + requestVolumeThreshold = int(deps.Default.Config.MustGetInt("clients.echo.requestVolumeThreshold")) + } + + hystrix.ConfigureCommand("echo", hystrix.CommandConfig{ + MaxConcurrentRequests: maxConcurrentRequests, + ErrorPercentThreshold: errorPercentThreshold, + SleepWindow: sleepWindowInMilliseconds, + RequestVolumeThreshold: requestVolumeThreshold, + Timeout: timeoutVal, + }) + return true +} + +// Echo is a client RPC call for method Echo::Echo. +func (e *echoClient) Echo( + ctx context.Context, + request *gen.Request, + opts ...yarpc.CallOption, +) (*gen.Response, error) { + var result *gen.Response + var err error + + ctx, callHelper := zanzibar.NewGRPCClientCallHelper(ctx, "Echo::Echo", e.opts) + + if e.opts.RoutingKey != "" { + opts = append(opts, yarpc.WithRoutingKey(e.opts.RoutingKey)) + } + if e.opts.RequestUUIDHeaderKey != "" { + reqUUID := zanzibar.RequestUUIDFromCtx(ctx) + if reqUUID != "" { + opts = append(opts, yarpc.WithHeader(e.opts.RequestUUIDHeaderKey, reqUUID)) + } + } + ctx, cancel := context.WithTimeout(ctx, e.opts.Timeout) + defer cancel() + + runFunc := e.client.Echo + callHelper.Start() + if e.opts.CircuitBreakerDisabled { + result, err = runFunc(ctx, request, opts...) + } else { + err = hystrix.DoC(ctx, "echo", func(ctx context.Context) error { + result, err = runFunc(ctx, request, opts...) + return err + }, nil) + } + callHelper.Finish(ctx, err) + + return result, err +} diff --git a/examples/selective-gateway/build/clients/echo/mock-client/mock_client.go b/examples/selective-gateway/build/clients/echo/mock-client/mock_client.go new file mode 100644 index 000000000..287350728 --- /dev/null +++ b/examples/selective-gateway/build/clients/echo/mock-client/mock_client.go @@ -0,0 +1,57 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo (interfaces: Client) + +// Package clientmock is a generated GoMock package. +package clientmock + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + echo "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/echo" + yarpc "go.uber.org/yarpc" +) + +// MockClient is a mock of Client interface +type MockClient struct { + ctrl *gomock.Controller + recorder *MockClientMockRecorder +} + +// MockClientMockRecorder is the mock recorder for MockClient +type MockClientMockRecorder struct { + mock *MockClient +} + +// NewMockClient creates a new mock instance +func NewMockClient(ctrl *gomock.Controller) *MockClient { + mock := &MockClient{ctrl: ctrl} + mock.recorder = &MockClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockClient) EXPECT() *MockClientMockRecorder { + return m.recorder +} + +// Echo mocks base method +func (m *MockClient) Echo(arg0 context.Context, arg1 *echo.Request, arg2 ...yarpc.CallOption) (*echo.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{arg0, arg1} + for _, a := range arg2 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Echo", varargs...) + ret0, _ := ret[0].(*echo.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Echo indicates an expected call of Echo +func (mr *MockClientMockRecorder) Echo(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{arg0, arg1}, arg2...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Echo", reflect.TypeOf((*MockClient)(nil).Echo), varargs...) +} diff --git a/examples/selective-gateway/build/clients/echo/module/dependencies.go b/examples/selective-gateway/build/clients/echo/module/dependencies.go new file mode 100644 index 000000000..7734d280f --- /dev/null +++ b/examples/selective-gateway/build/clients/echo/module/dependencies.go @@ -0,0 +1,33 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Dependencies contains dependencies for the echo client module +type Dependencies struct { + Default *zanzibar.DefaultDependencies +} diff --git a/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go b/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go new file mode 100644 index 000000000..5662fc305 --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go @@ -0,0 +1,178 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package bounceendpoint + +import ( + "context" + "runtime/debug" + "time" + + "github.com/pkg/errors" + tchannel "github.com/uber/tchannel-go" + zanzibar "github.com/uber/zanzibar/runtime" + "go.uber.org/thriftrw/wire" + "go.uber.org/zap" + + endpointsBounceBounce "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce" + customBounce "github.com/uber/zanzibar/examples/selective-gateway/endpoints/bounce" + + module "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" +) + +// NewBounceBounceHandler creates a handler to be registered with a thrift server. +func NewBounceBounceHandler(deps *module.Dependencies) *BounceBounceHandler { + handler := &BounceBounceHandler{ + Deps: deps, + } + handler.endpoint = zanzibar.NewTChannelEndpoint( + "bounce", "bounce", "Bounce::bounce", + handler, + ) + + return handler +} + +// BounceBounceHandler is the handler for "Bounce::bounce". +type BounceBounceHandler struct { + Deps *module.Dependencies + endpoint *zanzibar.TChannelEndpoint +} + +// Register adds the tchannel handler to the gateway's tchannel router +func (h *BounceBounceHandler) Register(g *zanzibar.Gateway) error { + return g.TChannelRouter.Register(h.endpoint) +} + +// Handle handles RPC call of "Bounce::bounce". +func (h *BounceBounceHandler) Handle( + ctx context.Context, + reqHeaders map[string]string, + wireValue *wire.Value, +) (isSuccessful bool, response zanzibar.RWTStruct, headers map[string]string, e error) { + defer func() { + if r := recover(); r != nil { + stacktrace := string(debug.Stack()) + e = errors.Errorf("enpoint panic: %v, stacktrace: %v", r, stacktrace) + h.Deps.Default.ContextLogger.Error( + ctx, + "Endpoint failure: endpoint panic", + zap.Error(e), + zap.String("stacktrace", stacktrace), + zap.String("endpoint", h.endpoint.EndpointID)) + + h.Deps.Default.ContextMetrics.IncCounter(ctx, zanzibar.MetricEndpointPanics, 1) + isSuccessful = false + response = nil + headers = nil + } + }() + + wfReqHeaders := zanzibar.ServerTChannelHeader(reqHeaders) + + var res endpointsBounceBounce.Bounce_Bounce_Result + + var req endpointsBounceBounce.Bounce_Bounce_Args + if err := req.FromWire(*wireValue); err != nil { + h.Deps.Default.ContextLogger.Error(ctx, "Endpoint failure: error converting request from wire", zap.Error(err)) + return false, nil, nil, errors.Wrapf( + err, "Error converting %s.%s (%s) request from wire", + h.endpoint.EndpointID, h.endpoint.HandlerID, h.endpoint.Method, + ) + } + + if hostPort, ok := reqHeaders["x-deputy-forwarded"]; ok { + if hostPort != "" { + return h.redirectToDeputy(ctx, reqHeaders, hostPort, &req, &res) + } + } + workflow := customBounce.NewBounceBounceWorkflow(h.Deps) + + r, wfResHeaders, err := workflow.Handle(ctx, wfReqHeaders, &req) + + resHeaders := map[string]string{} + if wfResHeaders != nil { + for _, key := range wfResHeaders.Keys() { + resHeaders[key], _ = wfResHeaders.Get(key) + } + } + + if err != nil { + h.Deps.Default.ContextLogger.Error(ctx, "Endpoint failure: handler returned error", zap.Error(err)) + return false, nil, resHeaders, err + } + res.Success = &r + + return err == nil, &res, resHeaders, nil +} + +// redirectToDeputy sends the request to deputy hostPort +func (h *BounceBounceHandler) redirectToDeputy( + ctx context.Context, + reqHeaders map[string]string, + hostPort string, + req *endpointsBounceBounce.Bounce_Bounce_Args, + res *endpointsBounceBounce.Bounce_Bounce_Result, +) (bool, zanzibar.RWTStruct, map[string]string, error) { + var routingKey string + if h.Deps.Default.Config.ContainsKey("tchannel.routingKey") { + routingKey = h.Deps.Default.Config.MustGetString("tchannel.routingKey") + } + + serviceName := h.Deps.Default.Config.MustGetString("tchannel.serviceName") + timeout := time.Millisecond * time.Duration( + h.Deps.Default.Config.MustGetInt("tchannel.deputy.timeout"), + ) + + timeoutPerAttempt := time.Millisecond * time.Duration( + h.Deps.Default.Config.MustGetInt("tchannel.deputy.timeoutPerAttempt"), + ) + + methodNames := map[string]string{ + "Bounce::bounce": "bounce", + } + + deputyChannel, err := tchannel.NewChannel(serviceName, nil) + if err != nil { + h.Deps.Default.ContextLogger.Error(ctx, "Deputy Failure", zap.Error(err)) + } + defer deputyChannel.Close() + deputyChannel.Peers().Add(hostPort) + client := zanzibar.NewTChannelClientContext( + deputyChannel, + h.Deps.Default.Logger, + h.Deps.Default.ContextMetrics, + h.Deps.Default.ContextExtractor, + &zanzibar.TChannelClientOption{ + ServiceName: serviceName, + ClientID: "", + MethodNames: methodNames, + Timeout: timeout, + TimeoutPerAttempt: timeoutPerAttempt, + RoutingKey: &routingKey, + }, + ) + + success, respHeaders, err := client.Call(ctx, "Bounce", "bounce", reqHeaders, req, res) + return success, res, respHeaders, err +} diff --git a/examples/selective-gateway/build/endpoints/bounce/endpoint.go b/examples/selective-gateway/build/endpoints/bounce/endpoint.go new file mode 100644 index 000000000..6ae45413b --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/endpoint.go @@ -0,0 +1,56 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package bounceendpoint + +import ( + module "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Endpoint registers a request handler on a gateway +type Endpoint interface { + Register(*zanzibar.Gateway) error +} + +// NewEndpoint returns a collection of endpoints that can be registered on +// a gateway +func NewEndpoint(deps *module.Dependencies) Endpoint { + return &EndpointHandlers{ + BounceBounceHandler: NewBounceBounceHandler(deps), + } +} + +// EndpointHandlers is a collection of individual endpoint handlers +type EndpointHandlers struct { + BounceBounceHandler *BounceBounceHandler +} + +// Register registers the endpoint handlers with the gateway +func (handlers *EndpointHandlers) Register(gateway *zanzibar.Gateway) error { + err0 := handlers.BounceBounceHandler.Register(gateway) + if err0 != nil { + return err0 + } + return nil +} diff --git a/examples/selective-gateway/build/endpoints/bounce/mock-workflow/bounce_bounce_workflow_mock.go b/examples/selective-gateway/build/endpoints/bounce/mock-workflow/bounce_bounce_workflow_mock.go new file mode 100644 index 000000000..5ce1c5aff --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/mock-workflow/bounce_bounce_workflow_mock.go @@ -0,0 +1,67 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package mockbounceworkflow + +import ( + "testing" + + "github.com/golang/mock/gomock" + "github.com/uber-go/tally" + zanzibar "github.com/uber/zanzibar/runtime" + "go.uber.org/zap" + + echoclientgeneratedmock "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo/mock-client" + module "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" + workflow "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/workflow" + bounceendpointstatic "github.com/uber/zanzibar/examples/selective-gateway/endpoints/bounce" +) + +// NewBounceBounceWorkflowMock creates a workflow with mock clients +func NewBounceBounceWorkflowMock(t *testing.T) (workflow.BounceBounceWorkflow, *MockClientNodes) { + ctrl := gomock.NewController(t) + + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + Logger: zap.NewNop(), + Scope: tally.NewTestScope("", make(map[string]string)), + } + initializedDefaultDependencies.ContextLogger = zanzibar.NewContextLogger(initializedDefaultDependencies.Logger) + initializedDefaultDependencies.ContextExtractor = &zanzibar.ContextExtractors{} + + initializedClientDependencies := &clientDependenciesNodes{} + mockClientNodes := &MockClientNodes{ + Echo: echoclientgeneratedmock.NewMockClient(ctrl), + } + initializedClientDependencies.Echo = mockClientNodes.Echo + + w := bounceendpointstatic.NewBounceBounceWorkflow( + &module.Dependencies{ + Default: initializedDefaultDependencies, + Client: &module.ClientDependencies{ + Echo: initializedClientDependencies.Echo, + }, + }, + ) + + return w, mockClientNodes +} diff --git a/examples/selective-gateway/build/endpoints/bounce/mock-workflow/type.go b/examples/selective-gateway/build/endpoints/bounce/mock-workflow/type.go new file mode 100644 index 000000000..cdc408b24 --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/mock-workflow/type.go @@ -0,0 +1,39 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package mockbounceworkflow + +import ( + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + echoclientgeneratedmock "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo/mock-client" +) + +// MockClientNodes contains mock client dependencies for the bounce endpoint module +type MockClientNodes struct { + Echo *echoclientgeneratedmock.MockClient +} + +// clientDependenciesNodes contains client dependencies +type clientDependenciesNodes struct { + Echo echoclientgenerated.Client +} diff --git a/examples/selective-gateway/build/endpoints/bounce/module/dependencies.go b/examples/selective-gateway/build/endpoints/bounce/module/dependencies.go new file mode 100644 index 000000000..93a042c7a --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/module/dependencies.go @@ -0,0 +1,41 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Dependencies contains dependencies for the bounce endpoint module +type Dependencies struct { + Default *zanzibar.DefaultDependencies + Client *ClientDependencies +} + +// ClientDependencies contains client dependencies +type ClientDependencies struct { + Echo echoclientgenerated.Client +} diff --git a/examples/selective-gateway/build/endpoints/bounce/workflow/bounce_bounce_method_bounce_tchannel.go b/examples/selective-gateway/build/endpoints/bounce/workflow/bounce_bounce_method_bounce_tchannel.go new file mode 100644 index 000000000..d5f5aabce --- /dev/null +++ b/examples/selective-gateway/build/endpoints/bounce/workflow/bounce_bounce_method_bounce_tchannel.go @@ -0,0 +1,41 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package workflow + +import ( + "context" + + zanzibar "github.com/uber/zanzibar/runtime" + + endpointsBounceBounce "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce" +) + +// BounceBounceWorkflow defines the interface for BounceBounce workflow +type BounceBounceWorkflow interface { + Handle( + ctx context.Context, + reqHeaders zanzibar.Header, + r *endpointsBounceBounce.Bounce_Bounce_Args, + ) (string, zanzibar.Header, error) +} diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go new file mode 100644 index 000000000..268e9542c --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go @@ -0,0 +1,20250 @@ +// Code generated by thriftrw v1.20.2. DO NOT EDIT. +// @generated + +package bar + +import ( + bytes "bytes" + base64 "encoding/base64" + json "encoding/json" + errors "errors" + fmt "fmt" + math "math" + strconv "strconv" + strings "strings" + + foo "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/foo/foo" + multierr "go.uber.org/multierr" + wire "go.uber.org/thriftrw/wire" + zapcore "go.uber.org/zap/zapcore" +) + +type BarException struct { + StringField string `json:"stringField,required"` +} + +// ToWire translates a BarException struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *BarException) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.StringField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a BarException struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a BarException struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v BarException +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *BarException) FromWire(w wire.Value) error { + var err error + + stringFieldIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.StringField, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + stringFieldIsSet = true + } + } + } + + if !stringFieldIsSet { + return errors.New("field StringField of BarException is required") + } + + return nil +} + +// String returns a readable string representation of a BarException +// struct. +func (v *BarException) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("StringField: %v", v.StringField) + i++ + + return fmt.Sprintf("BarException{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this BarException match the +// provided BarException. +// +// This function performs a deep comparison. +func (v *BarException) Equals(rhs *BarException) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.StringField == rhs.StringField) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of BarException. +func (v *BarException) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("stringField", v.StringField) + return err +} + +// GetStringField returns the value of StringField if it is set or its +// zero value if it is unset. +func (v *BarException) GetStringField() (o string) { + if v != nil { + o = v.StringField + } + return +} + +func (v *BarException) Error() string { + return v.String() +} + +type BarRequest struct { + StringField string `json:"stringField,required"` + BoolField bool `json:"boolField,required"` + BinaryField []byte `json:"binaryField,required"` + Timestamp Timestamp `json:"timestamp,required"` + EnumField Fruit `json:"enumField,required"` + LongField Long `json:"longField,required"` +} + +// ToWire translates a BarRequest struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *BarRequest) ToWire() (wire.Value, error) { + var ( + fields [6]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.StringField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + w, err = wire.NewValueBool(v.BoolField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + if v.BinaryField == nil { + return w, errors.New("field BinaryField of BarRequest is required") + } + w, err = wire.NewValueBinary(v.BinaryField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + + w, err = v.Timestamp.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + + w, err = v.EnumField.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 5, Value: w} + i++ + + w, err = v.LongField.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 6, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Timestamp_Read(w wire.Value) (Timestamp, error) { + var x Timestamp + err := x.FromWire(w) + return x, err +} + +func _Fruit_Read(w wire.Value) (Fruit, error) { + var v Fruit + err := v.FromWire(w) + return v, err +} + +func _Long_Read(w wire.Value) (Long, error) { + var x Long + err := x.FromWire(w) + return x, err +} + +// FromWire deserializes a BarRequest struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a BarRequest struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v BarRequest +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *BarRequest) FromWire(w wire.Value) error { + var err error + + stringFieldIsSet := false + boolFieldIsSet := false + binaryFieldIsSet := false + timestampIsSet := false + enumFieldIsSet := false + longFieldIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.StringField, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + stringFieldIsSet = true + } + case 2: + if field.Value.Type() == wire.TBool { + v.BoolField, err = field.Value.GetBool(), error(nil) + if err != nil { + return err + } + boolFieldIsSet = true + } + case 3: + if field.Value.Type() == wire.TBinary { + v.BinaryField, err = field.Value.GetBinary(), error(nil) + if err != nil { + return err + } + binaryFieldIsSet = true + } + case 4: + if field.Value.Type() == wire.TI64 { + v.Timestamp, err = _Timestamp_Read(field.Value) + if err != nil { + return err + } + timestampIsSet = true + } + case 5: + if field.Value.Type() == wire.TI32 { + v.EnumField, err = _Fruit_Read(field.Value) + if err != nil { + return err + } + enumFieldIsSet = true + } + case 6: + if field.Value.Type() == wire.TI64 { + v.LongField, err = _Long_Read(field.Value) + if err != nil { + return err + } + longFieldIsSet = true + } + } + } + + if !stringFieldIsSet { + return errors.New("field StringField of BarRequest is required") + } + + if !boolFieldIsSet { + return errors.New("field BoolField of BarRequest is required") + } + + if !binaryFieldIsSet { + return errors.New("field BinaryField of BarRequest is required") + } + + if !timestampIsSet { + return errors.New("field Timestamp of BarRequest is required") + } + + if !enumFieldIsSet { + return errors.New("field EnumField of BarRequest is required") + } + + if !longFieldIsSet { + return errors.New("field LongField of BarRequest is required") + } + + return nil +} + +// String returns a readable string representation of a BarRequest +// struct. +func (v *BarRequest) String() string { + if v == nil { + return "" + } + + var fields [6]string + i := 0 + fields[i] = fmt.Sprintf("StringField: %v", v.StringField) + i++ + fields[i] = fmt.Sprintf("BoolField: %v", v.BoolField) + i++ + fields[i] = fmt.Sprintf("BinaryField: %v", v.BinaryField) + i++ + fields[i] = fmt.Sprintf("Timestamp: %v", v.Timestamp) + i++ + fields[i] = fmt.Sprintf("EnumField: %v", v.EnumField) + i++ + fields[i] = fmt.Sprintf("LongField: %v", v.LongField) + i++ + + return fmt.Sprintf("BarRequest{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this BarRequest match the +// provided BarRequest. +// +// This function performs a deep comparison. +func (v *BarRequest) Equals(rhs *BarRequest) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.StringField == rhs.StringField) { + return false + } + if !(v.BoolField == rhs.BoolField) { + return false + } + if !bytes.Equal(v.BinaryField, rhs.BinaryField) { + return false + } + if !(v.Timestamp == rhs.Timestamp) { + return false + } + if !v.EnumField.Equals(rhs.EnumField) { + return false + } + if !(v.LongField == rhs.LongField) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of BarRequest. +func (v *BarRequest) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("stringField", v.StringField) + enc.AddBool("boolField", v.BoolField) + enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) + enc.AddInt64("timestamp", (int64)(v.Timestamp)) + err = multierr.Append(err, enc.AddObject("enumField", v.EnumField)) + enc.AddInt64("longField", (int64)(v.LongField)) + return err +} + +// GetStringField returns the value of StringField if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetStringField() (o string) { + if v != nil { + o = v.StringField + } + return +} + +// GetBoolField returns the value of BoolField if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetBoolField() (o bool) { + if v != nil { + o = v.BoolField + } + return +} + +// GetBinaryField returns the value of BinaryField if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetBinaryField() (o []byte) { + if v != nil { + o = v.BinaryField + } + return +} + +// IsSetBinaryField returns true if BinaryField is not nil. +func (v *BarRequest) IsSetBinaryField() bool { + return v != nil && v.BinaryField != nil +} + +// GetTimestamp returns the value of Timestamp if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetTimestamp() (o Timestamp) { + if v != nil { + o = v.Timestamp + } + return +} + +// GetEnumField returns the value of EnumField if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetEnumField() (o Fruit) { + if v != nil { + o = v.EnumField + } + return +} + +// GetLongField returns the value of LongField if it is set or its +// zero value if it is unset. +func (v *BarRequest) GetLongField() (o Long) { + if v != nil { + o = v.LongField + } + return +} + +type BarRequestRecur struct { + Name string `json:"name,required"` + Recur *BarRequestRecur `json:"recur,omitempty"` +} + +// ToWire translates a BarRequestRecur struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *BarRequestRecur) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Name), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.Recur != nil { + w, err = v.Recur.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _BarRequestRecur_Read(w wire.Value) (*BarRequestRecur, error) { + var v BarRequestRecur + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a BarRequestRecur struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a BarRequestRecur struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v BarRequestRecur +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *BarRequestRecur) FromWire(w wire.Value) error { + var err error + + nameIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Name, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + nameIsSet = true + } + case 2: + if field.Value.Type() == wire.TStruct { + v.Recur, err = _BarRequestRecur_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !nameIsSet { + return errors.New("field Name of BarRequestRecur is required") + } + + return nil +} + +// String returns a readable string representation of a BarRequestRecur +// struct. +func (v *BarRequestRecur) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Name: %v", v.Name) + i++ + if v.Recur != nil { + fields[i] = fmt.Sprintf("Recur: %v", v.Recur) + i++ + } + + return fmt.Sprintf("BarRequestRecur{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this BarRequestRecur match the +// provided BarRequestRecur. +// +// This function performs a deep comparison. +func (v *BarRequestRecur) Equals(rhs *BarRequestRecur) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Name == rhs.Name) { + return false + } + if !((v.Recur == nil && rhs.Recur == nil) || (v.Recur != nil && rhs.Recur != nil && v.Recur.Equals(rhs.Recur))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of BarRequestRecur. +func (v *BarRequestRecur) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("name", v.Name) + if v.Recur != nil { + err = multierr.Append(err, enc.AddObject("recur", v.Recur)) + } + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *BarRequestRecur) GetName() (o string) { + if v != nil { + o = v.Name + } + return +} + +// GetRecur returns the value of Recur if it is set or its +// zero value if it is unset. +func (v *BarRequestRecur) GetRecur() (o *BarRequestRecur) { + if v != nil && v.Recur != nil { + return v.Recur + } + + return +} + +// IsSetRecur returns true if Recur is not nil. +func (v *BarRequestRecur) IsSetRecur() bool { + return v != nil && v.Recur != nil +} + +type BarResponse struct { + StringField string `json:"stringField,required"` + IntWithRange int32 `json:"intWithRange,required"` + IntWithoutRange int32 `json:"intWithoutRange,required"` + MapIntWithRange map[UUID]int32 `json:"mapIntWithRange,required"` + MapIntWithoutRange map[string]int32 `json:"mapIntWithoutRange,required"` + BinaryField []byte `json:"binaryField,required"` + NextResponse *BarResponse `json:"nextResponse,omitempty"` +} + +type _Map_UUID_I32_MapItemList map[UUID]int32 + +func (m _Map_UUID_I32_MapItemList) ForEach(f func(wire.MapItem) error) error { + for k, v := range m { + kw, err := k.ToWire() + if err != nil { + return err + } + + vw, err := wire.NewValueI32(v), error(nil) + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_UUID_I32_MapItemList) Size() int { + return len(m) +} + +func (_Map_UUID_I32_MapItemList) KeyType() wire.Type { + return wire.TBinary +} + +func (_Map_UUID_I32_MapItemList) ValueType() wire.Type { + return wire.TI32 +} + +func (_Map_UUID_I32_MapItemList) Close() {} + +type _Map_String_I32_MapItemList map[string]int32 + +func (m _Map_String_I32_MapItemList) ForEach(f func(wire.MapItem) error) error { + for k, v := range m { + kw, err := wire.NewValueString(k), error(nil) + if err != nil { + return err + } + + vw, err := wire.NewValueI32(v), error(nil) + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_String_I32_MapItemList) Size() int { + return len(m) +} + +func (_Map_String_I32_MapItemList) KeyType() wire.Type { + return wire.TBinary +} + +func (_Map_String_I32_MapItemList) ValueType() wire.Type { + return wire.TI32 +} + +func (_Map_String_I32_MapItemList) Close() {} + +// ToWire translates a BarResponse struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *BarResponse) ToWire() (wire.Value, error) { + var ( + fields [7]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.StringField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + w, err = wire.NewValueI32(v.IntWithRange), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + + w, err = wire.NewValueI32(v.IntWithoutRange), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + if v.MapIntWithRange == nil { + return w, errors.New("field MapIntWithRange of BarResponse is required") + } + w, err = wire.NewValueMap(_Map_UUID_I32_MapItemList(v.MapIntWithRange)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + if v.MapIntWithoutRange == nil { + return w, errors.New("field MapIntWithoutRange of BarResponse is required") + } + w, err = wire.NewValueMap(_Map_String_I32_MapItemList(v.MapIntWithoutRange)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 5, Value: w} + i++ + if v.BinaryField == nil { + return w, errors.New("field BinaryField of BarResponse is required") + } + w, err = wire.NewValueBinary(v.BinaryField), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 6, Value: w} + i++ + if v.NextResponse != nil { + w, err = v.NextResponse.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 7, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _UUID_Read(w wire.Value) (UUID, error) { + var x UUID + err := x.FromWire(w) + return x, err +} + +func _Map_UUID_I32_Read(m wire.MapItemList) (map[UUID]int32, error) { + if m.KeyType() != wire.TBinary { + return nil, nil + } + + if m.ValueType() != wire.TI32 { + return nil, nil + } + + o := make(map[UUID]int32, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := _UUID_Read(x.Key) + if err != nil { + return err + } + + v, err := x.Value.GetI32(), error(nil) + if err != nil { + return err + } + + o[k] = v + return nil + }) + m.Close() + return o, err +} + +func _Map_String_I32_Read(m wire.MapItemList) (map[string]int32, error) { + if m.KeyType() != wire.TBinary { + return nil, nil + } + + if m.ValueType() != wire.TI32 { + return nil, nil + } + + o := make(map[string]int32, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := x.Key.GetString(), error(nil) + if err != nil { + return err + } + + v, err := x.Value.GetI32(), error(nil) + if err != nil { + return err + } + + o[k] = v + return nil + }) + m.Close() + return o, err +} + +func _BarResponse_Read(w wire.Value) (*BarResponse, error) { + var v BarResponse + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a BarResponse struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a BarResponse struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v BarResponse +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *BarResponse) FromWire(w wire.Value) error { + var err error + + stringFieldIsSet := false + intWithRangeIsSet := false + intWithoutRangeIsSet := false + mapIntWithRangeIsSet := false + mapIntWithoutRangeIsSet := false + binaryFieldIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.StringField, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + stringFieldIsSet = true + } + case 2: + if field.Value.Type() == wire.TI32 { + v.IntWithRange, err = field.Value.GetI32(), error(nil) + if err != nil { + return err + } + intWithRangeIsSet = true + } + case 3: + if field.Value.Type() == wire.TI32 { + v.IntWithoutRange, err = field.Value.GetI32(), error(nil) + if err != nil { + return err + } + intWithoutRangeIsSet = true + } + case 4: + if field.Value.Type() == wire.TMap { + v.MapIntWithRange, err = _Map_UUID_I32_Read(field.Value.GetMap()) + if err != nil { + return err + } + mapIntWithRangeIsSet = true + } + case 5: + if field.Value.Type() == wire.TMap { + v.MapIntWithoutRange, err = _Map_String_I32_Read(field.Value.GetMap()) + if err != nil { + return err + } + mapIntWithoutRangeIsSet = true + } + case 6: + if field.Value.Type() == wire.TBinary { + v.BinaryField, err = field.Value.GetBinary(), error(nil) + if err != nil { + return err + } + binaryFieldIsSet = true + } + case 7: + if field.Value.Type() == wire.TStruct { + v.NextResponse, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !stringFieldIsSet { + return errors.New("field StringField of BarResponse is required") + } + + if !intWithRangeIsSet { + return errors.New("field IntWithRange of BarResponse is required") + } + + if !intWithoutRangeIsSet { + return errors.New("field IntWithoutRange of BarResponse is required") + } + + if !mapIntWithRangeIsSet { + return errors.New("field MapIntWithRange of BarResponse is required") + } + + if !mapIntWithoutRangeIsSet { + return errors.New("field MapIntWithoutRange of BarResponse is required") + } + + if !binaryFieldIsSet { + return errors.New("field BinaryField of BarResponse is required") + } + + return nil +} + +// String returns a readable string representation of a BarResponse +// struct. +func (v *BarResponse) String() string { + if v == nil { + return "" + } + + var fields [7]string + i := 0 + fields[i] = fmt.Sprintf("StringField: %v", v.StringField) + i++ + fields[i] = fmt.Sprintf("IntWithRange: %v", v.IntWithRange) + i++ + fields[i] = fmt.Sprintf("IntWithoutRange: %v", v.IntWithoutRange) + i++ + fields[i] = fmt.Sprintf("MapIntWithRange: %v", v.MapIntWithRange) + i++ + fields[i] = fmt.Sprintf("MapIntWithoutRange: %v", v.MapIntWithoutRange) + i++ + fields[i] = fmt.Sprintf("BinaryField: %v", v.BinaryField) + i++ + if v.NextResponse != nil { + fields[i] = fmt.Sprintf("NextResponse: %v", v.NextResponse) + i++ + } + + return fmt.Sprintf("BarResponse{%v}", strings.Join(fields[:i], ", ")) +} + +func _Map_UUID_I32_Equals(lhs, rhs map[UUID]int32) bool { + if len(lhs) != len(rhs) { + return false + } + + for lk, lv := range lhs { + rv, ok := rhs[lk] + if !ok { + return false + } + if !(lv == rv) { + return false + } + } + return true +} + +func _Map_String_I32_Equals(lhs, rhs map[string]int32) bool { + if len(lhs) != len(rhs) { + return false + } + + for lk, lv := range lhs { + rv, ok := rhs[lk] + if !ok { + return false + } + if !(lv == rv) { + return false + } + } + return true +} + +// Equals returns true if all the fields of this BarResponse match the +// provided BarResponse. +// +// This function performs a deep comparison. +func (v *BarResponse) Equals(rhs *BarResponse) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.StringField == rhs.StringField) { + return false + } + if !(v.IntWithRange == rhs.IntWithRange) { + return false + } + if !(v.IntWithoutRange == rhs.IntWithoutRange) { + return false + } + if !_Map_UUID_I32_Equals(v.MapIntWithRange, rhs.MapIntWithRange) { + return false + } + if !_Map_String_I32_Equals(v.MapIntWithoutRange, rhs.MapIntWithoutRange) { + return false + } + if !bytes.Equal(v.BinaryField, rhs.BinaryField) { + return false + } + if !((v.NextResponse == nil && rhs.NextResponse == nil) || (v.NextResponse != nil && rhs.NextResponse != nil && v.NextResponse.Equals(rhs.NextResponse))) { + return false + } + + return true +} + +type _Map_UUID_I32_Zapper map[UUID]int32 + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of _Map_UUID_I32_Zapper. +func (m _Map_UUID_I32_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + for k, v := range m { + enc.AddInt32((string)(k), v) + } + return err +} + +type _Map_String_I32_Zapper map[string]int32 + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of _Map_String_I32_Zapper. +func (m _Map_String_I32_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + for k, v := range m { + enc.AddInt32((string)(k), v) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of BarResponse. +func (v *BarResponse) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("stringField", v.StringField) + enc.AddInt32("intWithRange", v.IntWithRange) + enc.AddInt32("intWithoutRange", v.IntWithoutRange) + err = multierr.Append(err, enc.AddObject("mapIntWithRange", (_Map_UUID_I32_Zapper)(v.MapIntWithRange))) + err = multierr.Append(err, enc.AddObject("mapIntWithoutRange", (_Map_String_I32_Zapper)(v.MapIntWithoutRange))) + enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) + if v.NextResponse != nil { + err = multierr.Append(err, enc.AddObject("nextResponse", v.NextResponse)) + } + return err +} + +// GetStringField returns the value of StringField if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetStringField() (o string) { + if v != nil { + o = v.StringField + } + return +} + +// GetIntWithRange returns the value of IntWithRange if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetIntWithRange() (o int32) { + if v != nil { + o = v.IntWithRange + } + return +} + +// GetIntWithoutRange returns the value of IntWithoutRange if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetIntWithoutRange() (o int32) { + if v != nil { + o = v.IntWithoutRange + } + return +} + +// GetMapIntWithRange returns the value of MapIntWithRange if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetMapIntWithRange() (o map[UUID]int32) { + if v != nil { + o = v.MapIntWithRange + } + return +} + +// IsSetMapIntWithRange returns true if MapIntWithRange is not nil. +func (v *BarResponse) IsSetMapIntWithRange() bool { + return v != nil && v.MapIntWithRange != nil +} + +// GetMapIntWithoutRange returns the value of MapIntWithoutRange if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetMapIntWithoutRange() (o map[string]int32) { + if v != nil { + o = v.MapIntWithoutRange + } + return +} + +// IsSetMapIntWithoutRange returns true if MapIntWithoutRange is not nil. +func (v *BarResponse) IsSetMapIntWithoutRange() bool { + return v != nil && v.MapIntWithoutRange != nil +} + +// GetBinaryField returns the value of BinaryField if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetBinaryField() (o []byte) { + if v != nil { + o = v.BinaryField + } + return +} + +// IsSetBinaryField returns true if BinaryField is not nil. +func (v *BarResponse) IsSetBinaryField() bool { + return v != nil && v.BinaryField != nil +} + +// GetNextResponse returns the value of NextResponse if it is set or its +// zero value if it is unset. +func (v *BarResponse) GetNextResponse() (o *BarResponse) { + if v != nil && v.NextResponse != nil { + return v.NextResponse + } + + return +} + +// IsSetNextResponse returns true if NextResponse is not nil. +func (v *BarResponse) IsSetNextResponse() bool { + return v != nil && v.NextResponse != nil +} + +type BarResponseRecur struct { + Nodes []string `json:"nodes,required"` + Height int32 `json:"height,required"` +} + +type _List_String_ValueList []string + +func (v _List_String_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + w, err := wire.NewValueString(x), error(nil) + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_String_ValueList) Size() int { + return len(v) +} + +func (_List_String_ValueList) ValueType() wire.Type { + return wire.TBinary +} + +func (_List_String_ValueList) Close() {} + +// ToWire translates a BarResponseRecur struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *BarResponseRecur) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Nodes == nil { + return w, errors.New("field Nodes of BarResponseRecur is required") + } + w, err = wire.NewValueList(_List_String_ValueList(v.Nodes)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + w, err = wire.NewValueI32(v.Height), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _List_String_Read(l wire.ValueList) ([]string, error) { + if l.ValueType() != wire.TBinary { + return nil, nil + } + + o := make([]string, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := x.GetString(), error(nil) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +// FromWire deserializes a BarResponseRecur struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a BarResponseRecur struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v BarResponseRecur +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *BarResponseRecur) FromWire(w wire.Value) error { + var err error + + nodesIsSet := false + heightIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TList { + v.Nodes, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + nodesIsSet = true + } + case 2: + if field.Value.Type() == wire.TI32 { + v.Height, err = field.Value.GetI32(), error(nil) + if err != nil { + return err + } + heightIsSet = true + } + } + } + + if !nodesIsSet { + return errors.New("field Nodes of BarResponseRecur is required") + } + + if !heightIsSet { + return errors.New("field Height of BarResponseRecur is required") + } + + return nil +} + +// String returns a readable string representation of a BarResponseRecur +// struct. +func (v *BarResponseRecur) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Nodes: %v", v.Nodes) + i++ + fields[i] = fmt.Sprintf("Height: %v", v.Height) + i++ + + return fmt.Sprintf("BarResponseRecur{%v}", strings.Join(fields[:i], ", ")) +} + +func _List_String_Equals(lhs, rhs []string) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !(lv == rv) { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this BarResponseRecur match the +// provided BarResponseRecur. +// +// This function performs a deep comparison. +func (v *BarResponseRecur) Equals(rhs *BarResponseRecur) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_List_String_Equals(v.Nodes, rhs.Nodes) { + return false + } + if !(v.Height == rhs.Height) { + return false + } + + return true +} + +type _List_String_Zapper []string + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_String_Zapper. +func (l _List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + enc.AppendString(v) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of BarResponseRecur. +func (v *BarResponseRecur) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("nodes", (_List_String_Zapper)(v.Nodes))) + enc.AddInt32("height", v.Height) + return err +} + +// GetNodes returns the value of Nodes if it is set or its +// zero value if it is unset. +func (v *BarResponseRecur) GetNodes() (o []string) { + if v != nil { + o = v.Nodes + } + return +} + +// IsSetNodes returns true if Nodes is not nil. +func (v *BarResponseRecur) IsSetNodes() bool { + return v != nil && v.Nodes != nil +} + +// GetHeight returns the value of Height if it is set or its +// zero value if it is unset. +func (v *BarResponseRecur) GetHeight() (o int32) { + if v != nil { + o = v.Height + } + return +} + +type DemoType int32 + +const ( + DemoTypeFirst DemoType = 0 + DemoTypeSecond DemoType = 1 +) + +// DemoType_Values returns all recognized values of DemoType. +func DemoType_Values() []DemoType { + return []DemoType{ + DemoTypeFirst, + DemoTypeSecond, + } +} + +// UnmarshalText tries to decode DemoType from a byte slice +// containing its name. +// +// var v DemoType +// err := v.UnmarshalText([]byte("FIRST")) +func (v *DemoType) UnmarshalText(value []byte) error { + switch s := string(value); s { + case "FIRST": + *v = DemoTypeFirst + return nil + case "SECOND": + *v = DemoTypeSecond + return nil + default: + val, err := strconv.ParseInt(s, 10, 32) + if err != nil { + return fmt.Errorf("unknown enum value %q for %q: %v", s, "DemoType", err) + } + *v = DemoType(val) + return nil + } +} + +// MarshalText encodes DemoType to text. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements the TextMarshaler interface. +func (v DemoType) MarshalText() ([]byte, error) { + switch int32(v) { + case 0: + return []byte("FIRST"), nil + case 1: + return []byte("SECOND"), nil + } + return []byte(strconv.FormatInt(int64(v), 10)), nil +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of DemoType. +// Enums are logged as objects, where the value is logged with key "value", and +// if this value's name is known, the name is logged with key "name". +func (v DemoType) MarshalLogObject(enc zapcore.ObjectEncoder) error { + enc.AddInt32("value", int32(v)) + switch int32(v) { + case 0: + enc.AddString("name", "FIRST") + case 1: + enc.AddString("name", "SECOND") + } + return nil +} + +// Ptr returns a pointer to this enum value. +func (v DemoType) Ptr() *DemoType { + return &v +} + +// ToWire translates DemoType into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// Enums are represented as 32-bit integers over the wire. +func (v DemoType) ToWire() (wire.Value, error) { + return wire.NewValueI32(int32(v)), nil +} + +// FromWire deserializes DemoType from its Thrift-level +// representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TI32) +// if err != nil { +// return DemoType(0), err +// } +// +// var v DemoType +// if err := v.FromWire(x); err != nil { +// return DemoType(0), err +// } +// return v, nil +func (v *DemoType) FromWire(w wire.Value) error { + *v = (DemoType)(w.GetI32()) + return nil +} + +// String returns a readable string representation of DemoType. +func (v DemoType) String() string { + w := int32(v) + switch w { + case 0: + return "FIRST" + case 1: + return "SECOND" + } + return fmt.Sprintf("DemoType(%d)", w) +} + +// Equals returns true if this DemoType value matches the provided +// value. +func (v DemoType) Equals(rhs DemoType) bool { + return v == rhs +} + +// MarshalJSON serializes DemoType into JSON. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements json.Marshaler. +func (v DemoType) MarshalJSON() ([]byte, error) { + switch int32(v) { + case 0: + return ([]byte)("\"FIRST\""), nil + case 1: + return ([]byte)("\"SECOND\""), nil + } + return ([]byte)(strconv.FormatInt(int64(v), 10)), nil +} + +// UnmarshalJSON attempts to decode DemoType from its JSON +// representation. +// +// This implementation supports both, numeric and string inputs. If a +// string is provided, it must be a known enum name. +// +// This implements json.Unmarshaler. +func (v *DemoType) UnmarshalJSON(text []byte) error { + d := json.NewDecoder(bytes.NewReader(text)) + d.UseNumber() + t, err := d.Token() + if err != nil { + return err + } + + switch w := t.(type) { + case json.Number: + x, err := w.Int64() + if err != nil { + return err + } + if x > math.MaxInt32 { + return fmt.Errorf("enum overflow from JSON %q for %q", text, "DemoType") + } + if x < math.MinInt32 { + return fmt.Errorf("enum underflow from JSON %q for %q", text, "DemoType") + } + *v = (DemoType)(x) + return nil + case string: + return v.UnmarshalText([]byte(w)) + default: + return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "DemoType") + } +} + +type Fruit int32 + +const ( + FruitApple Fruit = 0 + FruitBanana Fruit = 1 +) + +// Fruit_Values returns all recognized values of Fruit. +func Fruit_Values() []Fruit { + return []Fruit{ + FruitApple, + FruitBanana, + } +} + +// UnmarshalText tries to decode Fruit from a byte slice +// containing its name. +// +// var v Fruit +// err := v.UnmarshalText([]byte("APPLE")) +func (v *Fruit) UnmarshalText(value []byte) error { + switch s := string(value); s { + case "APPLE": + *v = FruitApple + return nil + case "BANANA": + *v = FruitBanana + return nil + default: + val, err := strconv.ParseInt(s, 10, 32) + if err != nil { + return fmt.Errorf("unknown enum value %q for %q: %v", s, "Fruit", err) + } + *v = Fruit(val) + return nil + } +} + +// MarshalText encodes Fruit to text. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements the TextMarshaler interface. +func (v Fruit) MarshalText() ([]byte, error) { + switch int32(v) { + case 0: + return []byte("APPLE"), nil + case 1: + return []byte("BANANA"), nil + } + return []byte(strconv.FormatInt(int64(v), 10)), nil +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Fruit. +// Enums are logged as objects, where the value is logged with key "value", and +// if this value's name is known, the name is logged with key "name". +func (v Fruit) MarshalLogObject(enc zapcore.ObjectEncoder) error { + enc.AddInt32("value", int32(v)) + switch int32(v) { + case 0: + enc.AddString("name", "APPLE") + case 1: + enc.AddString("name", "BANANA") + } + return nil +} + +// Ptr returns a pointer to this enum value. +func (v Fruit) Ptr() *Fruit { + return &v +} + +// ToWire translates Fruit into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// Enums are represented as 32-bit integers over the wire. +func (v Fruit) ToWire() (wire.Value, error) { + return wire.NewValueI32(int32(v)), nil +} + +// FromWire deserializes Fruit from its Thrift-level +// representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TI32) +// if err != nil { +// return Fruit(0), err +// } +// +// var v Fruit +// if err := v.FromWire(x); err != nil { +// return Fruit(0), err +// } +// return v, nil +func (v *Fruit) FromWire(w wire.Value) error { + *v = (Fruit)(w.GetI32()) + return nil +} + +// String returns a readable string representation of Fruit. +func (v Fruit) String() string { + w := int32(v) + switch w { + case 0: + return "APPLE" + case 1: + return "BANANA" + } + return fmt.Sprintf("Fruit(%d)", w) +} + +// Equals returns true if this Fruit value matches the provided +// value. +func (v Fruit) Equals(rhs Fruit) bool { + return v == rhs +} + +// MarshalJSON serializes Fruit into JSON. +// +// If the enum value is recognized, its name is returned. Otherwise, +// its integer value is returned. +// +// This implements json.Marshaler. +func (v Fruit) MarshalJSON() ([]byte, error) { + switch int32(v) { + case 0: + return ([]byte)("\"APPLE\""), nil + case 1: + return ([]byte)("\"BANANA\""), nil + } + return ([]byte)(strconv.FormatInt(int64(v), 10)), nil +} + +// UnmarshalJSON attempts to decode Fruit from its JSON +// representation. +// +// This implementation supports both, numeric and string inputs. If a +// string is provided, it must be a known enum name. +// +// This implements json.Unmarshaler. +func (v *Fruit) UnmarshalJSON(text []byte) error { + d := json.NewDecoder(bytes.NewReader(text)) + d.UseNumber() + t, err := d.Token() + if err != nil { + return err + } + + switch w := t.(type) { + case json.Number: + x, err := w.Int64() + if err != nil { + return err + } + if x > math.MaxInt32 { + return fmt.Errorf("enum overflow from JSON %q for %q", text, "Fruit") + } + if x < math.MinInt32 { + return fmt.Errorf("enum underflow from JSON %q for %q", text, "Fruit") + } + *v = (Fruit)(x) + return nil + case string: + return v.UnmarshalText([]byte(w)) + default: + return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "Fruit") + } +} + +type Long int64 + +// LongPtr returns a pointer to a Long +func (v Long) Ptr() *Long { + return &v +} + +// ToWire translates Long into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +func (v Long) ToWire() (wire.Value, error) { + x := (int64)(v) + return wire.NewValueI64(x), error(nil) +} + +// String returns a readable string representation of Long. +func (v Long) String() string { + x := (int64)(v) + return fmt.Sprint(x) +} + +// FromWire deserializes Long from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +func (v *Long) FromWire(w wire.Value) error { + x, err := w.GetI64(), error(nil) + *v = (Long)(x) + return err +} + +// Equals returns true if this Long is equal to the provided +// Long. +func (lhs Long) Equals(rhs Long) bool { + return ((int64)(lhs) == (int64)(rhs)) +} + +type OptionalParamsStruct struct { + UserID *string `json:"userID,omitempty"` +} + +// ToWire translates a OptionalParamsStruct struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *OptionalParamsStruct) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.UserID != nil { + w, err = wire.NewValueString(*(v.UserID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a OptionalParamsStruct struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a OptionalParamsStruct struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v OptionalParamsStruct +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *OptionalParamsStruct) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserID = &x + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a OptionalParamsStruct +// struct. +func (v *OptionalParamsStruct) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.UserID != nil { + fields[i] = fmt.Sprintf("UserID: %v", *(v.UserID)) + i++ + } + + return fmt.Sprintf("OptionalParamsStruct{%v}", strings.Join(fields[:i], ", ")) +} + +func _String_EqualsPtr(lhs, rhs *string) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this OptionalParamsStruct match the +// provided OptionalParamsStruct. +// +// This function performs a deep comparison. +func (v *OptionalParamsStruct) Equals(rhs *OptionalParamsStruct) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.UserID, rhs.UserID) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of OptionalParamsStruct. +func (v *OptionalParamsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.UserID != nil { + enc.AddString("userID", *v.UserID) + } + return err +} + +// GetUserID returns the value of UserID if it is set or its +// zero value if it is unset. +func (v *OptionalParamsStruct) GetUserID() (o string) { + if v != nil && v.UserID != nil { + return *v.UserID + } + + return +} + +// IsSetUserID returns true if UserID is not nil. +func (v *OptionalParamsStruct) IsSetUserID() bool { + return v != nil && v.UserID != nil +} + +type ParamsStruct struct { + UserUUID string `json:"userUUID,required"` +} + +// ToWire translates a ParamsStruct struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *ParamsStruct) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.UserUUID), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a ParamsStruct struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a ParamsStruct struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v ParamsStruct +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *ParamsStruct) FromWire(w wire.Value) error { + var err error + + userUUIDIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.UserUUID, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + userUUIDIsSet = true + } + } + } + + if !userUUIDIsSet { + return errors.New("field UserUUID of ParamsStruct is required") + } + + return nil +} + +// String returns a readable string representation of a ParamsStruct +// struct. +func (v *ParamsStruct) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("UserUUID: %v", v.UserUUID) + i++ + + return fmt.Sprintf("ParamsStruct{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this ParamsStruct match the +// provided ParamsStruct. +// +// This function performs a deep comparison. +func (v *ParamsStruct) Equals(rhs *ParamsStruct) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.UserUUID == rhs.UserUUID) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of ParamsStruct. +func (v *ParamsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("userUUID", v.UserUUID) + return err +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *ParamsStruct) GetUserUUID() (o string) { + if v != nil { + o = v.UserUUID + } + return +} + +type QueryParamsOptsStruct struct { + Name string `json:"name,required"` + UserUUID *string `json:"userUUID,omitempty"` + AuthUUID *string `json:"authUUID,omitempty"` + AuthUUID2 *string `json:"authUUID2,omitempty"` +} + +// ToWire translates a QueryParamsOptsStruct struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *QueryParamsOptsStruct) ToWire() (wire.Value, error) { + var ( + fields [4]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Name), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.UserUUID != nil { + w, err = wire.NewValueString(*(v.UserUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.AuthUUID != nil { + w, err = wire.NewValueString(*(v.AuthUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + if v.AuthUUID2 != nil { + w, err = wire.NewValueString(*(v.AuthUUID2)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a QueryParamsOptsStruct struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a QueryParamsOptsStruct struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v QueryParamsOptsStruct +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *QueryParamsOptsStruct) FromWire(w wire.Value) error { + var err error + + nameIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Name, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + nameIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserUUID = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.AuthUUID = &x + if err != nil { + return err + } + + } + case 4: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.AuthUUID2 = &x + if err != nil { + return err + } + + } + } + } + + if !nameIsSet { + return errors.New("field Name of QueryParamsOptsStruct is required") + } + + return nil +} + +// String returns a readable string representation of a QueryParamsOptsStruct +// struct. +func (v *QueryParamsOptsStruct) String() string { + if v == nil { + return "" + } + + var fields [4]string + i := 0 + fields[i] = fmt.Sprintf("Name: %v", v.Name) + i++ + if v.UserUUID != nil { + fields[i] = fmt.Sprintf("UserUUID: %v", *(v.UserUUID)) + i++ + } + if v.AuthUUID != nil { + fields[i] = fmt.Sprintf("AuthUUID: %v", *(v.AuthUUID)) + i++ + } + if v.AuthUUID2 != nil { + fields[i] = fmt.Sprintf("AuthUUID2: %v", *(v.AuthUUID2)) + i++ + } + + return fmt.Sprintf("QueryParamsOptsStruct{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this QueryParamsOptsStruct match the +// provided QueryParamsOptsStruct. +// +// This function performs a deep comparison. +func (v *QueryParamsOptsStruct) Equals(rhs *QueryParamsOptsStruct) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Name == rhs.Name) { + return false + } + if !_String_EqualsPtr(v.UserUUID, rhs.UserUUID) { + return false + } + if !_String_EqualsPtr(v.AuthUUID, rhs.AuthUUID) { + return false + } + if !_String_EqualsPtr(v.AuthUUID2, rhs.AuthUUID2) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of QueryParamsOptsStruct. +func (v *QueryParamsOptsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("name", v.Name) + if v.UserUUID != nil { + enc.AddString("userUUID", *v.UserUUID) + } + if v.AuthUUID != nil { + enc.AddString("authUUID", *v.AuthUUID) + } + if v.AuthUUID2 != nil { + enc.AddString("authUUID2", *v.AuthUUID2) + } + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *QueryParamsOptsStruct) GetName() (o string) { + if v != nil { + o = v.Name + } + return +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *QueryParamsOptsStruct) GetUserUUID() (o string) { + if v != nil && v.UserUUID != nil { + return *v.UserUUID + } + + return +} + +// IsSetUserUUID returns true if UserUUID is not nil. +func (v *QueryParamsOptsStruct) IsSetUserUUID() bool { + return v != nil && v.UserUUID != nil +} + +// GetAuthUUID returns the value of AuthUUID if it is set or its +// zero value if it is unset. +func (v *QueryParamsOptsStruct) GetAuthUUID() (o string) { + if v != nil && v.AuthUUID != nil { + return *v.AuthUUID + } + + return +} + +// IsSetAuthUUID returns true if AuthUUID is not nil. +func (v *QueryParamsOptsStruct) IsSetAuthUUID() bool { + return v != nil && v.AuthUUID != nil +} + +// GetAuthUUID2 returns the value of AuthUUID2 if it is set or its +// zero value if it is unset. +func (v *QueryParamsOptsStruct) GetAuthUUID2() (o string) { + if v != nil && v.AuthUUID2 != nil { + return *v.AuthUUID2 + } + + return +} + +// IsSetAuthUUID2 returns true if AuthUUID2 is not nil. +func (v *QueryParamsOptsStruct) IsSetAuthUUID2() bool { + return v != nil && v.AuthUUID2 != nil +} + +type QueryParamsStruct struct { + Name string `json:"name,required"` + UserUUID *string `json:"userUUID,omitempty"` + AuthUUID *string `json:"authUUID,omitempty"` + AuthUUID2 *string `json:"authUUID2,omitempty"` + Foo []string `json:"foo,required"` +} + +// ToWire translates a QueryParamsStruct struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *QueryParamsStruct) ToWire() (wire.Value, error) { + var ( + fields [5]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Name), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.UserUUID != nil { + w, err = wire.NewValueString(*(v.UserUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.AuthUUID != nil { + w, err = wire.NewValueString(*(v.AuthUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + if v.AuthUUID2 != nil { + w, err = wire.NewValueString(*(v.AuthUUID2)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + } + if v.Foo == nil { + return w, errors.New("field Foo of QueryParamsStruct is required") + } + w, err = wire.NewValueList(_List_String_ValueList(v.Foo)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 5, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a QueryParamsStruct struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a QueryParamsStruct struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v QueryParamsStruct +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *QueryParamsStruct) FromWire(w wire.Value) error { + var err error + + nameIsSet := false + + fooIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Name, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + nameIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserUUID = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.AuthUUID = &x + if err != nil { + return err + } + + } + case 4: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.AuthUUID2 = &x + if err != nil { + return err + } + + } + case 5: + if field.Value.Type() == wire.TList { + v.Foo, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + fooIsSet = true + } + } + } + + if !nameIsSet { + return errors.New("field Name of QueryParamsStruct is required") + } + + if !fooIsSet { + return errors.New("field Foo of QueryParamsStruct is required") + } + + return nil +} + +// String returns a readable string representation of a QueryParamsStruct +// struct. +func (v *QueryParamsStruct) String() string { + if v == nil { + return "" + } + + var fields [5]string + i := 0 + fields[i] = fmt.Sprintf("Name: %v", v.Name) + i++ + if v.UserUUID != nil { + fields[i] = fmt.Sprintf("UserUUID: %v", *(v.UserUUID)) + i++ + } + if v.AuthUUID != nil { + fields[i] = fmt.Sprintf("AuthUUID: %v", *(v.AuthUUID)) + i++ + } + if v.AuthUUID2 != nil { + fields[i] = fmt.Sprintf("AuthUUID2: %v", *(v.AuthUUID2)) + i++ + } + fields[i] = fmt.Sprintf("Foo: %v", v.Foo) + i++ + + return fmt.Sprintf("QueryParamsStruct{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this QueryParamsStruct match the +// provided QueryParamsStruct. +// +// This function performs a deep comparison. +func (v *QueryParamsStruct) Equals(rhs *QueryParamsStruct) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Name == rhs.Name) { + return false + } + if !_String_EqualsPtr(v.UserUUID, rhs.UserUUID) { + return false + } + if !_String_EqualsPtr(v.AuthUUID, rhs.AuthUUID) { + return false + } + if !_String_EqualsPtr(v.AuthUUID2, rhs.AuthUUID2) { + return false + } + if !_List_String_Equals(v.Foo, rhs.Foo) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of QueryParamsStruct. +func (v *QueryParamsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("name", v.Name) + if v.UserUUID != nil { + enc.AddString("userUUID", *v.UserUUID) + } + if v.AuthUUID != nil { + enc.AddString("authUUID", *v.AuthUUID) + } + if v.AuthUUID2 != nil { + enc.AddString("authUUID2", *v.AuthUUID2) + } + err = multierr.Append(err, enc.AddArray("foo", (_List_String_Zapper)(v.Foo))) + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *QueryParamsStruct) GetName() (o string) { + if v != nil { + o = v.Name + } + return +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *QueryParamsStruct) GetUserUUID() (o string) { + if v != nil && v.UserUUID != nil { + return *v.UserUUID + } + + return +} + +// IsSetUserUUID returns true if UserUUID is not nil. +func (v *QueryParamsStruct) IsSetUserUUID() bool { + return v != nil && v.UserUUID != nil +} + +// GetAuthUUID returns the value of AuthUUID if it is set or its +// zero value if it is unset. +func (v *QueryParamsStruct) GetAuthUUID() (o string) { + if v != nil && v.AuthUUID != nil { + return *v.AuthUUID + } + + return +} + +// IsSetAuthUUID returns true if AuthUUID is not nil. +func (v *QueryParamsStruct) IsSetAuthUUID() bool { + return v != nil && v.AuthUUID != nil +} + +// GetAuthUUID2 returns the value of AuthUUID2 if it is set or its +// zero value if it is unset. +func (v *QueryParamsStruct) GetAuthUUID2() (o string) { + if v != nil && v.AuthUUID2 != nil { + return *v.AuthUUID2 + } + + return +} + +// IsSetAuthUUID2 returns true if AuthUUID2 is not nil. +func (v *QueryParamsStruct) IsSetAuthUUID2() bool { + return v != nil && v.AuthUUID2 != nil +} + +// GetFoo returns the value of Foo if it is set or its +// zero value if it is unset. +func (v *QueryParamsStruct) GetFoo() (o []string) { + if v != nil { + o = v.Foo + } + return +} + +// IsSetFoo returns true if Foo is not nil. +func (v *QueryParamsStruct) IsSetFoo() bool { + return v != nil && v.Foo != nil +} + +type RequestWithDuplicateType struct { + Request1 *BarRequest `json:"request1,omitempty"` + Request2 *BarRequest `json:"request2,omitempty"` +} + +// ToWire translates a RequestWithDuplicateType struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *RequestWithDuplicateType) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request1 != nil { + w, err = v.Request1.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + if v.Request2 != nil { + w, err = v.Request2.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _BarRequest_Read(w wire.Value) (*BarRequest, error) { + var v BarRequest + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a RequestWithDuplicateType struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a RequestWithDuplicateType struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v RequestWithDuplicateType +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *RequestWithDuplicateType) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request1, err = _BarRequest_Read(field.Value) + if err != nil { + return err + } + + } + case 2: + if field.Value.Type() == wire.TStruct { + v.Request2, err = _BarRequest_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a RequestWithDuplicateType +// struct. +func (v *RequestWithDuplicateType) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Request1 != nil { + fields[i] = fmt.Sprintf("Request1: %v", v.Request1) + i++ + } + if v.Request2 != nil { + fields[i] = fmt.Sprintf("Request2: %v", v.Request2) + i++ + } + + return fmt.Sprintf("RequestWithDuplicateType{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this RequestWithDuplicateType match the +// provided RequestWithDuplicateType. +// +// This function performs a deep comparison. +func (v *RequestWithDuplicateType) Equals(rhs *RequestWithDuplicateType) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Request1 == nil && rhs.Request1 == nil) || (v.Request1 != nil && rhs.Request1 != nil && v.Request1.Equals(rhs.Request1))) { + return false + } + if !((v.Request2 == nil && rhs.Request2 == nil) || (v.Request2 != nil && rhs.Request2 != nil && v.Request2.Equals(rhs.Request2))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of RequestWithDuplicateType. +func (v *RequestWithDuplicateType) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Request1 != nil { + err = multierr.Append(err, enc.AddObject("request1", v.Request1)) + } + if v.Request2 != nil { + err = multierr.Append(err, enc.AddObject("request2", v.Request2)) + } + return err +} + +// GetRequest1 returns the value of Request1 if it is set or its +// zero value if it is unset. +func (v *RequestWithDuplicateType) GetRequest1() (o *BarRequest) { + if v != nil && v.Request1 != nil { + return v.Request1 + } + + return +} + +// IsSetRequest1 returns true if Request1 is not nil. +func (v *RequestWithDuplicateType) IsSetRequest1() bool { + return v != nil && v.Request1 != nil +} + +// GetRequest2 returns the value of Request2 if it is set or its +// zero value if it is unset. +func (v *RequestWithDuplicateType) GetRequest2() (o *BarRequest) { + if v != nil && v.Request2 != nil { + return v.Request2 + } + + return +} + +// IsSetRequest2 returns true if Request2 is not nil. +func (v *RequestWithDuplicateType) IsSetRequest2() bool { + return v != nil && v.Request2 != nil +} + +type StringList []string + +// ToWire translates StringList into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +func (v StringList) ToWire() (wire.Value, error) { + x := ([]string)(v) + return wire.NewValueList(_List_String_ValueList(x)), error(nil) +} + +// String returns a readable string representation of StringList. +func (v StringList) String() string { + x := ([]string)(v) + return fmt.Sprint(x) +} + +// FromWire deserializes StringList from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +func (v *StringList) FromWire(w wire.Value) error { + x, err := _List_String_Read(w.GetList()) + *v = (StringList)(x) + return err +} + +// Equals returns true if this StringList is equal to the provided +// StringList. +func (lhs StringList) Equals(rhs StringList) bool { + return _List_String_Equals(([]string)(lhs), ([]string)(rhs)) +} + +func (v StringList) MarshalLogArray(enc zapcore.ArrayEncoder) error { + return ((_List_String_Zapper)(([]string)(v))).MarshalLogArray(enc) +} + +type Timestamp int64 + +// TimestampPtr returns a pointer to a Timestamp +func (v Timestamp) Ptr() *Timestamp { + return &v +} + +// ToWire translates Timestamp into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +func (v Timestamp) ToWire() (wire.Value, error) { + x := (int64)(v) + return wire.NewValueI64(x), error(nil) +} + +// String returns a readable string representation of Timestamp. +func (v Timestamp) String() string { + x := (int64)(v) + return fmt.Sprint(x) +} + +// FromWire deserializes Timestamp from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +func (v *Timestamp) FromWire(w wire.Value) error { + x, err := w.GetI64(), error(nil) + *v = (Timestamp)(x) + return err +} + +// Equals returns true if this Timestamp is equal to the provided +// Timestamp. +func (lhs Timestamp) Equals(rhs Timestamp) bool { + return ((int64)(lhs) == (int64)(rhs)) +} + +type UUID string + +// UUIDPtr returns a pointer to a UUID +func (v UUID) Ptr() *UUID { + return &v +} + +// ToWire translates UUID into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +func (v UUID) ToWire() (wire.Value, error) { + x := (string)(v) + return wire.NewValueString(x), error(nil) +} + +// String returns a readable string representation of UUID. +func (v UUID) String() string { + x := (string)(v) + return fmt.Sprint(x) +} + +// FromWire deserializes UUID from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +func (v *UUID) FromWire(w wire.Value) error { + x, err := w.GetString(), error(nil) + *v = (UUID)(x) + return err +} + +// Equals returns true if this UUID is equal to the provided +// UUID. +func (lhs UUID) Equals(rhs UUID) bool { + return ((string)(lhs) == (string)(rhs)) +} + +type _List_UUID_ValueList []UUID + +func (v _List_UUID_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + w, err := x.ToWire() + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_UUID_ValueList) Size() int { + return len(v) +} + +func (_List_UUID_ValueList) ValueType() wire.Type { + return wire.TBinary +} + +func (_List_UUID_ValueList) Close() {} + +func _List_UUID_Read(l wire.ValueList) ([]UUID, error) { + if l.ValueType() != wire.TBinary { + return nil, nil + } + + o := make([]UUID, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := _UUID_Read(x) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +func _List_UUID_Equals(lhs, rhs []UUID) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !(lv == rv) { + return false + } + } + + return true +} + +type _List_UUID_Zapper []UUID + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_UUID_Zapper. +func (l _List_UUID_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + enc.AppendString((string)(v)) + } + return err +} + +type UUIDList []UUID + +// ToWire translates UUIDList into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +func (v UUIDList) ToWire() (wire.Value, error) { + x := ([]UUID)(v) + return wire.NewValueList(_List_UUID_ValueList(x)), error(nil) +} + +// String returns a readable string representation of UUIDList. +func (v UUIDList) String() string { + x := ([]UUID)(v) + return fmt.Sprint(x) +} + +// FromWire deserializes UUIDList from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +func (v *UUIDList) FromWire(w wire.Value) error { + x, err := _List_UUID_Read(w.GetList()) + *v = (UUIDList)(x) + return err +} + +// Equals returns true if this UUIDList is equal to the provided +// UUIDList. +func (lhs UUIDList) Equals(rhs UUIDList) bool { + return _List_UUID_Equals(([]UUID)(lhs), ([]UUID)(rhs)) +} + +func (v UUIDList) MarshalLogArray(enc zapcore.ArrayEncoder) error { + return ((_List_UUID_Zapper)(([]UUID)(v))).MarshalLogArray(enc) +} + +// Bar_ArgNotStruct_Args represents the arguments for the Bar.argNotStruct function. +// +// The arguments for argNotStruct are sent and received over the wire as this struct. +type Bar_ArgNotStruct_Args struct { + Request string `json:"request,required"` +} + +// ToWire translates a Bar_ArgNotStruct_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgNotStruct_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Request), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgNotStruct_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgNotStruct_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgNotStruct_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgNotStruct_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Request, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + requestIsSet = true + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_ArgNotStruct_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgNotStruct_Args +// struct. +func (v *Bar_ArgNotStruct_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + + return fmt.Sprintf("Bar_ArgNotStruct_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgNotStruct_Args match the +// provided Bar_ArgNotStruct_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgNotStruct_Args) Equals(rhs *Bar_ArgNotStruct_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Request == rhs.Request) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgNotStruct_Args. +func (v *Bar_ArgNotStruct_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("request", v.Request) + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_ArgNotStruct_Args) GetRequest() (o string) { + if v != nil { + o = v.Request + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argNotStruct" for this struct. +func (v *Bar_ArgNotStruct_Args) MethodName() string { + return "argNotStruct" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgNotStruct_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgNotStruct_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argNotStruct +// function. +var Bar_ArgNotStruct_Helper = struct { + // Args accepts the parameters of argNotStruct in-order and returns + // the arguments struct for the function. + Args func( + request string, + ) *Bar_ArgNotStruct_Args + + // IsException returns true if the given error can be thrown + // by argNotStruct. + // + // An error can be thrown by argNotStruct only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argNotStruct + // given the error returned by it. The provided error may + // be nil if argNotStruct did not fail. + // + // This allows mapping errors returned by argNotStruct into a + // serializable result struct. WrapResponse returns a + // non-nil error if the provided error cannot be thrown by + // argNotStruct + // + // err := argNotStruct(args) + // result, err := Bar_ArgNotStruct_Helper.WrapResponse(err) + // if err != nil { + // return fmt.Errorf("unexpected error from argNotStruct: %v", err) + // } + // serialize(result) + WrapResponse func(error) (*Bar_ArgNotStruct_Result, error) + + // UnwrapResponse takes the result struct for argNotStruct + // and returns the erorr returned by it (if any). + // + // The error is non-nil only if argNotStruct threw an + // exception. + // + // result := deserialize(bytes) + // err := Bar_ArgNotStruct_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgNotStruct_Result) error +}{} + +func init() { + Bar_ArgNotStruct_Helper.Args = func( + request string, + ) *Bar_ArgNotStruct_Args { + return &Bar_ArgNotStruct_Args{ + Request: request, + } + } + + Bar_ArgNotStruct_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_ArgNotStruct_Helper.WrapResponse = func(err error) (*Bar_ArgNotStruct_Result, error) { + if err == nil { + return &Bar_ArgNotStruct_Result{}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_ArgNotStruct_Result.BarException") + } + return &Bar_ArgNotStruct_Result{BarException: e}, nil + } + + return nil, err + } + Bar_ArgNotStruct_Helper.UnwrapResponse = func(result *Bar_ArgNotStruct_Result) (err error) { + if result.BarException != nil { + err = result.BarException + return + } + return + } + +} + +// Bar_ArgNotStruct_Result represents the result of a Bar.argNotStruct function call. +// +// The result of a argNotStruct execution is sent and received over the wire as this struct. +type Bar_ArgNotStruct_Result struct { + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_ArgNotStruct_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgNotStruct_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i > 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgNotStruct_Result should have at most one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _BarException_Read(w wire.Value) (*BarException, error) { + var v BarException + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_ArgNotStruct_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgNotStruct_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgNotStruct_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgNotStruct_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.BarException != nil { + count++ + } + if count > 1 { + return fmt.Errorf("Bar_ArgNotStruct_Result should have at most one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgNotStruct_Result +// struct. +func (v *Bar_ArgNotStruct_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_ArgNotStruct_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgNotStruct_Result match the +// provided Bar_ArgNotStruct_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgNotStruct_Result) Equals(rhs *Bar_ArgNotStruct_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgNotStruct_Result. +func (v *Bar_ArgNotStruct_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_ArgNotStruct_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_ArgNotStruct_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argNotStruct" for this struct. +func (v *Bar_ArgNotStruct_Result) MethodName() string { + return "argNotStruct" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgNotStruct_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithHeaders_Args represents the arguments for the Bar.argWithHeaders function. +// +// The arguments for argWithHeaders are sent and received over the wire as this struct. +type Bar_ArgWithHeaders_Args struct { + Name string `json:"-"` + UserUUID *string `json:"-"` + ParamsStruct *OptionalParamsStruct `json:"paramsStruct,omitempty"` +} + +// ToWire translates a Bar_ArgWithHeaders_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithHeaders_Args) ToWire() (wire.Value, error) { + var ( + fields [3]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Name), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.UserUUID != nil { + w, err = wire.NewValueString(*(v.UserUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.ParamsStruct != nil { + w, err = v.ParamsStruct.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _OptionalParamsStruct_Read(w wire.Value) (*OptionalParamsStruct, error) { + var v OptionalParamsStruct + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_ArgWithHeaders_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithHeaders_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithHeaders_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithHeaders_Args) FromWire(w wire.Value) error { + var err error + + nameIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Name, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + nameIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserUUID = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TStruct { + v.ParamsStruct, err = _OptionalParamsStruct_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !nameIsSet { + return errors.New("field Name of Bar_ArgWithHeaders_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithHeaders_Args +// struct. +func (v *Bar_ArgWithHeaders_Args) String() string { + if v == nil { + return "" + } + + var fields [3]string + i := 0 + fields[i] = fmt.Sprintf("Name: %v", v.Name) + i++ + if v.UserUUID != nil { + fields[i] = fmt.Sprintf("UserUUID: %v", *(v.UserUUID)) + i++ + } + if v.ParamsStruct != nil { + fields[i] = fmt.Sprintf("ParamsStruct: %v", v.ParamsStruct) + i++ + } + + return fmt.Sprintf("Bar_ArgWithHeaders_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithHeaders_Args match the +// provided Bar_ArgWithHeaders_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithHeaders_Args) Equals(rhs *Bar_ArgWithHeaders_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Name == rhs.Name) { + return false + } + if !_String_EqualsPtr(v.UserUUID, rhs.UserUUID) { + return false + } + if !((v.ParamsStruct == nil && rhs.ParamsStruct == nil) || (v.ParamsStruct != nil && rhs.ParamsStruct != nil && v.ParamsStruct.Equals(rhs.ParamsStruct))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithHeaders_Args. +func (v *Bar_ArgWithHeaders_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("name", v.Name) + if v.UserUUID != nil { + enc.AddString("userUUID", *v.UserUUID) + } + if v.ParamsStruct != nil { + err = multierr.Append(err, enc.AddObject("paramsStruct", v.ParamsStruct)) + } + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithHeaders_Args) GetName() (o string) { + if v != nil { + o = v.Name + } + return +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithHeaders_Args) GetUserUUID() (o string) { + if v != nil && v.UserUUID != nil { + return *v.UserUUID + } + + return +} + +// IsSetUserUUID returns true if UserUUID is not nil. +func (v *Bar_ArgWithHeaders_Args) IsSetUserUUID() bool { + return v != nil && v.UserUUID != nil +} + +// GetParamsStruct returns the value of ParamsStruct if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithHeaders_Args) GetParamsStruct() (o *OptionalParamsStruct) { + if v != nil && v.ParamsStruct != nil { + return v.ParamsStruct + } + + return +} + +// IsSetParamsStruct returns true if ParamsStruct is not nil. +func (v *Bar_ArgWithHeaders_Args) IsSetParamsStruct() bool { + return v != nil && v.ParamsStruct != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithHeaders" for this struct. +func (v *Bar_ArgWithHeaders_Args) MethodName() string { + return "argWithHeaders" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithHeaders_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithHeaders_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithHeaders +// function. +var Bar_ArgWithHeaders_Helper = struct { + // Args accepts the parameters of argWithHeaders in-order and returns + // the arguments struct for the function. + Args func( + name string, + userUUID *string, + paramsStruct *OptionalParamsStruct, + ) *Bar_ArgWithHeaders_Args + + // IsException returns true if the given error can be thrown + // by argWithHeaders. + // + // An error can be thrown by argWithHeaders only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithHeaders + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithHeaders into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithHeaders + // + // value, err := argWithHeaders(args) + // result, err := Bar_ArgWithHeaders_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithHeaders: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithHeaders_Result, error) + + // UnwrapResponse takes the result struct for argWithHeaders + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithHeaders threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithHeaders_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithHeaders_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithHeaders_Helper.Args = func( + name string, + userUUID *string, + paramsStruct *OptionalParamsStruct, + ) *Bar_ArgWithHeaders_Args { + return &Bar_ArgWithHeaders_Args{ + Name: name, + UserUUID: userUUID, + ParamsStruct: paramsStruct, + } + } + + Bar_ArgWithHeaders_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithHeaders_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithHeaders_Result, error) { + if err == nil { + return &Bar_ArgWithHeaders_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithHeaders_Helper.UnwrapResponse = func(result *Bar_ArgWithHeaders_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithHeaders_Result represents the result of a Bar.argWithHeaders function call. +// +// The result of a argWithHeaders execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithHeaders_Result struct { + // Value returned by argWithHeaders after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithHeaders_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithHeaders_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithHeaders_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithHeaders_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithHeaders_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithHeaders_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithHeaders_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithHeaders_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithHeaders_Result +// struct. +func (v *Bar_ArgWithHeaders_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithHeaders_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithHeaders_Result match the +// provided Bar_ArgWithHeaders_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithHeaders_Result) Equals(rhs *Bar_ArgWithHeaders_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithHeaders_Result. +func (v *Bar_ArgWithHeaders_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithHeaders_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithHeaders_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithHeaders" for this struct. +func (v *Bar_ArgWithHeaders_Result) MethodName() string { + return "argWithHeaders" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithHeaders_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithManyQueryParams_Args represents the arguments for the Bar.argWithManyQueryParams function. +// +// The arguments for argWithManyQueryParams are sent and received over the wire as this struct. +type Bar_ArgWithManyQueryParams_Args struct { + AStr string `json:"aStr,required"` + AnOptStr *string `json:"anOptStr,omitempty"` + ABool bool `json:"aBool,required"` + AnOptBool *bool `json:"anOptBool,omitempty"` + AInt8 int8 `json:"aInt8,required"` + AnOptInt8 *int8 `json:"anOptInt8,omitempty"` + AInt16 int16 `json:"aInt16,required"` + AnOptInt16 *int16 `json:"anOptInt16,omitempty"` + AInt32 int32 `json:"aInt32,required"` + AnOptInt32 *int32 `json:"anOptInt32,omitempty"` + AInt64 int64 `json:"aInt64,required"` + AnOptInt64 *int64 `json:"anOptInt64,omitempty"` + AFloat64 float64 `json:"aFloat64,required"` + AnOptFloat64 *float64 `json:"anOptFloat64,omitempty"` + AUUID UUID `json:"aUUID,required"` + AnOptUUID *UUID `json:"anOptUUID,omitempty"` + AListUUID []UUID `json:"aListUUID,required"` + AnOptListUUID []UUID `json:"anOptListUUID,omitempty"` + AStringList StringList `json:"aStringList,required"` + AnOptStringList StringList `json:"anOptStringList,omitempty"` + AUUIDList UUIDList `json:"aUUIDList,required"` + AnOptUUIDList UUIDList `json:"anOptUUIDList,omitempty"` + ATs Timestamp `json:"aTs,required"` + AnOptTs *Timestamp `json:"anOptTs,omitempty"` + AReqDemo DemoType `json:"aReqDemo,required"` + AnOptFruit *Fruit `json:"anOptFruit,omitempty"` + AReqFruits []Fruit `json:"aReqFruits,required"` + AnOptDemos []DemoType `json:"anOptDemos,omitempty"` +} + +type _List_Fruit_ValueList []Fruit + +func (v _List_Fruit_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + w, err := x.ToWire() + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_Fruit_ValueList) Size() int { + return len(v) +} + +func (_List_Fruit_ValueList) ValueType() wire.Type { + return wire.TI32 +} + +func (_List_Fruit_ValueList) Close() {} + +type _List_DemoType_ValueList []DemoType + +func (v _List_DemoType_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + w, err := x.ToWire() + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_DemoType_ValueList) Size() int { + return len(v) +} + +func (_List_DemoType_ValueList) ValueType() wire.Type { + return wire.TI32 +} + +func (_List_DemoType_ValueList) Close() {} + +// ToWire translates a Bar_ArgWithManyQueryParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithManyQueryParams_Args) ToWire() (wire.Value, error) { + var ( + fields [28]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.AStr), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.AnOptStr != nil { + w, err = wire.NewValueString(*(v.AnOptStr)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + w, err = wire.NewValueBool(v.ABool), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + if v.AnOptBool != nil { + w, err = wire.NewValueBool(*(v.AnOptBool)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + } + + w, err = wire.NewValueI8(v.AInt8), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 5, Value: w} + i++ + if v.AnOptInt8 != nil { + w, err = wire.NewValueI8(*(v.AnOptInt8)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 6, Value: w} + i++ + } + + w, err = wire.NewValueI16(v.AInt16), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 7, Value: w} + i++ + if v.AnOptInt16 != nil { + w, err = wire.NewValueI16(*(v.AnOptInt16)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 8, Value: w} + i++ + } + + w, err = wire.NewValueI32(v.AInt32), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 9, Value: w} + i++ + if v.AnOptInt32 != nil { + w, err = wire.NewValueI32(*(v.AnOptInt32)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 10, Value: w} + i++ + } + + w, err = wire.NewValueI64(v.AInt64), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 11, Value: w} + i++ + if v.AnOptInt64 != nil { + w, err = wire.NewValueI64(*(v.AnOptInt64)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 12, Value: w} + i++ + } + + w, err = wire.NewValueDouble(v.AFloat64), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 13, Value: w} + i++ + if v.AnOptFloat64 != nil { + w, err = wire.NewValueDouble(*(v.AnOptFloat64)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 14, Value: w} + i++ + } + + w, err = v.AUUID.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 15, Value: w} + i++ + if v.AnOptUUID != nil { + w, err = v.AnOptUUID.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 16, Value: w} + i++ + } + if v.AListUUID == nil { + return w, errors.New("field AListUUID of Bar_ArgWithManyQueryParams_Args is required") + } + w, err = wire.NewValueList(_List_UUID_ValueList(v.AListUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 17, Value: w} + i++ + if v.AnOptListUUID != nil { + w, err = wire.NewValueList(_List_UUID_ValueList(v.AnOptListUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 18, Value: w} + i++ + } + if v.AStringList == nil { + return w, errors.New("field AStringList of Bar_ArgWithManyQueryParams_Args is required") + } + w, err = v.AStringList.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 19, Value: w} + i++ + if v.AnOptStringList != nil { + w, err = v.AnOptStringList.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 20, Value: w} + i++ + } + if v.AUUIDList == nil { + return w, errors.New("field AUUIDList of Bar_ArgWithManyQueryParams_Args is required") + } + w, err = v.AUUIDList.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 21, Value: w} + i++ + if v.AnOptUUIDList != nil { + w, err = v.AnOptUUIDList.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 22, Value: w} + i++ + } + + w, err = v.ATs.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 23, Value: w} + i++ + if v.AnOptTs != nil { + w, err = v.AnOptTs.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 24, Value: w} + i++ + } + + w, err = v.AReqDemo.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 25, Value: w} + i++ + if v.AnOptFruit != nil { + w, err = v.AnOptFruit.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 26, Value: w} + i++ + } + if v.AReqFruits == nil { + return w, errors.New("field AReqFruits of Bar_ArgWithManyQueryParams_Args is required") + } + w, err = wire.NewValueList(_List_Fruit_ValueList(v.AReqFruits)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 27, Value: w} + i++ + if v.AnOptDemos != nil { + w, err = wire.NewValueList(_List_DemoType_ValueList(v.AnOptDemos)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 28, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _StringList_Read(w wire.Value) (StringList, error) { + var x StringList + err := x.FromWire(w) + return x, err +} + +func _UUIDList_Read(w wire.Value) (UUIDList, error) { + var x UUIDList + err := x.FromWire(w) + return x, err +} + +func _DemoType_Read(w wire.Value) (DemoType, error) { + var v DemoType + err := v.FromWire(w) + return v, err +} + +func _List_Fruit_Read(l wire.ValueList) ([]Fruit, error) { + if l.ValueType() != wire.TI32 { + return nil, nil + } + + o := make([]Fruit, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := _Fruit_Read(x) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +func _List_DemoType_Read(l wire.ValueList) ([]DemoType, error) { + if l.ValueType() != wire.TI32 { + return nil, nil + } + + o := make([]DemoType, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := _DemoType_Read(x) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +// FromWire deserializes a Bar_ArgWithManyQueryParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithManyQueryParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithManyQueryParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithManyQueryParams_Args) FromWire(w wire.Value) error { + var err error + + aStrIsSet := false + + aBoolIsSet := false + + aInt8IsSet := false + + aInt16IsSet := false + + aInt32IsSet := false + + aInt64IsSet := false + + aFloat64IsSet := false + + aUUIDIsSet := false + + aListUUIDIsSet := false + + aStringListIsSet := false + + aUUIDListIsSet := false + + aTsIsSet := false + + aReqDemoIsSet := false + + aReqFruitsIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.AStr, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + aStrIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.AnOptStr = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TBool { + v.ABool, err = field.Value.GetBool(), error(nil) + if err != nil { + return err + } + aBoolIsSet = true + } + case 4: + if field.Value.Type() == wire.TBool { + var x bool + x, err = field.Value.GetBool(), error(nil) + v.AnOptBool = &x + if err != nil { + return err + } + + } + case 5: + if field.Value.Type() == wire.TI8 { + v.AInt8, err = field.Value.GetI8(), error(nil) + if err != nil { + return err + } + aInt8IsSet = true + } + case 6: + if field.Value.Type() == wire.TI8 { + var x int8 + x, err = field.Value.GetI8(), error(nil) + v.AnOptInt8 = &x + if err != nil { + return err + } + + } + case 7: + if field.Value.Type() == wire.TI16 { + v.AInt16, err = field.Value.GetI16(), error(nil) + if err != nil { + return err + } + aInt16IsSet = true + } + case 8: + if field.Value.Type() == wire.TI16 { + var x int16 + x, err = field.Value.GetI16(), error(nil) + v.AnOptInt16 = &x + if err != nil { + return err + } + + } + case 9: + if field.Value.Type() == wire.TI32 { + v.AInt32, err = field.Value.GetI32(), error(nil) + if err != nil { + return err + } + aInt32IsSet = true + } + case 10: + if field.Value.Type() == wire.TI32 { + var x int32 + x, err = field.Value.GetI32(), error(nil) + v.AnOptInt32 = &x + if err != nil { + return err + } + + } + case 11: + if field.Value.Type() == wire.TI64 { + v.AInt64, err = field.Value.GetI64(), error(nil) + if err != nil { + return err + } + aInt64IsSet = true + } + case 12: + if field.Value.Type() == wire.TI64 { + var x int64 + x, err = field.Value.GetI64(), error(nil) + v.AnOptInt64 = &x + if err != nil { + return err + } + + } + case 13: + if field.Value.Type() == wire.TDouble { + v.AFloat64, err = field.Value.GetDouble(), error(nil) + if err != nil { + return err + } + aFloat64IsSet = true + } + case 14: + if field.Value.Type() == wire.TDouble { + var x float64 + x, err = field.Value.GetDouble(), error(nil) + v.AnOptFloat64 = &x + if err != nil { + return err + } + + } + case 15: + if field.Value.Type() == wire.TBinary { + v.AUUID, err = _UUID_Read(field.Value) + if err != nil { + return err + } + aUUIDIsSet = true + } + case 16: + if field.Value.Type() == wire.TBinary { + var x UUID + x, err = _UUID_Read(field.Value) + v.AnOptUUID = &x + if err != nil { + return err + } + + } + case 17: + if field.Value.Type() == wire.TList { + v.AListUUID, err = _List_UUID_Read(field.Value.GetList()) + if err != nil { + return err + } + aListUUIDIsSet = true + } + case 18: + if field.Value.Type() == wire.TList { + v.AnOptListUUID, err = _List_UUID_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + case 19: + if field.Value.Type() == wire.TList { + v.AStringList, err = _StringList_Read(field.Value) + if err != nil { + return err + } + aStringListIsSet = true + } + case 20: + if field.Value.Type() == wire.TList { + v.AnOptStringList, err = _StringList_Read(field.Value) + if err != nil { + return err + } + + } + case 21: + if field.Value.Type() == wire.TList { + v.AUUIDList, err = _UUIDList_Read(field.Value) + if err != nil { + return err + } + aUUIDListIsSet = true + } + case 22: + if field.Value.Type() == wire.TList { + v.AnOptUUIDList, err = _UUIDList_Read(field.Value) + if err != nil { + return err + } + + } + case 23: + if field.Value.Type() == wire.TI64 { + v.ATs, err = _Timestamp_Read(field.Value) + if err != nil { + return err + } + aTsIsSet = true + } + case 24: + if field.Value.Type() == wire.TI64 { + var x Timestamp + x, err = _Timestamp_Read(field.Value) + v.AnOptTs = &x + if err != nil { + return err + } + + } + case 25: + if field.Value.Type() == wire.TI32 { + v.AReqDemo, err = _DemoType_Read(field.Value) + if err != nil { + return err + } + aReqDemoIsSet = true + } + case 26: + if field.Value.Type() == wire.TI32 { + var x Fruit + x, err = _Fruit_Read(field.Value) + v.AnOptFruit = &x + if err != nil { + return err + } + + } + case 27: + if field.Value.Type() == wire.TList { + v.AReqFruits, err = _List_Fruit_Read(field.Value.GetList()) + if err != nil { + return err + } + aReqFruitsIsSet = true + } + case 28: + if field.Value.Type() == wire.TList { + v.AnOptDemos, err = _List_DemoType_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + } + } + + if !aStrIsSet { + return errors.New("field AStr of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aBoolIsSet { + return errors.New("field ABool of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aInt8IsSet { + return errors.New("field AInt8 of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aInt16IsSet { + return errors.New("field AInt16 of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aInt32IsSet { + return errors.New("field AInt32 of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aInt64IsSet { + return errors.New("field AInt64 of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aFloat64IsSet { + return errors.New("field AFloat64 of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aUUIDIsSet { + return errors.New("field AUUID of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aListUUIDIsSet { + return errors.New("field AListUUID of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aStringListIsSet { + return errors.New("field AStringList of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aUUIDListIsSet { + return errors.New("field AUUIDList of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aTsIsSet { + return errors.New("field ATs of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aReqDemoIsSet { + return errors.New("field AReqDemo of Bar_ArgWithManyQueryParams_Args is required") + } + + if !aReqFruitsIsSet { + return errors.New("field AReqFruits of Bar_ArgWithManyQueryParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithManyQueryParams_Args +// struct. +func (v *Bar_ArgWithManyQueryParams_Args) String() string { + if v == nil { + return "" + } + + var fields [28]string + i := 0 + fields[i] = fmt.Sprintf("AStr: %v", v.AStr) + i++ + if v.AnOptStr != nil { + fields[i] = fmt.Sprintf("AnOptStr: %v", *(v.AnOptStr)) + i++ + } + fields[i] = fmt.Sprintf("ABool: %v", v.ABool) + i++ + if v.AnOptBool != nil { + fields[i] = fmt.Sprintf("AnOptBool: %v", *(v.AnOptBool)) + i++ + } + fields[i] = fmt.Sprintf("AInt8: %v", v.AInt8) + i++ + if v.AnOptInt8 != nil { + fields[i] = fmt.Sprintf("AnOptInt8: %v", *(v.AnOptInt8)) + i++ + } + fields[i] = fmt.Sprintf("AInt16: %v", v.AInt16) + i++ + if v.AnOptInt16 != nil { + fields[i] = fmt.Sprintf("AnOptInt16: %v", *(v.AnOptInt16)) + i++ + } + fields[i] = fmt.Sprintf("AInt32: %v", v.AInt32) + i++ + if v.AnOptInt32 != nil { + fields[i] = fmt.Sprintf("AnOptInt32: %v", *(v.AnOptInt32)) + i++ + } + fields[i] = fmt.Sprintf("AInt64: %v", v.AInt64) + i++ + if v.AnOptInt64 != nil { + fields[i] = fmt.Sprintf("AnOptInt64: %v", *(v.AnOptInt64)) + i++ + } + fields[i] = fmt.Sprintf("AFloat64: %v", v.AFloat64) + i++ + if v.AnOptFloat64 != nil { + fields[i] = fmt.Sprintf("AnOptFloat64: %v", *(v.AnOptFloat64)) + i++ + } + fields[i] = fmt.Sprintf("AUUID: %v", v.AUUID) + i++ + if v.AnOptUUID != nil { + fields[i] = fmt.Sprintf("AnOptUUID: %v", *(v.AnOptUUID)) + i++ + } + fields[i] = fmt.Sprintf("AListUUID: %v", v.AListUUID) + i++ + if v.AnOptListUUID != nil { + fields[i] = fmt.Sprintf("AnOptListUUID: %v", v.AnOptListUUID) + i++ + } + fields[i] = fmt.Sprintf("AStringList: %v", v.AStringList) + i++ + if v.AnOptStringList != nil { + fields[i] = fmt.Sprintf("AnOptStringList: %v", v.AnOptStringList) + i++ + } + fields[i] = fmt.Sprintf("AUUIDList: %v", v.AUUIDList) + i++ + if v.AnOptUUIDList != nil { + fields[i] = fmt.Sprintf("AnOptUUIDList: %v", v.AnOptUUIDList) + i++ + } + fields[i] = fmt.Sprintf("ATs: %v", v.ATs) + i++ + if v.AnOptTs != nil { + fields[i] = fmt.Sprintf("AnOptTs: %v", *(v.AnOptTs)) + i++ + } + fields[i] = fmt.Sprintf("AReqDemo: %v", v.AReqDemo) + i++ + if v.AnOptFruit != nil { + fields[i] = fmt.Sprintf("AnOptFruit: %v", *(v.AnOptFruit)) + i++ + } + fields[i] = fmt.Sprintf("AReqFruits: %v", v.AReqFruits) + i++ + if v.AnOptDemos != nil { + fields[i] = fmt.Sprintf("AnOptDemos: %v", v.AnOptDemos) + i++ + } + + return fmt.Sprintf("Bar_ArgWithManyQueryParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Bool_EqualsPtr(lhs, rhs *bool) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Byte_EqualsPtr(lhs, rhs *int8) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _I16_EqualsPtr(lhs, rhs *int16) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _I32_EqualsPtr(lhs, rhs *int32) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _I64_EqualsPtr(lhs, rhs *int64) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Double_EqualsPtr(lhs, rhs *float64) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _UUID_EqualsPtr(lhs, rhs *UUID) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Timestamp_EqualsPtr(lhs, rhs *Timestamp) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Fruit_EqualsPtr(lhs, rhs *Fruit) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return x.Equals(y) + } + return lhs == nil && rhs == nil +} + +func _List_Fruit_Equals(lhs, rhs []Fruit) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !lv.Equals(rv) { + return false + } + } + + return true +} + +func _List_DemoType_Equals(lhs, rhs []DemoType) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !lv.Equals(rv) { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this Bar_ArgWithManyQueryParams_Args match the +// provided Bar_ArgWithManyQueryParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithManyQueryParams_Args) Equals(rhs *Bar_ArgWithManyQueryParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.AStr == rhs.AStr) { + return false + } + if !_String_EqualsPtr(v.AnOptStr, rhs.AnOptStr) { + return false + } + if !(v.ABool == rhs.ABool) { + return false + } + if !_Bool_EqualsPtr(v.AnOptBool, rhs.AnOptBool) { + return false + } + if !(v.AInt8 == rhs.AInt8) { + return false + } + if !_Byte_EqualsPtr(v.AnOptInt8, rhs.AnOptInt8) { + return false + } + if !(v.AInt16 == rhs.AInt16) { + return false + } + if !_I16_EqualsPtr(v.AnOptInt16, rhs.AnOptInt16) { + return false + } + if !(v.AInt32 == rhs.AInt32) { + return false + } + if !_I32_EqualsPtr(v.AnOptInt32, rhs.AnOptInt32) { + return false + } + if !(v.AInt64 == rhs.AInt64) { + return false + } + if !_I64_EqualsPtr(v.AnOptInt64, rhs.AnOptInt64) { + return false + } + if !(v.AFloat64 == rhs.AFloat64) { + return false + } + if !_Double_EqualsPtr(v.AnOptFloat64, rhs.AnOptFloat64) { + return false + } + if !(v.AUUID == rhs.AUUID) { + return false + } + if !_UUID_EqualsPtr(v.AnOptUUID, rhs.AnOptUUID) { + return false + } + if !_List_UUID_Equals(v.AListUUID, rhs.AListUUID) { + return false + } + if !((v.AnOptListUUID == nil && rhs.AnOptListUUID == nil) || (v.AnOptListUUID != nil && rhs.AnOptListUUID != nil && _List_UUID_Equals(v.AnOptListUUID, rhs.AnOptListUUID))) { + return false + } + if !v.AStringList.Equals(rhs.AStringList) { + return false + } + if !((v.AnOptStringList == nil && rhs.AnOptStringList == nil) || (v.AnOptStringList != nil && rhs.AnOptStringList != nil && v.AnOptStringList.Equals(rhs.AnOptStringList))) { + return false + } + if !v.AUUIDList.Equals(rhs.AUUIDList) { + return false + } + if !((v.AnOptUUIDList == nil && rhs.AnOptUUIDList == nil) || (v.AnOptUUIDList != nil && rhs.AnOptUUIDList != nil && v.AnOptUUIDList.Equals(rhs.AnOptUUIDList))) { + return false + } + if !(v.ATs == rhs.ATs) { + return false + } + if !_Timestamp_EqualsPtr(v.AnOptTs, rhs.AnOptTs) { + return false + } + if !v.AReqDemo.Equals(rhs.AReqDemo) { + return false + } + if !_Fruit_EqualsPtr(v.AnOptFruit, rhs.AnOptFruit) { + return false + } + if !_List_Fruit_Equals(v.AReqFruits, rhs.AReqFruits) { + return false + } + if !((v.AnOptDemos == nil && rhs.AnOptDemos == nil) || (v.AnOptDemos != nil && rhs.AnOptDemos != nil && _List_DemoType_Equals(v.AnOptDemos, rhs.AnOptDemos))) { + return false + } + + return true +} + +type _List_Fruit_Zapper []Fruit + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_Fruit_Zapper. +func (l _List_Fruit_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + err = multierr.Append(err, enc.AppendObject(v)) + } + return err +} + +type _List_DemoType_Zapper []DemoType + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_DemoType_Zapper. +func (l _List_DemoType_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + err = multierr.Append(err, enc.AppendObject(v)) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithManyQueryParams_Args. +func (v *Bar_ArgWithManyQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("aStr", v.AStr) + if v.AnOptStr != nil { + enc.AddString("anOptStr", *v.AnOptStr) + } + enc.AddBool("aBool", v.ABool) + if v.AnOptBool != nil { + enc.AddBool("anOptBool", *v.AnOptBool) + } + enc.AddInt8("aInt8", v.AInt8) + if v.AnOptInt8 != nil { + enc.AddInt8("anOptInt8", *v.AnOptInt8) + } + enc.AddInt16("aInt16", v.AInt16) + if v.AnOptInt16 != nil { + enc.AddInt16("anOptInt16", *v.AnOptInt16) + } + enc.AddInt32("aInt32", v.AInt32) + if v.AnOptInt32 != nil { + enc.AddInt32("anOptInt32", *v.AnOptInt32) + } + enc.AddInt64("aInt64", v.AInt64) + if v.AnOptInt64 != nil { + enc.AddInt64("anOptInt64", *v.AnOptInt64) + } + enc.AddFloat64("aFloat64", v.AFloat64) + if v.AnOptFloat64 != nil { + enc.AddFloat64("anOptFloat64", *v.AnOptFloat64) + } + enc.AddString("aUUID", (string)(v.AUUID)) + if v.AnOptUUID != nil { + enc.AddString("anOptUUID", (string)(*v.AnOptUUID)) + } + err = multierr.Append(err, enc.AddArray("aListUUID", (_List_UUID_Zapper)(v.AListUUID))) + if v.AnOptListUUID != nil { + err = multierr.Append(err, enc.AddArray("anOptListUUID", (_List_UUID_Zapper)(v.AnOptListUUID))) + } + err = multierr.Append(err, enc.AddArray("aStringList", (_List_String_Zapper)(([]string)(v.AStringList)))) + if v.AnOptStringList != nil { + err = multierr.Append(err, enc.AddArray("anOptStringList", (_List_String_Zapper)(([]string)(v.AnOptStringList)))) + } + err = multierr.Append(err, enc.AddArray("aUUIDList", (_List_UUID_Zapper)(([]UUID)(v.AUUIDList)))) + if v.AnOptUUIDList != nil { + err = multierr.Append(err, enc.AddArray("anOptUUIDList", (_List_UUID_Zapper)(([]UUID)(v.AnOptUUIDList)))) + } + enc.AddInt64("aTs", (int64)(v.ATs)) + if v.AnOptTs != nil { + enc.AddInt64("anOptTs", (int64)(*v.AnOptTs)) + } + err = multierr.Append(err, enc.AddObject("aReqDemo", v.AReqDemo)) + if v.AnOptFruit != nil { + err = multierr.Append(err, enc.AddObject("anOptFruit", *v.AnOptFruit)) + } + err = multierr.Append(err, enc.AddArray("aReqFruits", (_List_Fruit_Zapper)(v.AReqFruits))) + if v.AnOptDemos != nil { + err = multierr.Append(err, enc.AddArray("anOptDemos", (_List_DemoType_Zapper)(v.AnOptDemos))) + } + return err +} + +// GetAStr returns the value of AStr if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAStr() (o string) { + if v != nil { + o = v.AStr + } + return +} + +// GetAnOptStr returns the value of AnOptStr if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptStr() (o string) { + if v != nil && v.AnOptStr != nil { + return *v.AnOptStr + } + + return +} + +// IsSetAnOptStr returns true if AnOptStr is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptStr() bool { + return v != nil && v.AnOptStr != nil +} + +// GetABool returns the value of ABool if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetABool() (o bool) { + if v != nil { + o = v.ABool + } + return +} + +// GetAnOptBool returns the value of AnOptBool if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptBool() (o bool) { + if v != nil && v.AnOptBool != nil { + return *v.AnOptBool + } + + return +} + +// IsSetAnOptBool returns true if AnOptBool is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptBool() bool { + return v != nil && v.AnOptBool != nil +} + +// GetAInt8 returns the value of AInt8 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAInt8() (o int8) { + if v != nil { + o = v.AInt8 + } + return +} + +// GetAnOptInt8 returns the value of AnOptInt8 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptInt8() (o int8) { + if v != nil && v.AnOptInt8 != nil { + return *v.AnOptInt8 + } + + return +} + +// IsSetAnOptInt8 returns true if AnOptInt8 is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptInt8() bool { + return v != nil && v.AnOptInt8 != nil +} + +// GetAInt16 returns the value of AInt16 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAInt16() (o int16) { + if v != nil { + o = v.AInt16 + } + return +} + +// GetAnOptInt16 returns the value of AnOptInt16 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptInt16() (o int16) { + if v != nil && v.AnOptInt16 != nil { + return *v.AnOptInt16 + } + + return +} + +// IsSetAnOptInt16 returns true if AnOptInt16 is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptInt16() bool { + return v != nil && v.AnOptInt16 != nil +} + +// GetAInt32 returns the value of AInt32 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAInt32() (o int32) { + if v != nil { + o = v.AInt32 + } + return +} + +// GetAnOptInt32 returns the value of AnOptInt32 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptInt32() (o int32) { + if v != nil && v.AnOptInt32 != nil { + return *v.AnOptInt32 + } + + return +} + +// IsSetAnOptInt32 returns true if AnOptInt32 is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptInt32() bool { + return v != nil && v.AnOptInt32 != nil +} + +// GetAInt64 returns the value of AInt64 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAInt64() (o int64) { + if v != nil { + o = v.AInt64 + } + return +} + +// GetAnOptInt64 returns the value of AnOptInt64 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptInt64() (o int64) { + if v != nil && v.AnOptInt64 != nil { + return *v.AnOptInt64 + } + + return +} + +// IsSetAnOptInt64 returns true if AnOptInt64 is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptInt64() bool { + return v != nil && v.AnOptInt64 != nil +} + +// GetAFloat64 returns the value of AFloat64 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAFloat64() (o float64) { + if v != nil { + o = v.AFloat64 + } + return +} + +// GetAnOptFloat64 returns the value of AnOptFloat64 if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptFloat64() (o float64) { + if v != nil && v.AnOptFloat64 != nil { + return *v.AnOptFloat64 + } + + return +} + +// IsSetAnOptFloat64 returns true if AnOptFloat64 is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptFloat64() bool { + return v != nil && v.AnOptFloat64 != nil +} + +// GetAUUID returns the value of AUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAUUID() (o UUID) { + if v != nil { + o = v.AUUID + } + return +} + +// GetAnOptUUID returns the value of AnOptUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptUUID() (o UUID) { + if v != nil && v.AnOptUUID != nil { + return *v.AnOptUUID + } + + return +} + +// IsSetAnOptUUID returns true if AnOptUUID is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptUUID() bool { + return v != nil && v.AnOptUUID != nil +} + +// GetAListUUID returns the value of AListUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAListUUID() (o []UUID) { + if v != nil { + o = v.AListUUID + } + return +} + +// IsSetAListUUID returns true if AListUUID is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAListUUID() bool { + return v != nil && v.AListUUID != nil +} + +// GetAnOptListUUID returns the value of AnOptListUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptListUUID() (o []UUID) { + if v != nil && v.AnOptListUUID != nil { + return v.AnOptListUUID + } + + return +} + +// IsSetAnOptListUUID returns true if AnOptListUUID is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptListUUID() bool { + return v != nil && v.AnOptListUUID != nil +} + +// GetAStringList returns the value of AStringList if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAStringList() (o StringList) { + if v != nil { + o = v.AStringList + } + return +} + +// IsSetAStringList returns true if AStringList is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAStringList() bool { + return v != nil && v.AStringList != nil +} + +// GetAnOptStringList returns the value of AnOptStringList if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptStringList() (o StringList) { + if v != nil && v.AnOptStringList != nil { + return v.AnOptStringList + } + + return +} + +// IsSetAnOptStringList returns true if AnOptStringList is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptStringList() bool { + return v != nil && v.AnOptStringList != nil +} + +// GetAUUIDList returns the value of AUUIDList if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAUUIDList() (o UUIDList) { + if v != nil { + o = v.AUUIDList + } + return +} + +// IsSetAUUIDList returns true if AUUIDList is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAUUIDList() bool { + return v != nil && v.AUUIDList != nil +} + +// GetAnOptUUIDList returns the value of AnOptUUIDList if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptUUIDList() (o UUIDList) { + if v != nil && v.AnOptUUIDList != nil { + return v.AnOptUUIDList + } + + return +} + +// IsSetAnOptUUIDList returns true if AnOptUUIDList is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptUUIDList() bool { + return v != nil && v.AnOptUUIDList != nil +} + +// GetATs returns the value of ATs if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetATs() (o Timestamp) { + if v != nil { + o = v.ATs + } + return +} + +// GetAnOptTs returns the value of AnOptTs if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptTs() (o Timestamp) { + if v != nil && v.AnOptTs != nil { + return *v.AnOptTs + } + + return +} + +// IsSetAnOptTs returns true if AnOptTs is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptTs() bool { + return v != nil && v.AnOptTs != nil +} + +// GetAReqDemo returns the value of AReqDemo if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAReqDemo() (o DemoType) { + if v != nil { + o = v.AReqDemo + } + return +} + +// GetAnOptFruit returns the value of AnOptFruit if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptFruit() (o Fruit) { + if v != nil && v.AnOptFruit != nil { + return *v.AnOptFruit + } + + return +} + +// IsSetAnOptFruit returns true if AnOptFruit is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptFruit() bool { + return v != nil && v.AnOptFruit != nil +} + +// GetAReqFruits returns the value of AReqFruits if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAReqFruits() (o []Fruit) { + if v != nil { + o = v.AReqFruits + } + return +} + +// IsSetAReqFruits returns true if AReqFruits is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAReqFruits() bool { + return v != nil && v.AReqFruits != nil +} + +// GetAnOptDemos returns the value of AnOptDemos if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Args) GetAnOptDemos() (o []DemoType) { + if v != nil && v.AnOptDemos != nil { + return v.AnOptDemos + } + + return +} + +// IsSetAnOptDemos returns true if AnOptDemos is not nil. +func (v *Bar_ArgWithManyQueryParams_Args) IsSetAnOptDemos() bool { + return v != nil && v.AnOptDemos != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithManyQueryParams" for this struct. +func (v *Bar_ArgWithManyQueryParams_Args) MethodName() string { + return "argWithManyQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithManyQueryParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithManyQueryParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithManyQueryParams +// function. +var Bar_ArgWithManyQueryParams_Helper = struct { + // Args accepts the parameters of argWithManyQueryParams in-order and returns + // the arguments struct for the function. + Args func( + aStr string, + anOptStr *string, + aBool bool, + anOptBool *bool, + aInt8 int8, + anOptInt8 *int8, + aInt16 int16, + anOptInt16 *int16, + aInt32 int32, + anOptInt32 *int32, + aInt64 int64, + anOptInt64 *int64, + aFloat64 float64, + anOptFloat64 *float64, + aUUID UUID, + anOptUUID *UUID, + aListUUID []UUID, + anOptListUUID []UUID, + aStringList StringList, + anOptStringList StringList, + aUUIDList UUIDList, + anOptUUIDList UUIDList, + aTs Timestamp, + anOptTs *Timestamp, + aReqDemo DemoType, + anOptFruit *Fruit, + aReqFruits []Fruit, + anOptDemos []DemoType, + ) *Bar_ArgWithManyQueryParams_Args + + // IsException returns true if the given error can be thrown + // by argWithManyQueryParams. + // + // An error can be thrown by argWithManyQueryParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithManyQueryParams + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithManyQueryParams into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithManyQueryParams + // + // value, err := argWithManyQueryParams(args) + // result, err := Bar_ArgWithManyQueryParams_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithManyQueryParams: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithManyQueryParams_Result, error) + + // UnwrapResponse takes the result struct for argWithManyQueryParams + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithManyQueryParams threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithManyQueryParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithManyQueryParams_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithManyQueryParams_Helper.Args = func( + aStr string, + anOptStr *string, + aBool bool, + anOptBool *bool, + aInt8 int8, + anOptInt8 *int8, + aInt16 int16, + anOptInt16 *int16, + aInt32 int32, + anOptInt32 *int32, + aInt64 int64, + anOptInt64 *int64, + aFloat64 float64, + anOptFloat64 *float64, + aUUID UUID, + anOptUUID *UUID, + aListUUID []UUID, + anOptListUUID []UUID, + aStringList StringList, + anOptStringList StringList, + aUUIDList UUIDList, + anOptUUIDList UUIDList, + aTs Timestamp, + anOptTs *Timestamp, + aReqDemo DemoType, + anOptFruit *Fruit, + aReqFruits []Fruit, + anOptDemos []DemoType, + ) *Bar_ArgWithManyQueryParams_Args { + return &Bar_ArgWithManyQueryParams_Args{ + AStr: aStr, + AnOptStr: anOptStr, + ABool: aBool, + AnOptBool: anOptBool, + AInt8: aInt8, + AnOptInt8: anOptInt8, + AInt16: aInt16, + AnOptInt16: anOptInt16, + AInt32: aInt32, + AnOptInt32: anOptInt32, + AInt64: aInt64, + AnOptInt64: anOptInt64, + AFloat64: aFloat64, + AnOptFloat64: anOptFloat64, + AUUID: aUUID, + AnOptUUID: anOptUUID, + AListUUID: aListUUID, + AnOptListUUID: anOptListUUID, + AStringList: aStringList, + AnOptStringList: anOptStringList, + AUUIDList: aUUIDList, + AnOptUUIDList: anOptUUIDList, + ATs: aTs, + AnOptTs: anOptTs, + AReqDemo: aReqDemo, + AnOptFruit: anOptFruit, + AReqFruits: aReqFruits, + AnOptDemos: anOptDemos, + } + } + + Bar_ArgWithManyQueryParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithManyQueryParams_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithManyQueryParams_Result, error) { + if err == nil { + return &Bar_ArgWithManyQueryParams_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithManyQueryParams_Helper.UnwrapResponse = func(result *Bar_ArgWithManyQueryParams_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithManyQueryParams_Result represents the result of a Bar.argWithManyQueryParams function call. +// +// The result of a argWithManyQueryParams execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithManyQueryParams_Result struct { + // Value returned by argWithManyQueryParams after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithManyQueryParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithManyQueryParams_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithManyQueryParams_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithManyQueryParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithManyQueryParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithManyQueryParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithManyQueryParams_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithManyQueryParams_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithManyQueryParams_Result +// struct. +func (v *Bar_ArgWithManyQueryParams_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithManyQueryParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithManyQueryParams_Result match the +// provided Bar_ArgWithManyQueryParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithManyQueryParams_Result) Equals(rhs *Bar_ArgWithManyQueryParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithManyQueryParams_Result. +func (v *Bar_ArgWithManyQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithManyQueryParams_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithManyQueryParams_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithManyQueryParams" for this struct. +func (v *Bar_ArgWithManyQueryParams_Result) MethodName() string { + return "argWithManyQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithManyQueryParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithNearDupQueryParams_Args represents the arguments for the Bar.argWithNearDupQueryParams function. +// +// The arguments for argWithNearDupQueryParams are sent and received over the wire as this struct. +type Bar_ArgWithNearDupQueryParams_Args struct { + One string `json:"one,required"` + Two *int32 `json:"two,omitempty"` + Three *string `json:"three,omitempty"` + Four *string `json:"four,omitempty"` +} + +// ToWire translates a Bar_ArgWithNearDupQueryParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithNearDupQueryParams_Args) ToWire() (wire.Value, error) { + var ( + fields [4]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.One), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.Two != nil { + w, err = wire.NewValueI32(*(v.Two)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.Three != nil { + w, err = wire.NewValueString(*(v.Three)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + if v.Four != nil { + w, err = wire.NewValueString(*(v.Four)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithNearDupQueryParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithNearDupQueryParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithNearDupQueryParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithNearDupQueryParams_Args) FromWire(w wire.Value) error { + var err error + + oneIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.One, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + oneIsSet = true + } + case 2: + if field.Value.Type() == wire.TI32 { + var x int32 + x, err = field.Value.GetI32(), error(nil) + v.Two = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Three = &x + if err != nil { + return err + } + + } + case 4: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Four = &x + if err != nil { + return err + } + + } + } + } + + if !oneIsSet { + return errors.New("field One of Bar_ArgWithNearDupQueryParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithNearDupQueryParams_Args +// struct. +func (v *Bar_ArgWithNearDupQueryParams_Args) String() string { + if v == nil { + return "" + } + + var fields [4]string + i := 0 + fields[i] = fmt.Sprintf("One: %v", v.One) + i++ + if v.Two != nil { + fields[i] = fmt.Sprintf("Two: %v", *(v.Two)) + i++ + } + if v.Three != nil { + fields[i] = fmt.Sprintf("Three: %v", *(v.Three)) + i++ + } + if v.Four != nil { + fields[i] = fmt.Sprintf("Four: %v", *(v.Four)) + i++ + } + + return fmt.Sprintf("Bar_ArgWithNearDupQueryParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithNearDupQueryParams_Args match the +// provided Bar_ArgWithNearDupQueryParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithNearDupQueryParams_Args) Equals(rhs *Bar_ArgWithNearDupQueryParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.One == rhs.One) { + return false + } + if !_I32_EqualsPtr(v.Two, rhs.Two) { + return false + } + if !_String_EqualsPtr(v.Three, rhs.Three) { + return false + } + if !_String_EqualsPtr(v.Four, rhs.Four) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithNearDupQueryParams_Args. +func (v *Bar_ArgWithNearDupQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("one", v.One) + if v.Two != nil { + enc.AddInt32("two", *v.Two) + } + if v.Three != nil { + enc.AddString("three", *v.Three) + } + if v.Four != nil { + enc.AddString("four", *v.Four) + } + return err +} + +// GetOne returns the value of One if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNearDupQueryParams_Args) GetOne() (o string) { + if v != nil { + o = v.One + } + return +} + +// GetTwo returns the value of Two if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNearDupQueryParams_Args) GetTwo() (o int32) { + if v != nil && v.Two != nil { + return *v.Two + } + + return +} + +// IsSetTwo returns true if Two is not nil. +func (v *Bar_ArgWithNearDupQueryParams_Args) IsSetTwo() bool { + return v != nil && v.Two != nil +} + +// GetThree returns the value of Three if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNearDupQueryParams_Args) GetThree() (o string) { + if v != nil && v.Three != nil { + return *v.Three + } + + return +} + +// IsSetThree returns true if Three is not nil. +func (v *Bar_ArgWithNearDupQueryParams_Args) IsSetThree() bool { + return v != nil && v.Three != nil +} + +// GetFour returns the value of Four if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNearDupQueryParams_Args) GetFour() (o string) { + if v != nil && v.Four != nil { + return *v.Four + } + + return +} + +// IsSetFour returns true if Four is not nil. +func (v *Bar_ArgWithNearDupQueryParams_Args) IsSetFour() bool { + return v != nil && v.Four != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithNearDupQueryParams" for this struct. +func (v *Bar_ArgWithNearDupQueryParams_Args) MethodName() string { + return "argWithNearDupQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithNearDupQueryParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithNearDupQueryParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithNearDupQueryParams +// function. +var Bar_ArgWithNearDupQueryParams_Helper = struct { + // Args accepts the parameters of argWithNearDupQueryParams in-order and returns + // the arguments struct for the function. + Args func( + one string, + two *int32, + three *string, + four *string, + ) *Bar_ArgWithNearDupQueryParams_Args + + // IsException returns true if the given error can be thrown + // by argWithNearDupQueryParams. + // + // An error can be thrown by argWithNearDupQueryParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithNearDupQueryParams + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithNearDupQueryParams into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithNearDupQueryParams + // + // value, err := argWithNearDupQueryParams(args) + // result, err := Bar_ArgWithNearDupQueryParams_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithNearDupQueryParams: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithNearDupQueryParams_Result, error) + + // UnwrapResponse takes the result struct for argWithNearDupQueryParams + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithNearDupQueryParams threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithNearDupQueryParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithNearDupQueryParams_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithNearDupQueryParams_Helper.Args = func( + one string, + two *int32, + three *string, + four *string, + ) *Bar_ArgWithNearDupQueryParams_Args { + return &Bar_ArgWithNearDupQueryParams_Args{ + One: one, + Two: two, + Three: three, + Four: four, + } + } + + Bar_ArgWithNearDupQueryParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithNearDupQueryParams_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithNearDupQueryParams_Result, error) { + if err == nil { + return &Bar_ArgWithNearDupQueryParams_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithNearDupQueryParams_Helper.UnwrapResponse = func(result *Bar_ArgWithNearDupQueryParams_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithNearDupQueryParams_Result represents the result of a Bar.argWithNearDupQueryParams function call. +// +// The result of a argWithNearDupQueryParams execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithNearDupQueryParams_Result struct { + // Value returned by argWithNearDupQueryParams after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithNearDupQueryParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithNearDupQueryParams_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithNearDupQueryParams_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithNearDupQueryParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithNearDupQueryParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithNearDupQueryParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithNearDupQueryParams_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithNearDupQueryParams_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithNearDupQueryParams_Result +// struct. +func (v *Bar_ArgWithNearDupQueryParams_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithNearDupQueryParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithNearDupQueryParams_Result match the +// provided Bar_ArgWithNearDupQueryParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithNearDupQueryParams_Result) Equals(rhs *Bar_ArgWithNearDupQueryParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithNearDupQueryParams_Result. +func (v *Bar_ArgWithNearDupQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNearDupQueryParams_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithNearDupQueryParams_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithNearDupQueryParams" for this struct. +func (v *Bar_ArgWithNearDupQueryParams_Result) MethodName() string { + return "argWithNearDupQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithNearDupQueryParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithNestedQueryParams_Args represents the arguments for the Bar.argWithNestedQueryParams function. +// +// The arguments for argWithNestedQueryParams are sent and received over the wire as this struct. +type Bar_ArgWithNestedQueryParams_Args struct { + Request *QueryParamsStruct `json:"request,required"` + Opt *QueryParamsOptsStruct `json:"opt,omitempty"` +} + +// ToWire translates a Bar_ArgWithNestedQueryParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithNestedQueryParams_Args) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request == nil { + return w, errors.New("field Request of Bar_ArgWithNestedQueryParams_Args is required") + } + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.Opt != nil { + w, err = v.Opt.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _QueryParamsStruct_Read(w wire.Value) (*QueryParamsStruct, error) { + var v QueryParamsStruct + err := v.FromWire(w) + return &v, err +} + +func _QueryParamsOptsStruct_Read(w wire.Value) (*QueryParamsOptsStruct, error) { + var v QueryParamsOptsStruct + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_ArgWithNestedQueryParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithNestedQueryParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithNestedQueryParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithNestedQueryParams_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _QueryParamsStruct_Read(field.Value) + if err != nil { + return err + } + requestIsSet = true + } + case 2: + if field.Value.Type() == wire.TStruct { + v.Opt, err = _QueryParamsOptsStruct_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_ArgWithNestedQueryParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithNestedQueryParams_Args +// struct. +func (v *Bar_ArgWithNestedQueryParams_Args) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + if v.Opt != nil { + fields[i] = fmt.Sprintf("Opt: %v", v.Opt) + i++ + } + + return fmt.Sprintf("Bar_ArgWithNestedQueryParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithNestedQueryParams_Args match the +// provided Bar_ArgWithNestedQueryParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithNestedQueryParams_Args) Equals(rhs *Bar_ArgWithNestedQueryParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !v.Request.Equals(rhs.Request) { + return false + } + if !((v.Opt == nil && rhs.Opt == nil) || (v.Opt != nil && rhs.Opt != nil && v.Opt.Equals(rhs.Opt))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithNestedQueryParams_Args. +func (v *Bar_ArgWithNestedQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("request", v.Request)) + if v.Opt != nil { + err = multierr.Append(err, enc.AddObject("opt", v.Opt)) + } + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNestedQueryParams_Args) GetRequest() (o *QueryParamsStruct) { + if v != nil { + o = v.Request + } + return +} + +// IsSetRequest returns true if Request is not nil. +func (v *Bar_ArgWithNestedQueryParams_Args) IsSetRequest() bool { + return v != nil && v.Request != nil +} + +// GetOpt returns the value of Opt if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNestedQueryParams_Args) GetOpt() (o *QueryParamsOptsStruct) { + if v != nil && v.Opt != nil { + return v.Opt + } + + return +} + +// IsSetOpt returns true if Opt is not nil. +func (v *Bar_ArgWithNestedQueryParams_Args) IsSetOpt() bool { + return v != nil && v.Opt != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithNestedQueryParams" for this struct. +func (v *Bar_ArgWithNestedQueryParams_Args) MethodName() string { + return "argWithNestedQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithNestedQueryParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithNestedQueryParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithNestedQueryParams +// function. +var Bar_ArgWithNestedQueryParams_Helper = struct { + // Args accepts the parameters of argWithNestedQueryParams in-order and returns + // the arguments struct for the function. + Args func( + request *QueryParamsStruct, + opt *QueryParamsOptsStruct, + ) *Bar_ArgWithNestedQueryParams_Args + + // IsException returns true if the given error can be thrown + // by argWithNestedQueryParams. + // + // An error can be thrown by argWithNestedQueryParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithNestedQueryParams + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithNestedQueryParams into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithNestedQueryParams + // + // value, err := argWithNestedQueryParams(args) + // result, err := Bar_ArgWithNestedQueryParams_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithNestedQueryParams: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithNestedQueryParams_Result, error) + + // UnwrapResponse takes the result struct for argWithNestedQueryParams + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithNestedQueryParams threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithNestedQueryParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithNestedQueryParams_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithNestedQueryParams_Helper.Args = func( + request *QueryParamsStruct, + opt *QueryParamsOptsStruct, + ) *Bar_ArgWithNestedQueryParams_Args { + return &Bar_ArgWithNestedQueryParams_Args{ + Request: request, + Opt: opt, + } + } + + Bar_ArgWithNestedQueryParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithNestedQueryParams_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithNestedQueryParams_Result, error) { + if err == nil { + return &Bar_ArgWithNestedQueryParams_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithNestedQueryParams_Helper.UnwrapResponse = func(result *Bar_ArgWithNestedQueryParams_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithNestedQueryParams_Result represents the result of a Bar.argWithNestedQueryParams function call. +// +// The result of a argWithNestedQueryParams execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithNestedQueryParams_Result struct { + // Value returned by argWithNestedQueryParams after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithNestedQueryParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithNestedQueryParams_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithNestedQueryParams_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithNestedQueryParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithNestedQueryParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithNestedQueryParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithNestedQueryParams_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithNestedQueryParams_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithNestedQueryParams_Result +// struct. +func (v *Bar_ArgWithNestedQueryParams_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithNestedQueryParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithNestedQueryParams_Result match the +// provided Bar_ArgWithNestedQueryParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithNestedQueryParams_Result) Equals(rhs *Bar_ArgWithNestedQueryParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithNestedQueryParams_Result. +func (v *Bar_ArgWithNestedQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithNestedQueryParams_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithNestedQueryParams_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithNestedQueryParams" for this struct. +func (v *Bar_ArgWithNestedQueryParams_Result) MethodName() string { + return "argWithNestedQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithNestedQueryParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithParams_Args represents the arguments for the Bar.argWithParams function. +// +// The arguments for argWithParams are sent and received over the wire as this struct. +type Bar_ArgWithParams_Args struct { + UUID string `json:"uuid,required"` + Params *ParamsStruct `json:"params,omitempty"` +} + +// ToWire translates a Bar_ArgWithParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithParams_Args) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.UUID), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.Params != nil { + w, err = v.Params.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _ParamsStruct_Read(w wire.Value) (*ParamsStruct, error) { + var v ParamsStruct + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_ArgWithParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithParams_Args) FromWire(w wire.Value) error { + var err error + + uuidIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.UUID, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + uuidIsSet = true + } + case 2: + if field.Value.Type() == wire.TStruct { + v.Params, err = _ParamsStruct_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !uuidIsSet { + return errors.New("field UUID of Bar_ArgWithParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithParams_Args +// struct. +func (v *Bar_ArgWithParams_Args) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("UUID: %v", v.UUID) + i++ + if v.Params != nil { + fields[i] = fmt.Sprintf("Params: %v", v.Params) + i++ + } + + return fmt.Sprintf("Bar_ArgWithParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithParams_Args match the +// provided Bar_ArgWithParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithParams_Args) Equals(rhs *Bar_ArgWithParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.UUID == rhs.UUID) { + return false + } + if !((v.Params == nil && rhs.Params == nil) || (v.Params != nil && rhs.Params != nil && v.Params.Equals(rhs.Params))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithParams_Args. +func (v *Bar_ArgWithParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("uuid", v.UUID) + if v.Params != nil { + err = multierr.Append(err, enc.AddObject("params", v.Params)) + } + return err +} + +// GetUUID returns the value of UUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParams_Args) GetUUID() (o string) { + if v != nil { + o = v.UUID + } + return +} + +// GetParams returns the value of Params if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParams_Args) GetParams() (o *ParamsStruct) { + if v != nil && v.Params != nil { + return v.Params + } + + return +} + +// IsSetParams returns true if Params is not nil. +func (v *Bar_ArgWithParams_Args) IsSetParams() bool { + return v != nil && v.Params != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithParams" for this struct. +func (v *Bar_ArgWithParams_Args) MethodName() string { + return "argWithParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithParams +// function. +var Bar_ArgWithParams_Helper = struct { + // Args accepts the parameters of argWithParams in-order and returns + // the arguments struct for the function. + Args func( + uuid string, + params *ParamsStruct, + ) *Bar_ArgWithParams_Args + + // IsException returns true if the given error can be thrown + // by argWithParams. + // + // An error can be thrown by argWithParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithParams + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithParams into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithParams + // + // value, err := argWithParams(args) + // result, err := Bar_ArgWithParams_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithParams: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithParams_Result, error) + + // UnwrapResponse takes the result struct for argWithParams + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithParams threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithParams_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithParams_Helper.Args = func( + uuid string, + params *ParamsStruct, + ) *Bar_ArgWithParams_Args { + return &Bar_ArgWithParams_Args{ + UUID: uuid, + Params: params, + } + } + + Bar_ArgWithParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithParams_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithParams_Result, error) { + if err == nil { + return &Bar_ArgWithParams_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithParams_Helper.UnwrapResponse = func(result *Bar_ArgWithParams_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithParams_Result represents the result of a Bar.argWithParams function call. +// +// The result of a argWithParams execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithParams_Result struct { + // Value returned by argWithParams after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithParams_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithParams_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithParams_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithParams_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithParams_Result +// struct. +func (v *Bar_ArgWithParams_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithParams_Result match the +// provided Bar_ArgWithParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithParams_Result) Equals(rhs *Bar_ArgWithParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithParams_Result. +func (v *Bar_ArgWithParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParams_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithParams_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithParams" for this struct. +func (v *Bar_ArgWithParams_Result) MethodName() string { + return "argWithParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithParamsAndDuplicateFields_Args represents the arguments for the Bar.argWithParamsAndDuplicateFields function. +// +// The arguments for argWithParamsAndDuplicateFields are sent and received over the wire as this struct. +type Bar_ArgWithParamsAndDuplicateFields_Args struct { + Request *RequestWithDuplicateType `json:"request,required"` + EntityUUID string `json:"entityUUID,required"` +} + +// ToWire translates a Bar_ArgWithParamsAndDuplicateFields_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request == nil { + return w, errors.New("field Request of Bar_ArgWithParamsAndDuplicateFields_Args is required") + } + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + w, err = wire.NewValueString(v.EntityUUID), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _RequestWithDuplicateType_Read(w wire.Value) (*RequestWithDuplicateType, error) { + var v RequestWithDuplicateType + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_ArgWithParamsAndDuplicateFields_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithParamsAndDuplicateFields_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithParamsAndDuplicateFields_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + entityUUIDIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _RequestWithDuplicateType_Read(field.Value) + if err != nil { + return err + } + requestIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + v.EntityUUID, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + entityUUIDIsSet = true + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_ArgWithParamsAndDuplicateFields_Args is required") + } + + if !entityUUIDIsSet { + return errors.New("field EntityUUID of Bar_ArgWithParamsAndDuplicateFields_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithParamsAndDuplicateFields_Args +// struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + fields[i] = fmt.Sprintf("EntityUUID: %v", v.EntityUUID) + i++ + + return fmt.Sprintf("Bar_ArgWithParamsAndDuplicateFields_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithParamsAndDuplicateFields_Args match the +// provided Bar_ArgWithParamsAndDuplicateFields_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) Equals(rhs *Bar_ArgWithParamsAndDuplicateFields_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !v.Request.Equals(rhs.Request) { + return false + } + if !(v.EntityUUID == rhs.EntityUUID) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithParamsAndDuplicateFields_Args. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("request", v.Request)) + enc.AddString("entityUUID", v.EntityUUID) + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) GetRequest() (o *RequestWithDuplicateType) { + if v != nil { + o = v.Request + } + return +} + +// IsSetRequest returns true if Request is not nil. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) IsSetRequest() bool { + return v != nil && v.Request != nil +} + +// GetEntityUUID returns the value of EntityUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) GetEntityUUID() (o string) { + if v != nil { + o = v.EntityUUID + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithParamsAndDuplicateFields" for this struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) MethodName() string { + return "argWithParamsAndDuplicateFields" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithParamsAndDuplicateFields_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithParamsAndDuplicateFields +// function. +var Bar_ArgWithParamsAndDuplicateFields_Helper = struct { + // Args accepts the parameters of argWithParamsAndDuplicateFields in-order and returns + // the arguments struct for the function. + Args func( + request *RequestWithDuplicateType, + entityUUID string, + ) *Bar_ArgWithParamsAndDuplicateFields_Args + + // IsException returns true if the given error can be thrown + // by argWithParamsAndDuplicateFields. + // + // An error can be thrown by argWithParamsAndDuplicateFields only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithParamsAndDuplicateFields + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithParamsAndDuplicateFields into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithParamsAndDuplicateFields + // + // value, err := argWithParamsAndDuplicateFields(args) + // result, err := Bar_ArgWithParamsAndDuplicateFields_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithParamsAndDuplicateFields: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithParamsAndDuplicateFields_Result, error) + + // UnwrapResponse takes the result struct for argWithParamsAndDuplicateFields + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithParamsAndDuplicateFields threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithParamsAndDuplicateFields_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithParamsAndDuplicateFields_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithParamsAndDuplicateFields_Helper.Args = func( + request *RequestWithDuplicateType, + entityUUID string, + ) *Bar_ArgWithParamsAndDuplicateFields_Args { + return &Bar_ArgWithParamsAndDuplicateFields_Args{ + Request: request, + EntityUUID: entityUUID, + } + } + + Bar_ArgWithParamsAndDuplicateFields_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithParamsAndDuplicateFields_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithParamsAndDuplicateFields_Result, error) { + if err == nil { + return &Bar_ArgWithParamsAndDuplicateFields_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithParamsAndDuplicateFields_Helper.UnwrapResponse = func(result *Bar_ArgWithParamsAndDuplicateFields_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithParamsAndDuplicateFields_Result represents the result of a Bar.argWithParamsAndDuplicateFields function call. +// +// The result of a argWithParamsAndDuplicateFields execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithParamsAndDuplicateFields_Result struct { + // Value returned by argWithParamsAndDuplicateFields after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithParamsAndDuplicateFields_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithParamsAndDuplicateFields_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithParamsAndDuplicateFields_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithParamsAndDuplicateFields_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithParamsAndDuplicateFields_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithParamsAndDuplicateFields_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithParamsAndDuplicateFields_Result +// struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithParamsAndDuplicateFields_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithParamsAndDuplicateFields_Result match the +// provided Bar_ArgWithParamsAndDuplicateFields_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) Equals(rhs *Bar_ArgWithParamsAndDuplicateFields_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithParamsAndDuplicateFields_Result. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithParamsAndDuplicateFields" for this struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) MethodName() string { + return "argWithParamsAndDuplicateFields" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithQueryHeader_Args represents the arguments for the Bar.argWithQueryHeader function. +// +// The arguments for argWithQueryHeader are sent and received over the wire as this struct. +type Bar_ArgWithQueryHeader_Args struct { + UserUUID *string `json:"userUUID,omitempty"` +} + +// ToWire translates a Bar_ArgWithQueryHeader_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithQueryHeader_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.UserUUID != nil { + w, err = wire.NewValueString(*(v.UserUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithQueryHeader_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithQueryHeader_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithQueryHeader_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithQueryHeader_Args) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserUUID = &x + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithQueryHeader_Args +// struct. +func (v *Bar_ArgWithQueryHeader_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.UserUUID != nil { + fields[i] = fmt.Sprintf("UserUUID: %v", *(v.UserUUID)) + i++ + } + + return fmt.Sprintf("Bar_ArgWithQueryHeader_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithQueryHeader_Args match the +// provided Bar_ArgWithQueryHeader_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithQueryHeader_Args) Equals(rhs *Bar_ArgWithQueryHeader_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.UserUUID, rhs.UserUUID) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithQueryHeader_Args. +func (v *Bar_ArgWithQueryHeader_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.UserUUID != nil { + enc.AddString("userUUID", *v.UserUUID) + } + return err +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryHeader_Args) GetUserUUID() (o string) { + if v != nil && v.UserUUID != nil { + return *v.UserUUID + } + + return +} + +// IsSetUserUUID returns true if UserUUID is not nil. +func (v *Bar_ArgWithQueryHeader_Args) IsSetUserUUID() bool { + return v != nil && v.UserUUID != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithQueryHeader" for this struct. +func (v *Bar_ArgWithQueryHeader_Args) MethodName() string { + return "argWithQueryHeader" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithQueryHeader_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithQueryHeader_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithQueryHeader +// function. +var Bar_ArgWithQueryHeader_Helper = struct { + // Args accepts the parameters of argWithQueryHeader in-order and returns + // the arguments struct for the function. + Args func( + userUUID *string, + ) *Bar_ArgWithQueryHeader_Args + + // IsException returns true if the given error can be thrown + // by argWithQueryHeader. + // + // An error can be thrown by argWithQueryHeader only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithQueryHeader + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithQueryHeader into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithQueryHeader + // + // value, err := argWithQueryHeader(args) + // result, err := Bar_ArgWithQueryHeader_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithQueryHeader: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithQueryHeader_Result, error) + + // UnwrapResponse takes the result struct for argWithQueryHeader + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithQueryHeader threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithQueryHeader_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithQueryHeader_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithQueryHeader_Helper.Args = func( + userUUID *string, + ) *Bar_ArgWithQueryHeader_Args { + return &Bar_ArgWithQueryHeader_Args{ + UserUUID: userUUID, + } + } + + Bar_ArgWithQueryHeader_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithQueryHeader_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithQueryHeader_Result, error) { + if err == nil { + return &Bar_ArgWithQueryHeader_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithQueryHeader_Helper.UnwrapResponse = func(result *Bar_ArgWithQueryHeader_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithQueryHeader_Result represents the result of a Bar.argWithQueryHeader function call. +// +// The result of a argWithQueryHeader execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithQueryHeader_Result struct { + // Value returned by argWithQueryHeader after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithQueryHeader_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithQueryHeader_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithQueryHeader_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithQueryHeader_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithQueryHeader_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithQueryHeader_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithQueryHeader_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithQueryHeader_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithQueryHeader_Result +// struct. +func (v *Bar_ArgWithQueryHeader_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithQueryHeader_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithQueryHeader_Result match the +// provided Bar_ArgWithQueryHeader_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithQueryHeader_Result) Equals(rhs *Bar_ArgWithQueryHeader_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithQueryHeader_Result. +func (v *Bar_ArgWithQueryHeader_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryHeader_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithQueryHeader_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithQueryHeader" for this struct. +func (v *Bar_ArgWithQueryHeader_Result) MethodName() string { + return "argWithQueryHeader" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithQueryHeader_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ArgWithQueryParams_Args represents the arguments for the Bar.argWithQueryParams function. +// +// The arguments for argWithQueryParams are sent and received over the wire as this struct. +type Bar_ArgWithQueryParams_Args struct { + Name string `json:"name,required"` + UserUUID *string `json:"userUUID,omitempty"` + Foo []string `json:"foo,omitempty"` + Bar []int8 `json:"bar,required"` +} + +type _List_Byte_ValueList []int8 + +func (v _List_Byte_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + w, err := wire.NewValueI8(x), error(nil) + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_Byte_ValueList) Size() int { + return len(v) +} + +func (_List_Byte_ValueList) ValueType() wire.Type { + return wire.TI8 +} + +func (_List_Byte_ValueList) Close() {} + +// ToWire translates a Bar_ArgWithQueryParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithQueryParams_Args) ToWire() (wire.Value, error) { + var ( + fields [4]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Name), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.UserUUID != nil { + w, err = wire.NewValueString(*(v.UserUUID)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.Foo != nil { + w, err = wire.NewValueList(_List_String_ValueList(v.Foo)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + if v.Bar == nil { + return w, errors.New("field Bar of Bar_ArgWithQueryParams_Args is required") + } + w, err = wire.NewValueList(_List_Byte_ValueList(v.Bar)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _List_Byte_Read(l wire.ValueList) ([]int8, error) { + if l.ValueType() != wire.TI8 { + return nil, nil + } + + o := make([]int8, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := x.GetI8(), error(nil) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +// FromWire deserializes a Bar_ArgWithQueryParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithQueryParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithQueryParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithQueryParams_Args) FromWire(w wire.Value) error { + var err error + + nameIsSet := false + + barIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Name, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + nameIsSet = true + } + case 2: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.UserUUID = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TList { + v.Foo, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + case 4: + if field.Value.Type() == wire.TList { + v.Bar, err = _List_Byte_Read(field.Value.GetList()) + if err != nil { + return err + } + barIsSet = true + } + } + } + + if !nameIsSet { + return errors.New("field Name of Bar_ArgWithQueryParams_Args is required") + } + + if !barIsSet { + return errors.New("field Bar of Bar_ArgWithQueryParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithQueryParams_Args +// struct. +func (v *Bar_ArgWithQueryParams_Args) String() string { + if v == nil { + return "" + } + + var fields [4]string + i := 0 + fields[i] = fmt.Sprintf("Name: %v", v.Name) + i++ + if v.UserUUID != nil { + fields[i] = fmt.Sprintf("UserUUID: %v", *(v.UserUUID)) + i++ + } + if v.Foo != nil { + fields[i] = fmt.Sprintf("Foo: %v", v.Foo) + i++ + } + fields[i] = fmt.Sprintf("Bar: %v", v.Bar) + i++ + + return fmt.Sprintf("Bar_ArgWithQueryParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _List_Byte_Equals(lhs, rhs []int8) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !(lv == rv) { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this Bar_ArgWithQueryParams_Args match the +// provided Bar_ArgWithQueryParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithQueryParams_Args) Equals(rhs *Bar_ArgWithQueryParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Name == rhs.Name) { + return false + } + if !_String_EqualsPtr(v.UserUUID, rhs.UserUUID) { + return false + } + if !((v.Foo == nil && rhs.Foo == nil) || (v.Foo != nil && rhs.Foo != nil && _List_String_Equals(v.Foo, rhs.Foo))) { + return false + } + if !_List_Byte_Equals(v.Bar, rhs.Bar) { + return false + } + + return true +} + +type _List_Byte_Zapper []int8 + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_Byte_Zapper. +func (l _List_Byte_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + enc.AppendInt8(v) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithQueryParams_Args. +func (v *Bar_ArgWithQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("name", v.Name) + if v.UserUUID != nil { + enc.AddString("userUUID", *v.UserUUID) + } + if v.Foo != nil { + err = multierr.Append(err, enc.AddArray("foo", (_List_String_Zapper)(v.Foo))) + } + err = multierr.Append(err, enc.AddArray("bar", (_List_Byte_Zapper)(v.Bar))) + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryParams_Args) GetName() (o string) { + if v != nil { + o = v.Name + } + return +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryParams_Args) GetUserUUID() (o string) { + if v != nil && v.UserUUID != nil { + return *v.UserUUID + } + + return +} + +// IsSetUserUUID returns true if UserUUID is not nil. +func (v *Bar_ArgWithQueryParams_Args) IsSetUserUUID() bool { + return v != nil && v.UserUUID != nil +} + +// GetFoo returns the value of Foo if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryParams_Args) GetFoo() (o []string) { + if v != nil && v.Foo != nil { + return v.Foo + } + + return +} + +// IsSetFoo returns true if Foo is not nil. +func (v *Bar_ArgWithQueryParams_Args) IsSetFoo() bool { + return v != nil && v.Foo != nil +} + +// GetBar returns the value of Bar if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryParams_Args) GetBar() (o []int8) { + if v != nil { + o = v.Bar + } + return +} + +// IsSetBar returns true if Bar is not nil. +func (v *Bar_ArgWithQueryParams_Args) IsSetBar() bool { + return v != nil && v.Bar != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "argWithQueryParams" for this struct. +func (v *Bar_ArgWithQueryParams_Args) MethodName() string { + return "argWithQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ArgWithQueryParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ArgWithQueryParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.argWithQueryParams +// function. +var Bar_ArgWithQueryParams_Helper = struct { + // Args accepts the parameters of argWithQueryParams in-order and returns + // the arguments struct for the function. + Args func( + name string, + userUUID *string, + foo []string, + bar []int8, + ) *Bar_ArgWithQueryParams_Args + + // IsException returns true if the given error can be thrown + // by argWithQueryParams. + // + // An error can be thrown by argWithQueryParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for argWithQueryParams + // given its return value and error. + // + // This allows mapping values and errors returned by + // argWithQueryParams into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by argWithQueryParams + // + // value, err := argWithQueryParams(args) + // result, err := Bar_ArgWithQueryParams_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from argWithQueryParams: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_ArgWithQueryParams_Result, error) + + // UnwrapResponse takes the result struct for argWithQueryParams + // and returns the value or error returned by it. + // + // The error is non-nil only if argWithQueryParams threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ArgWithQueryParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ArgWithQueryParams_Result) (*BarResponse, error) +}{} + +func init() { + Bar_ArgWithQueryParams_Helper.Args = func( + name string, + userUUID *string, + foo []string, + bar []int8, + ) *Bar_ArgWithQueryParams_Args { + return &Bar_ArgWithQueryParams_Args{ + Name: name, + UserUUID: userUUID, + Foo: foo, + Bar: bar, + } + } + + Bar_ArgWithQueryParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_ArgWithQueryParams_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_ArgWithQueryParams_Result, error) { + if err == nil { + return &Bar_ArgWithQueryParams_Result{Success: success}, nil + } + + return nil, err + } + Bar_ArgWithQueryParams_Helper.UnwrapResponse = func(result *Bar_ArgWithQueryParams_Result) (success *BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ArgWithQueryParams_Result represents the result of a Bar.argWithQueryParams function call. +// +// The result of a argWithQueryParams execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ArgWithQueryParams_Result struct { + // Value returned by argWithQueryParams after a successful execution. + Success *BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Bar_ArgWithQueryParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ArgWithQueryParams_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ArgWithQueryParams_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ArgWithQueryParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ArgWithQueryParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ArgWithQueryParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ArgWithQueryParams_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ArgWithQueryParams_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ArgWithQueryParams_Result +// struct. +func (v *Bar_ArgWithQueryParams_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Bar_ArgWithQueryParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ArgWithQueryParams_Result match the +// provided Bar_ArgWithQueryParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_ArgWithQueryParams_Result) Equals(rhs *Bar_ArgWithQueryParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ArgWithQueryParams_Result. +func (v *Bar_ArgWithQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ArgWithQueryParams_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ArgWithQueryParams_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "argWithQueryParams" for this struct. +func (v *Bar_ArgWithQueryParams_Result) MethodName() string { + return "argWithQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ArgWithQueryParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_DeleteFoo_Args represents the arguments for the Bar.deleteFoo function. +// +// The arguments for deleteFoo are sent and received over the wire as this struct. +type Bar_DeleteFoo_Args struct { + UserUUID string `json:"userUUID,required"` +} + +// ToWire translates a Bar_DeleteFoo_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_DeleteFoo_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.UserUUID), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_DeleteFoo_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_DeleteFoo_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_DeleteFoo_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_DeleteFoo_Args) FromWire(w wire.Value) error { + var err error + + userUUIDIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.UserUUID, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + userUUIDIsSet = true + } + } + } + + if !userUUIDIsSet { + return errors.New("field UserUUID of Bar_DeleteFoo_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_DeleteFoo_Args +// struct. +func (v *Bar_DeleteFoo_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("UserUUID: %v", v.UserUUID) + i++ + + return fmt.Sprintf("Bar_DeleteFoo_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_DeleteFoo_Args match the +// provided Bar_DeleteFoo_Args. +// +// This function performs a deep comparison. +func (v *Bar_DeleteFoo_Args) Equals(rhs *Bar_DeleteFoo_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.UserUUID == rhs.UserUUID) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_DeleteFoo_Args. +func (v *Bar_DeleteFoo_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("userUUID", v.UserUUID) + return err +} + +// GetUserUUID returns the value of UserUUID if it is set or its +// zero value if it is unset. +func (v *Bar_DeleteFoo_Args) GetUserUUID() (o string) { + if v != nil { + o = v.UserUUID + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "deleteFoo" for this struct. +func (v *Bar_DeleteFoo_Args) MethodName() string { + return "deleteFoo" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_DeleteFoo_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_DeleteFoo_Helper provides functions that aid in handling the +// parameters and return values of the Bar.deleteFoo +// function. +var Bar_DeleteFoo_Helper = struct { + // Args accepts the parameters of deleteFoo in-order and returns + // the arguments struct for the function. + Args func( + userUUID string, + ) *Bar_DeleteFoo_Args + + // IsException returns true if the given error can be thrown + // by deleteFoo. + // + // An error can be thrown by deleteFoo only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for deleteFoo + // given the error returned by it. The provided error may + // be nil if deleteFoo did not fail. + // + // This allows mapping errors returned by deleteFoo into a + // serializable result struct. WrapResponse returns a + // non-nil error if the provided error cannot be thrown by + // deleteFoo + // + // err := deleteFoo(args) + // result, err := Bar_DeleteFoo_Helper.WrapResponse(err) + // if err != nil { + // return fmt.Errorf("unexpected error from deleteFoo: %v", err) + // } + // serialize(result) + WrapResponse func(error) (*Bar_DeleteFoo_Result, error) + + // UnwrapResponse takes the result struct for deleteFoo + // and returns the erorr returned by it (if any). + // + // The error is non-nil only if deleteFoo threw an + // exception. + // + // result := deserialize(bytes) + // err := Bar_DeleteFoo_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_DeleteFoo_Result) error +}{} + +func init() { + Bar_DeleteFoo_Helper.Args = func( + userUUID string, + ) *Bar_DeleteFoo_Args { + return &Bar_DeleteFoo_Args{ + UserUUID: userUUID, + } + } + + Bar_DeleteFoo_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_DeleteFoo_Helper.WrapResponse = func(err error) (*Bar_DeleteFoo_Result, error) { + if err == nil { + return &Bar_DeleteFoo_Result{}, nil + } + + return nil, err + } + Bar_DeleteFoo_Helper.UnwrapResponse = func(result *Bar_DeleteFoo_Result) (err error) { + return + } + +} + +// Bar_DeleteFoo_Result represents the result of a Bar.deleteFoo function call. +// +// The result of a deleteFoo execution is sent and received over the wire as this struct. +type Bar_DeleteFoo_Result struct { +} + +// ToWire translates a Bar_DeleteFoo_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_DeleteFoo_Result) ToWire() (wire.Value, error) { + var ( + fields [0]wire.Field + i int = 0 + ) + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_DeleteFoo_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_DeleteFoo_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_DeleteFoo_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_DeleteFoo_Result) FromWire(w wire.Value) error { + + for _, field := range w.GetStruct().Fields { + switch field.ID { + } + } + + return nil +} + +// String returns a readable string representation of a Bar_DeleteFoo_Result +// struct. +func (v *Bar_DeleteFoo_Result) String() string { + if v == nil { + return "" + } + + var fields [0]string + i := 0 + + return fmt.Sprintf("Bar_DeleteFoo_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_DeleteFoo_Result match the +// provided Bar_DeleteFoo_Result. +// +// This function performs a deep comparison. +func (v *Bar_DeleteFoo_Result) Equals(rhs *Bar_DeleteFoo_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_DeleteFoo_Result. +func (v *Bar_DeleteFoo_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + return err +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "deleteFoo" for this struct. +func (v *Bar_DeleteFoo_Result) MethodName() string { + return "deleteFoo" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_DeleteFoo_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_DeleteWithQueryParams_Args represents the arguments for the Bar.deleteWithQueryParams function. +// +// The arguments for deleteWithQueryParams are sent and received over the wire as this struct. +type Bar_DeleteWithQueryParams_Args struct { + Filter string `json:"filter,required"` + Count *int32 `json:"count,omitempty"` +} + +// ToWire translates a Bar_DeleteWithQueryParams_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_DeleteWithQueryParams_Args) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Filter), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + if v.Count != nil { + w, err = wire.NewValueI32(*(v.Count)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_DeleteWithQueryParams_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_DeleteWithQueryParams_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_DeleteWithQueryParams_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_DeleteWithQueryParams_Args) FromWire(w wire.Value) error { + var err error + + filterIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 2: + if field.Value.Type() == wire.TBinary { + v.Filter, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + filterIsSet = true + } + case 3: + if field.Value.Type() == wire.TI32 { + var x int32 + x, err = field.Value.GetI32(), error(nil) + v.Count = &x + if err != nil { + return err + } + + } + } + } + + if !filterIsSet { + return errors.New("field Filter of Bar_DeleteWithQueryParams_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_DeleteWithQueryParams_Args +// struct. +func (v *Bar_DeleteWithQueryParams_Args) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Filter: %v", v.Filter) + i++ + if v.Count != nil { + fields[i] = fmt.Sprintf("Count: %v", *(v.Count)) + i++ + } + + return fmt.Sprintf("Bar_DeleteWithQueryParams_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_DeleteWithQueryParams_Args match the +// provided Bar_DeleteWithQueryParams_Args. +// +// This function performs a deep comparison. +func (v *Bar_DeleteWithQueryParams_Args) Equals(rhs *Bar_DeleteWithQueryParams_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Filter == rhs.Filter) { + return false + } + if !_I32_EqualsPtr(v.Count, rhs.Count) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_DeleteWithQueryParams_Args. +func (v *Bar_DeleteWithQueryParams_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("filter", v.Filter) + if v.Count != nil { + enc.AddInt32("count", *v.Count) + } + return err +} + +// GetFilter returns the value of Filter if it is set or its +// zero value if it is unset. +func (v *Bar_DeleteWithQueryParams_Args) GetFilter() (o string) { + if v != nil { + o = v.Filter + } + return +} + +// GetCount returns the value of Count if it is set or its +// zero value if it is unset. +func (v *Bar_DeleteWithQueryParams_Args) GetCount() (o int32) { + if v != nil && v.Count != nil { + return *v.Count + } + + return +} + +// IsSetCount returns true if Count is not nil. +func (v *Bar_DeleteWithQueryParams_Args) IsSetCount() bool { + return v != nil && v.Count != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "deleteWithQueryParams" for this struct. +func (v *Bar_DeleteWithQueryParams_Args) MethodName() string { + return "deleteWithQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_DeleteWithQueryParams_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_DeleteWithQueryParams_Helper provides functions that aid in handling the +// parameters and return values of the Bar.deleteWithQueryParams +// function. +var Bar_DeleteWithQueryParams_Helper = struct { + // Args accepts the parameters of deleteWithQueryParams in-order and returns + // the arguments struct for the function. + Args func( + filter string, + count *int32, + ) *Bar_DeleteWithQueryParams_Args + + // IsException returns true if the given error can be thrown + // by deleteWithQueryParams. + // + // An error can be thrown by deleteWithQueryParams only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for deleteWithQueryParams + // given the error returned by it. The provided error may + // be nil if deleteWithQueryParams did not fail. + // + // This allows mapping errors returned by deleteWithQueryParams into a + // serializable result struct. WrapResponse returns a + // non-nil error if the provided error cannot be thrown by + // deleteWithQueryParams + // + // err := deleteWithQueryParams(args) + // result, err := Bar_DeleteWithQueryParams_Helper.WrapResponse(err) + // if err != nil { + // return fmt.Errorf("unexpected error from deleteWithQueryParams: %v", err) + // } + // serialize(result) + WrapResponse func(error) (*Bar_DeleteWithQueryParams_Result, error) + + // UnwrapResponse takes the result struct for deleteWithQueryParams + // and returns the erorr returned by it (if any). + // + // The error is non-nil only if deleteWithQueryParams threw an + // exception. + // + // result := deserialize(bytes) + // err := Bar_DeleteWithQueryParams_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_DeleteWithQueryParams_Result) error +}{} + +func init() { + Bar_DeleteWithQueryParams_Helper.Args = func( + filter string, + count *int32, + ) *Bar_DeleteWithQueryParams_Args { + return &Bar_DeleteWithQueryParams_Args{ + Filter: filter, + Count: count, + } + } + + Bar_DeleteWithQueryParams_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bar_DeleteWithQueryParams_Helper.WrapResponse = func(err error) (*Bar_DeleteWithQueryParams_Result, error) { + if err == nil { + return &Bar_DeleteWithQueryParams_Result{}, nil + } + + return nil, err + } + Bar_DeleteWithQueryParams_Helper.UnwrapResponse = func(result *Bar_DeleteWithQueryParams_Result) (err error) { + return + } + +} + +// Bar_DeleteWithQueryParams_Result represents the result of a Bar.deleteWithQueryParams function call. +// +// The result of a deleteWithQueryParams execution is sent and received over the wire as this struct. +type Bar_DeleteWithQueryParams_Result struct { +} + +// ToWire translates a Bar_DeleteWithQueryParams_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_DeleteWithQueryParams_Result) ToWire() (wire.Value, error) { + var ( + fields [0]wire.Field + i int = 0 + ) + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_DeleteWithQueryParams_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_DeleteWithQueryParams_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_DeleteWithQueryParams_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_DeleteWithQueryParams_Result) FromWire(w wire.Value) error { + + for _, field := range w.GetStruct().Fields { + switch field.ID { + } + } + + return nil +} + +// String returns a readable string representation of a Bar_DeleteWithQueryParams_Result +// struct. +func (v *Bar_DeleteWithQueryParams_Result) String() string { + if v == nil { + return "" + } + + var fields [0]string + i := 0 + + return fmt.Sprintf("Bar_DeleteWithQueryParams_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_DeleteWithQueryParams_Result match the +// provided Bar_DeleteWithQueryParams_Result. +// +// This function performs a deep comparison. +func (v *Bar_DeleteWithQueryParams_Result) Equals(rhs *Bar_DeleteWithQueryParams_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_DeleteWithQueryParams_Result. +func (v *Bar_DeleteWithQueryParams_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + return err +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "deleteWithQueryParams" for this struct. +func (v *Bar_DeleteWithQueryParams_Result) MethodName() string { + return "deleteWithQueryParams" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_DeleteWithQueryParams_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_HelloWorld_Args represents the arguments for the Bar.helloWorld function. +// +// The arguments for helloWorld are sent and received over the wire as this struct. +type Bar_HelloWorld_Args struct { +} + +// ToWire translates a Bar_HelloWorld_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_HelloWorld_Args) ToWire() (wire.Value, error) { + var ( + fields [0]wire.Field + i int = 0 + ) + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_HelloWorld_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_HelloWorld_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_HelloWorld_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_HelloWorld_Args) FromWire(w wire.Value) error { + + for _, field := range w.GetStruct().Fields { + switch field.ID { + } + } + + return nil +} + +// String returns a readable string representation of a Bar_HelloWorld_Args +// struct. +func (v *Bar_HelloWorld_Args) String() string { + if v == nil { + return "" + } + + var fields [0]string + i := 0 + + return fmt.Sprintf("Bar_HelloWorld_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_HelloWorld_Args match the +// provided Bar_HelloWorld_Args. +// +// This function performs a deep comparison. +func (v *Bar_HelloWorld_Args) Equals(rhs *Bar_HelloWorld_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_HelloWorld_Args. +func (v *Bar_HelloWorld_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + return err +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "helloWorld" for this struct. +func (v *Bar_HelloWorld_Args) MethodName() string { + return "helloWorld" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_HelloWorld_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_HelloWorld_Helper provides functions that aid in handling the +// parameters and return values of the Bar.helloWorld +// function. +var Bar_HelloWorld_Helper = struct { + // Args accepts the parameters of helloWorld in-order and returns + // the arguments struct for the function. + Args func() *Bar_HelloWorld_Args + + // IsException returns true if the given error can be thrown + // by helloWorld. + // + // An error can be thrown by helloWorld only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for helloWorld + // given its return value and error. + // + // This allows mapping values and errors returned by + // helloWorld into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by helloWorld + // + // value, err := helloWorld(args) + // result, err := Bar_HelloWorld_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from helloWorld: %v", err) + // } + // serialize(result) + WrapResponse func(string, error) (*Bar_HelloWorld_Result, error) + + // UnwrapResponse takes the result struct for helloWorld + // and returns the value or error returned by it. + // + // The error is non-nil only if helloWorld threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_HelloWorld_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_HelloWorld_Result) (string, error) +}{} + +func init() { + Bar_HelloWorld_Helper.Args = func() *Bar_HelloWorld_Args { + return &Bar_HelloWorld_Args{} + } + + Bar_HelloWorld_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_HelloWorld_Helper.WrapResponse = func(success string, err error) (*Bar_HelloWorld_Result, error) { + if err == nil { + return &Bar_HelloWorld_Result{Success: &success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_HelloWorld_Result.BarException") + } + return &Bar_HelloWorld_Result{BarException: e}, nil + } + + return nil, err + } + Bar_HelloWorld_Helper.UnwrapResponse = func(result *Bar_HelloWorld_Result) (success string, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_HelloWorld_Result represents the result of a Bar.helloWorld function call. +// +// The result of a helloWorld execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_HelloWorld_Result struct { + // Value returned by helloWorld after a successful execution. + Success *string `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_HelloWorld_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_HelloWorld_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueString(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_HelloWorld_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_HelloWorld_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_HelloWorld_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_HelloWorld_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_HelloWorld_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_HelloWorld_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_HelloWorld_Result +// struct. +func (v *Bar_HelloWorld_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_HelloWorld_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_HelloWorld_Result match the +// provided Bar_HelloWorld_Result. +// +// This function performs a deep comparison. +func (v *Bar_HelloWorld_Result) Equals(rhs *Bar_HelloWorld_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Success, rhs.Success) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_HelloWorld_Result. +func (v *Bar_HelloWorld_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", *v.Success) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_HelloWorld_Result) GetSuccess() (o string) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_HelloWorld_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_HelloWorld_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_HelloWorld_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "helloWorld" for this struct. +func (v *Bar_HelloWorld_Result) MethodName() string { + return "helloWorld" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_HelloWorld_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_ListAndEnum_Args represents the arguments for the Bar.listAndEnum function. +// +// The arguments for listAndEnum are sent and received over the wire as this struct. +type Bar_ListAndEnum_Args struct { + DemoIds []string `json:"demoIds,required"` + DemoType *DemoType `json:"demoType,omitempty"` + Demos []DemoType `json:"demos,omitempty"` +} + +// ToWire translates a Bar_ListAndEnum_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ListAndEnum_Args) ToWire() (wire.Value, error) { + var ( + fields [3]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.DemoIds == nil { + return w, errors.New("field DemoIds of Bar_ListAndEnum_Args is required") + } + w, err = wire.NewValueList(_List_String_ValueList(v.DemoIds)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.DemoType != nil { + w, err = v.DemoType.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.Demos != nil { + w, err = wire.NewValueList(_List_DemoType_ValueList(v.Demos)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ListAndEnum_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ListAndEnum_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ListAndEnum_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ListAndEnum_Args) FromWire(w wire.Value) error { + var err error + + demoIdsIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TList { + v.DemoIds, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + demoIdsIsSet = true + } + case 2: + if field.Value.Type() == wire.TI32 { + var x DemoType + x, err = _DemoType_Read(field.Value) + v.DemoType = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TList { + v.Demos, err = _List_DemoType_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + } + } + + if !demoIdsIsSet { + return errors.New("field DemoIds of Bar_ListAndEnum_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_ListAndEnum_Args +// struct. +func (v *Bar_ListAndEnum_Args) String() string { + if v == nil { + return "" + } + + var fields [3]string + i := 0 + fields[i] = fmt.Sprintf("DemoIds: %v", v.DemoIds) + i++ + if v.DemoType != nil { + fields[i] = fmt.Sprintf("DemoType: %v", *(v.DemoType)) + i++ + } + if v.Demos != nil { + fields[i] = fmt.Sprintf("Demos: %v", v.Demos) + i++ + } + + return fmt.Sprintf("Bar_ListAndEnum_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _DemoType_EqualsPtr(lhs, rhs *DemoType) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return x.Equals(y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this Bar_ListAndEnum_Args match the +// provided Bar_ListAndEnum_Args. +// +// This function performs a deep comparison. +func (v *Bar_ListAndEnum_Args) Equals(rhs *Bar_ListAndEnum_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_List_String_Equals(v.DemoIds, rhs.DemoIds) { + return false + } + if !_DemoType_EqualsPtr(v.DemoType, rhs.DemoType) { + return false + } + if !((v.Demos == nil && rhs.Demos == nil) || (v.Demos != nil && rhs.Demos != nil && _List_DemoType_Equals(v.Demos, rhs.Demos))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ListAndEnum_Args. +func (v *Bar_ListAndEnum_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("demoIds", (_List_String_Zapper)(v.DemoIds))) + if v.DemoType != nil { + err = multierr.Append(err, enc.AddObject("demoType", *v.DemoType)) + } + if v.Demos != nil { + err = multierr.Append(err, enc.AddArray("demos", (_List_DemoType_Zapper)(v.Demos))) + } + return err +} + +// GetDemoIds returns the value of DemoIds if it is set or its +// zero value if it is unset. +func (v *Bar_ListAndEnum_Args) GetDemoIds() (o []string) { + if v != nil { + o = v.DemoIds + } + return +} + +// IsSetDemoIds returns true if DemoIds is not nil. +func (v *Bar_ListAndEnum_Args) IsSetDemoIds() bool { + return v != nil && v.DemoIds != nil +} + +// GetDemoType returns the value of DemoType if it is set or its +// zero value if it is unset. +func (v *Bar_ListAndEnum_Args) GetDemoType() (o DemoType) { + if v != nil && v.DemoType != nil { + return *v.DemoType + } + + return +} + +// IsSetDemoType returns true if DemoType is not nil. +func (v *Bar_ListAndEnum_Args) IsSetDemoType() bool { + return v != nil && v.DemoType != nil +} + +// GetDemos returns the value of Demos if it is set or its +// zero value if it is unset. +func (v *Bar_ListAndEnum_Args) GetDemos() (o []DemoType) { + if v != nil && v.Demos != nil { + return v.Demos + } + + return +} + +// IsSetDemos returns true if Demos is not nil. +func (v *Bar_ListAndEnum_Args) IsSetDemos() bool { + return v != nil && v.Demos != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "listAndEnum" for this struct. +func (v *Bar_ListAndEnum_Args) MethodName() string { + return "listAndEnum" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_ListAndEnum_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_ListAndEnum_Helper provides functions that aid in handling the +// parameters and return values of the Bar.listAndEnum +// function. +var Bar_ListAndEnum_Helper = struct { + // Args accepts the parameters of listAndEnum in-order and returns + // the arguments struct for the function. + Args func( + demoIds []string, + demoType *DemoType, + demos []DemoType, + ) *Bar_ListAndEnum_Args + + // IsException returns true if the given error can be thrown + // by listAndEnum. + // + // An error can be thrown by listAndEnum only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for listAndEnum + // given its return value and error. + // + // This allows mapping values and errors returned by + // listAndEnum into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by listAndEnum + // + // value, err := listAndEnum(args) + // result, err := Bar_ListAndEnum_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from listAndEnum: %v", err) + // } + // serialize(result) + WrapResponse func(string, error) (*Bar_ListAndEnum_Result, error) + + // UnwrapResponse takes the result struct for listAndEnum + // and returns the value or error returned by it. + // + // The error is non-nil only if listAndEnum threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_ListAndEnum_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_ListAndEnum_Result) (string, error) +}{} + +func init() { + Bar_ListAndEnum_Helper.Args = func( + demoIds []string, + demoType *DemoType, + demos []DemoType, + ) *Bar_ListAndEnum_Args { + return &Bar_ListAndEnum_Args{ + DemoIds: demoIds, + DemoType: demoType, + Demos: demos, + } + } + + Bar_ListAndEnum_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_ListAndEnum_Helper.WrapResponse = func(success string, err error) (*Bar_ListAndEnum_Result, error) { + if err == nil { + return &Bar_ListAndEnum_Result{Success: &success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_ListAndEnum_Result.BarException") + } + return &Bar_ListAndEnum_Result{BarException: e}, nil + } + + return nil, err + } + Bar_ListAndEnum_Helper.UnwrapResponse = func(result *Bar_ListAndEnum_Result) (success string, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_ListAndEnum_Result represents the result of a Bar.listAndEnum function call. +// +// The result of a listAndEnum execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_ListAndEnum_Result struct { + // Value returned by listAndEnum after a successful execution. + Success *string `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_ListAndEnum_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_ListAndEnum_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueString(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_ListAndEnum_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_ListAndEnum_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_ListAndEnum_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_ListAndEnum_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_ListAndEnum_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_ListAndEnum_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_ListAndEnum_Result +// struct. +func (v *Bar_ListAndEnum_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_ListAndEnum_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_ListAndEnum_Result match the +// provided Bar_ListAndEnum_Result. +// +// This function performs a deep comparison. +func (v *Bar_ListAndEnum_Result) Equals(rhs *Bar_ListAndEnum_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Success, rhs.Success) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_ListAndEnum_Result. +func (v *Bar_ListAndEnum_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", *v.Success) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_ListAndEnum_Result) GetSuccess() (o string) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_ListAndEnum_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_ListAndEnum_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_ListAndEnum_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "listAndEnum" for this struct. +func (v *Bar_ListAndEnum_Result) MethodName() string { + return "listAndEnum" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_ListAndEnum_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_MissingArg_Args represents the arguments for the Bar.missingArg function. +// +// The arguments for missingArg are sent and received over the wire as this struct. +type Bar_MissingArg_Args struct { +} + +// ToWire translates a Bar_MissingArg_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_MissingArg_Args) ToWire() (wire.Value, error) { + var ( + fields [0]wire.Field + i int = 0 + ) + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_MissingArg_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_MissingArg_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_MissingArg_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_MissingArg_Args) FromWire(w wire.Value) error { + + for _, field := range w.GetStruct().Fields { + switch field.ID { + } + } + + return nil +} + +// String returns a readable string representation of a Bar_MissingArg_Args +// struct. +func (v *Bar_MissingArg_Args) String() string { + if v == nil { + return "" + } + + var fields [0]string + i := 0 + + return fmt.Sprintf("Bar_MissingArg_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_MissingArg_Args match the +// provided Bar_MissingArg_Args. +// +// This function performs a deep comparison. +func (v *Bar_MissingArg_Args) Equals(rhs *Bar_MissingArg_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_MissingArg_Args. +func (v *Bar_MissingArg_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + return err +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "missingArg" for this struct. +func (v *Bar_MissingArg_Args) MethodName() string { + return "missingArg" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_MissingArg_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_MissingArg_Helper provides functions that aid in handling the +// parameters and return values of the Bar.missingArg +// function. +var Bar_MissingArg_Helper = struct { + // Args accepts the parameters of missingArg in-order and returns + // the arguments struct for the function. + Args func() *Bar_MissingArg_Args + + // IsException returns true if the given error can be thrown + // by missingArg. + // + // An error can be thrown by missingArg only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for missingArg + // given its return value and error. + // + // This allows mapping values and errors returned by + // missingArg into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by missingArg + // + // value, err := missingArg(args) + // result, err := Bar_MissingArg_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from missingArg: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_MissingArg_Result, error) + + // UnwrapResponse takes the result struct for missingArg + // and returns the value or error returned by it. + // + // The error is non-nil only if missingArg threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_MissingArg_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_MissingArg_Result) (*BarResponse, error) +}{} + +func init() { + Bar_MissingArg_Helper.Args = func() *Bar_MissingArg_Args { + return &Bar_MissingArg_Args{} + } + + Bar_MissingArg_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_MissingArg_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_MissingArg_Result, error) { + if err == nil { + return &Bar_MissingArg_Result{Success: success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_MissingArg_Result.BarException") + } + return &Bar_MissingArg_Result{BarException: e}, nil + } + + return nil, err + } + Bar_MissingArg_Helper.UnwrapResponse = func(result *Bar_MissingArg_Result) (success *BarResponse, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_MissingArg_Result represents the result of a Bar.missingArg function call. +// +// The result of a missingArg execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_MissingArg_Result struct { + // Value returned by missingArg after a successful execution. + Success *BarResponse `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_MissingArg_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_MissingArg_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_MissingArg_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_MissingArg_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_MissingArg_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_MissingArg_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_MissingArg_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_MissingArg_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_MissingArg_Result +// struct. +func (v *Bar_MissingArg_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_MissingArg_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_MissingArg_Result match the +// provided Bar_MissingArg_Result. +// +// This function performs a deep comparison. +func (v *Bar_MissingArg_Result) Equals(rhs *Bar_MissingArg_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_MissingArg_Result. +func (v *Bar_MissingArg_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_MissingArg_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_MissingArg_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_MissingArg_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_MissingArg_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "missingArg" for this struct. +func (v *Bar_MissingArg_Result) MethodName() string { + return "missingArg" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_MissingArg_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_NoRequest_Args represents the arguments for the Bar.noRequest function. +// +// The arguments for noRequest are sent and received over the wire as this struct. +type Bar_NoRequest_Args struct { +} + +// ToWire translates a Bar_NoRequest_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_NoRequest_Args) ToWire() (wire.Value, error) { + var ( + fields [0]wire.Field + i int = 0 + ) + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_NoRequest_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_NoRequest_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_NoRequest_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_NoRequest_Args) FromWire(w wire.Value) error { + + for _, field := range w.GetStruct().Fields { + switch field.ID { + } + } + + return nil +} + +// String returns a readable string representation of a Bar_NoRequest_Args +// struct. +func (v *Bar_NoRequest_Args) String() string { + if v == nil { + return "" + } + + var fields [0]string + i := 0 + + return fmt.Sprintf("Bar_NoRequest_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_NoRequest_Args match the +// provided Bar_NoRequest_Args. +// +// This function performs a deep comparison. +func (v *Bar_NoRequest_Args) Equals(rhs *Bar_NoRequest_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_NoRequest_Args. +func (v *Bar_NoRequest_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + return err +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "noRequest" for this struct. +func (v *Bar_NoRequest_Args) MethodName() string { + return "noRequest" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_NoRequest_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_NoRequest_Helper provides functions that aid in handling the +// parameters and return values of the Bar.noRequest +// function. +var Bar_NoRequest_Helper = struct { + // Args accepts the parameters of noRequest in-order and returns + // the arguments struct for the function. + Args func() *Bar_NoRequest_Args + + // IsException returns true if the given error can be thrown + // by noRequest. + // + // An error can be thrown by noRequest only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for noRequest + // given its return value and error. + // + // This allows mapping values and errors returned by + // noRequest into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by noRequest + // + // value, err := noRequest(args) + // result, err := Bar_NoRequest_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from noRequest: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_NoRequest_Result, error) + + // UnwrapResponse takes the result struct for noRequest + // and returns the value or error returned by it. + // + // The error is non-nil only if noRequest threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_NoRequest_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_NoRequest_Result) (*BarResponse, error) +}{} + +func init() { + Bar_NoRequest_Helper.Args = func() *Bar_NoRequest_Args { + return &Bar_NoRequest_Args{} + } + + Bar_NoRequest_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_NoRequest_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_NoRequest_Result, error) { + if err == nil { + return &Bar_NoRequest_Result{Success: success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_NoRequest_Result.BarException") + } + return &Bar_NoRequest_Result{BarException: e}, nil + } + + return nil, err + } + Bar_NoRequest_Helper.UnwrapResponse = func(result *Bar_NoRequest_Result) (success *BarResponse, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_NoRequest_Result represents the result of a Bar.noRequest function call. +// +// The result of a noRequest execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_NoRequest_Result struct { + // Value returned by noRequest after a successful execution. + Success *BarResponse `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_NoRequest_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_NoRequest_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_NoRequest_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_NoRequest_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_NoRequest_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_NoRequest_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_NoRequest_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_NoRequest_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_NoRequest_Result +// struct. +func (v *Bar_NoRequest_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_NoRequest_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_NoRequest_Result match the +// provided Bar_NoRequest_Result. +// +// This function performs a deep comparison. +func (v *Bar_NoRequest_Result) Equals(rhs *Bar_NoRequest_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_NoRequest_Result. +func (v *Bar_NoRequest_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_NoRequest_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_NoRequest_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_NoRequest_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_NoRequest_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "noRequest" for this struct. +func (v *Bar_NoRequest_Result) MethodName() string { + return "noRequest" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_NoRequest_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_Normal_Args represents the arguments for the Bar.normal function. +// +// The arguments for normal are sent and received over the wire as this struct. +type Bar_Normal_Args struct { + Request *BarRequest `json:"request,required"` +} + +// ToWire translates a Bar_Normal_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_Normal_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request == nil { + return w, errors.New("field Request of Bar_Normal_Args is required") + } + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_Normal_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_Normal_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_Normal_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_Normal_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _BarRequest_Read(field.Value) + if err != nil { + return err + } + requestIsSet = true + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_Normal_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_Normal_Args +// struct. +func (v *Bar_Normal_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + + return fmt.Sprintf("Bar_Normal_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_Normal_Args match the +// provided Bar_Normal_Args. +// +// This function performs a deep comparison. +func (v *Bar_Normal_Args) Equals(rhs *Bar_Normal_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !v.Request.Equals(rhs.Request) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_Normal_Args. +func (v *Bar_Normal_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("request", v.Request)) + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_Normal_Args) GetRequest() (o *BarRequest) { + if v != nil { + o = v.Request + } + return +} + +// IsSetRequest returns true if Request is not nil. +func (v *Bar_Normal_Args) IsSetRequest() bool { + return v != nil && v.Request != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "normal" for this struct. +func (v *Bar_Normal_Args) MethodName() string { + return "normal" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_Normal_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_Normal_Helper provides functions that aid in handling the +// parameters and return values of the Bar.normal +// function. +var Bar_Normal_Helper = struct { + // Args accepts the parameters of normal in-order and returns + // the arguments struct for the function. + Args func( + request *BarRequest, + ) *Bar_Normal_Args + + // IsException returns true if the given error can be thrown + // by normal. + // + // An error can be thrown by normal only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for normal + // given its return value and error. + // + // This allows mapping values and errors returned by + // normal into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by normal + // + // value, err := normal(args) + // result, err := Bar_Normal_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from normal: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_Normal_Result, error) + + // UnwrapResponse takes the result struct for normal + // and returns the value or error returned by it. + // + // The error is non-nil only if normal threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_Normal_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_Normal_Result) (*BarResponse, error) +}{} + +func init() { + Bar_Normal_Helper.Args = func( + request *BarRequest, + ) *Bar_Normal_Args { + return &Bar_Normal_Args{ + Request: request, + } + } + + Bar_Normal_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_Normal_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_Normal_Result, error) { + if err == nil { + return &Bar_Normal_Result{Success: success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_Normal_Result.BarException") + } + return &Bar_Normal_Result{BarException: e}, nil + } + + return nil, err + } + Bar_Normal_Helper.UnwrapResponse = func(result *Bar_Normal_Result) (success *BarResponse, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_Normal_Result represents the result of a Bar.normal function call. +// +// The result of a normal execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_Normal_Result struct { + // Value returned by normal after a successful execution. + Success *BarResponse `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_Normal_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_Normal_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_Normal_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_Normal_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_Normal_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_Normal_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_Normal_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_Normal_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_Normal_Result +// struct. +func (v *Bar_Normal_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_Normal_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_Normal_Result match the +// provided Bar_Normal_Result. +// +// This function performs a deep comparison. +func (v *Bar_Normal_Result) Equals(rhs *Bar_Normal_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_Normal_Result. +func (v *Bar_Normal_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_Normal_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_Normal_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_Normal_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_Normal_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "normal" for this struct. +func (v *Bar_Normal_Result) MethodName() string { + return "normal" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_Normal_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_NormalRecur_Args represents the arguments for the Bar.normalRecur function. +// +// The arguments for normalRecur are sent and received over the wire as this struct. +type Bar_NormalRecur_Args struct { + Request *BarRequestRecur `json:"request,required"` +} + +// ToWire translates a Bar_NormalRecur_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_NormalRecur_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request == nil { + return w, errors.New("field Request of Bar_NormalRecur_Args is required") + } + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bar_NormalRecur_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_NormalRecur_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_NormalRecur_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_NormalRecur_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _BarRequestRecur_Read(field.Value) + if err != nil { + return err + } + requestIsSet = true + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_NormalRecur_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_NormalRecur_Args +// struct. +func (v *Bar_NormalRecur_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + + return fmt.Sprintf("Bar_NormalRecur_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_NormalRecur_Args match the +// provided Bar_NormalRecur_Args. +// +// This function performs a deep comparison. +func (v *Bar_NormalRecur_Args) Equals(rhs *Bar_NormalRecur_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !v.Request.Equals(rhs.Request) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_NormalRecur_Args. +func (v *Bar_NormalRecur_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("request", v.Request)) + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_NormalRecur_Args) GetRequest() (o *BarRequestRecur) { + if v != nil { + o = v.Request + } + return +} + +// IsSetRequest returns true if Request is not nil. +func (v *Bar_NormalRecur_Args) IsSetRequest() bool { + return v != nil && v.Request != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "normalRecur" for this struct. +func (v *Bar_NormalRecur_Args) MethodName() string { + return "normalRecur" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_NormalRecur_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_NormalRecur_Helper provides functions that aid in handling the +// parameters and return values of the Bar.normalRecur +// function. +var Bar_NormalRecur_Helper = struct { + // Args accepts the parameters of normalRecur in-order and returns + // the arguments struct for the function. + Args func( + request *BarRequestRecur, + ) *Bar_NormalRecur_Args + + // IsException returns true if the given error can be thrown + // by normalRecur. + // + // An error can be thrown by normalRecur only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for normalRecur + // given its return value and error. + // + // This allows mapping values and errors returned by + // normalRecur into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by normalRecur + // + // value, err := normalRecur(args) + // result, err := Bar_NormalRecur_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from normalRecur: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponseRecur, error) (*Bar_NormalRecur_Result, error) + + // UnwrapResponse takes the result struct for normalRecur + // and returns the value or error returned by it. + // + // The error is non-nil only if normalRecur threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_NormalRecur_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_NormalRecur_Result) (*BarResponseRecur, error) +}{} + +func init() { + Bar_NormalRecur_Helper.Args = func( + request *BarRequestRecur, + ) *Bar_NormalRecur_Args { + return &Bar_NormalRecur_Args{ + Request: request, + } + } + + Bar_NormalRecur_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + default: + return false + } + } + + Bar_NormalRecur_Helper.WrapResponse = func(success *BarResponseRecur, err error) (*Bar_NormalRecur_Result, error) { + if err == nil { + return &Bar_NormalRecur_Result{Success: success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_NormalRecur_Result.BarException") + } + return &Bar_NormalRecur_Result{BarException: e}, nil + } + + return nil, err + } + Bar_NormalRecur_Helper.UnwrapResponse = func(result *Bar_NormalRecur_Result) (success *BarResponseRecur, err error) { + if result.BarException != nil { + err = result.BarException + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_NormalRecur_Result represents the result of a Bar.normalRecur function call. +// +// The result of a normalRecur execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_NormalRecur_Result struct { + // Value returned by normalRecur after a successful execution. + Success *BarResponseRecur `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` +} + +// ToWire translates a Bar_NormalRecur_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_NormalRecur_Result) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_NormalRecur_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _BarResponseRecur_Read(w wire.Value) (*BarResponseRecur, error) { + var v BarResponseRecur + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_NormalRecur_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_NormalRecur_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_NormalRecur_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_NormalRecur_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponseRecur_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_NormalRecur_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_NormalRecur_Result +// struct. +func (v *Bar_NormalRecur_Result) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + + return fmt.Sprintf("Bar_NormalRecur_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_NormalRecur_Result match the +// provided Bar_NormalRecur_Result. +// +// This function performs a deep comparison. +func (v *Bar_NormalRecur_Result) Equals(rhs *Bar_NormalRecur_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_NormalRecur_Result. +func (v *Bar_NormalRecur_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_NormalRecur_Result) GetSuccess() (o *BarResponseRecur) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_NormalRecur_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_NormalRecur_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_NormalRecur_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "normalRecur" for this struct. +func (v *Bar_NormalRecur_Result) MethodName() string { + return "normalRecur" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_NormalRecur_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Bar_TooManyArgs_Args represents the arguments for the Bar.tooManyArgs function. +// +// The arguments for tooManyArgs are sent and received over the wire as this struct. +type Bar_TooManyArgs_Args struct { + Request *BarRequest `json:"request,required"` + Foo *foo.FooStruct `json:"foo,omitempty"` +} + +// ToWire translates a Bar_TooManyArgs_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_TooManyArgs_Args) ToWire() (wire.Value, error) { + var ( + fields [2]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Request == nil { + return w, errors.New("field Request of Bar_TooManyArgs_Args is required") + } + w, err = v.Request.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.Foo != nil { + w, err = v.Foo.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _FooStruct_Read(w wire.Value) (*foo.FooStruct, error) { + var v foo.FooStruct + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_TooManyArgs_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_TooManyArgs_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_TooManyArgs_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_TooManyArgs_Args) FromWire(w wire.Value) error { + var err error + + requestIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TStruct { + v.Request, err = _BarRequest_Read(field.Value) + if err != nil { + return err + } + requestIsSet = true + } + case 2: + if field.Value.Type() == wire.TStruct { + v.Foo, err = _FooStruct_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !requestIsSet { + return errors.New("field Request of Bar_TooManyArgs_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bar_TooManyArgs_Args +// struct. +func (v *Bar_TooManyArgs_Args) String() string { + if v == nil { + return "" + } + + var fields [2]string + i := 0 + fields[i] = fmt.Sprintf("Request: %v", v.Request) + i++ + if v.Foo != nil { + fields[i] = fmt.Sprintf("Foo: %v", v.Foo) + i++ + } + + return fmt.Sprintf("Bar_TooManyArgs_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_TooManyArgs_Args match the +// provided Bar_TooManyArgs_Args. +// +// This function performs a deep comparison. +func (v *Bar_TooManyArgs_Args) Equals(rhs *Bar_TooManyArgs_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !v.Request.Equals(rhs.Request) { + return false + } + if !((v.Foo == nil && rhs.Foo == nil) || (v.Foo != nil && rhs.Foo != nil && v.Foo.Equals(rhs.Foo))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_TooManyArgs_Args. +func (v *Bar_TooManyArgs_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("request", v.Request)) + if v.Foo != nil { + err = multierr.Append(err, enc.AddObject("foo", v.Foo)) + } + return err +} + +// GetRequest returns the value of Request if it is set or its +// zero value if it is unset. +func (v *Bar_TooManyArgs_Args) GetRequest() (o *BarRequest) { + if v != nil { + o = v.Request + } + return +} + +// IsSetRequest returns true if Request is not nil. +func (v *Bar_TooManyArgs_Args) IsSetRequest() bool { + return v != nil && v.Request != nil +} + +// GetFoo returns the value of Foo if it is set or its +// zero value if it is unset. +func (v *Bar_TooManyArgs_Args) GetFoo() (o *foo.FooStruct) { + if v != nil && v.Foo != nil { + return v.Foo + } + + return +} + +// IsSetFoo returns true if Foo is not nil. +func (v *Bar_TooManyArgs_Args) IsSetFoo() bool { + return v != nil && v.Foo != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "tooManyArgs" for this struct. +func (v *Bar_TooManyArgs_Args) MethodName() string { + return "tooManyArgs" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bar_TooManyArgs_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bar_TooManyArgs_Helper provides functions that aid in handling the +// parameters and return values of the Bar.tooManyArgs +// function. +var Bar_TooManyArgs_Helper = struct { + // Args accepts the parameters of tooManyArgs in-order and returns + // the arguments struct for the function. + Args func( + request *BarRequest, + foo *foo.FooStruct, + ) *Bar_TooManyArgs_Args + + // IsException returns true if the given error can be thrown + // by tooManyArgs. + // + // An error can be thrown by tooManyArgs only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for tooManyArgs + // given its return value and error. + // + // This allows mapping values and errors returned by + // tooManyArgs into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by tooManyArgs + // + // value, err := tooManyArgs(args) + // result, err := Bar_TooManyArgs_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from tooManyArgs: %v", err) + // } + // serialize(result) + WrapResponse func(*BarResponse, error) (*Bar_TooManyArgs_Result, error) + + // UnwrapResponse takes the result struct for tooManyArgs + // and returns the value or error returned by it. + // + // The error is non-nil only if tooManyArgs threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bar_TooManyArgs_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bar_TooManyArgs_Result) (*BarResponse, error) +}{} + +func init() { + Bar_TooManyArgs_Helper.Args = func( + request *BarRequest, + foo *foo.FooStruct, + ) *Bar_TooManyArgs_Args { + return &Bar_TooManyArgs_Args{ + Request: request, + Foo: foo, + } + } + + Bar_TooManyArgs_Helper.IsException = func(err error) bool { + switch err.(type) { + case *BarException: + return true + case *foo.FooException: + return true + default: + return false + } + } + + Bar_TooManyArgs_Helper.WrapResponse = func(success *BarResponse, err error) (*Bar_TooManyArgs_Result, error) { + if err == nil { + return &Bar_TooManyArgs_Result{Success: success}, nil + } + + switch e := err.(type) { + case *BarException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_TooManyArgs_Result.BarException") + } + return &Bar_TooManyArgs_Result{BarException: e}, nil + case *foo.FooException: + if e == nil { + return nil, errors.New("WrapResponse received non-nil error type with nil value for Bar_TooManyArgs_Result.FooException") + } + return &Bar_TooManyArgs_Result{FooException: e}, nil + } + + return nil, err + } + Bar_TooManyArgs_Helper.UnwrapResponse = func(result *Bar_TooManyArgs_Result) (success *BarResponse, err error) { + if result.BarException != nil { + err = result.BarException + return + } + if result.FooException != nil { + err = result.FooException + return + } + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bar_TooManyArgs_Result represents the result of a Bar.tooManyArgs function call. +// +// The result of a tooManyArgs execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bar_TooManyArgs_Result struct { + // Value returned by tooManyArgs after a successful execution. + Success *BarResponse `json:"success,omitempty"` + BarException *BarException `json:"barException,omitempty"` + FooException *foo.FooException `json:"fooException,omitempty"` +} + +// ToWire translates a Bar_TooManyArgs_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bar_TooManyArgs_Result) ToWire() (wire.Value, error) { + var ( + fields [3]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + if v.BarException != nil { + w, err = v.BarException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + if v.FooException != nil { + w, err = v.FooException.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bar_TooManyArgs_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _FooException_Read(w wire.Value) (*foo.FooException, error) { + var v foo.FooException + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a Bar_TooManyArgs_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bar_TooManyArgs_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bar_TooManyArgs_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bar_TooManyArgs_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TStruct { + v.Success, err = _BarResponse_Read(field.Value) + if err != nil { + return err + } + + } + case 1: + if field.Value.Type() == wire.TStruct { + v.BarException, err = _BarException_Read(field.Value) + if err != nil { + return err + } + + } + case 2: + if field.Value.Type() == wire.TStruct { + v.FooException, err = _FooException_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if v.BarException != nil { + count++ + } + if v.FooException != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bar_TooManyArgs_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bar_TooManyArgs_Result +// struct. +func (v *Bar_TooManyArgs_Result) String() string { + if v == nil { + return "" + } + + var fields [3]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + if v.BarException != nil { + fields[i] = fmt.Sprintf("BarException: %v", v.BarException) + i++ + } + if v.FooException != nil { + fields[i] = fmt.Sprintf("FooException: %v", v.FooException) + i++ + } + + return fmt.Sprintf("Bar_TooManyArgs_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bar_TooManyArgs_Result match the +// provided Bar_TooManyArgs_Result. +// +// This function performs a deep comparison. +func (v *Bar_TooManyArgs_Result) Equals(rhs *Bar_TooManyArgs_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && v.Success.Equals(rhs.Success))) { + return false + } + if !((v.BarException == nil && rhs.BarException == nil) || (v.BarException != nil && rhs.BarException != nil && v.BarException.Equals(rhs.BarException))) { + return false + } + if !((v.FooException == nil && rhs.FooException == nil) || (v.FooException != nil && rhs.FooException != nil && v.FooException.Equals(rhs.FooException))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bar_TooManyArgs_Result. +func (v *Bar_TooManyArgs_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", v.Success)) + } + if v.BarException != nil { + err = multierr.Append(err, enc.AddObject("barException", v.BarException)) + } + if v.FooException != nil { + err = multierr.Append(err, enc.AddObject("fooException", v.FooException)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bar_TooManyArgs_Result) GetSuccess() (o *BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bar_TooManyArgs_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// GetBarException returns the value of BarException if it is set or its +// zero value if it is unset. +func (v *Bar_TooManyArgs_Result) GetBarException() (o *BarException) { + if v != nil && v.BarException != nil { + return v.BarException + } + + return +} + +// IsSetBarException returns true if BarException is not nil. +func (v *Bar_TooManyArgs_Result) IsSetBarException() bool { + return v != nil && v.BarException != nil +} + +// GetFooException returns the value of FooException if it is set or its +// zero value if it is unset. +func (v *Bar_TooManyArgs_Result) GetFooException() (o *foo.FooException) { + if v != nil && v.FooException != nil { + return v.FooException + } + + return +} + +// IsSetFooException returns true if FooException is not nil. +func (v *Bar_TooManyArgs_Result) IsSetFooException() bool { + return v != nil && v.FooException != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "tooManyArgs" for this struct. +func (v *Bar_TooManyArgs_Result) MethodName() string { + return "tooManyArgs" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bar_TooManyArgs_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoBinary_Args represents the arguments for the Echo.echoBinary function. +// +// The arguments for echoBinary are sent and received over the wire as this struct. +type Echo_EchoBinary_Args struct { + Arg []byte `json:"arg,required"` +} + +// ToWire translates a Echo_EchoBinary_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoBinary_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoBinary_Args is required") + } + w, err = wire.NewValueBinary(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoBinary_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoBinary_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoBinary_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoBinary_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Arg, err = field.Value.GetBinary(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoBinary_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoBinary_Args +// struct. +func (v *Echo_EchoBinary_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoBinary_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoBinary_Args match the +// provided Echo_EchoBinary_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoBinary_Args) Equals(rhs *Echo_EchoBinary_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !bytes.Equal(v.Arg, rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoBinary_Args. +func (v *Echo_EchoBinary_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("arg", base64.StdEncoding.EncodeToString(v.Arg)) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoBinary_Args) GetArg() (o []byte) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoBinary_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoBinary" for this struct. +func (v *Echo_EchoBinary_Args) MethodName() string { + return "echoBinary" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoBinary_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoBinary_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoBinary +// function. +var Echo_EchoBinary_Helper = struct { + // Args accepts the parameters of echoBinary in-order and returns + // the arguments struct for the function. + Args func( + arg []byte, + ) *Echo_EchoBinary_Args + + // IsException returns true if the given error can be thrown + // by echoBinary. + // + // An error can be thrown by echoBinary only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoBinary + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoBinary into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoBinary + // + // value, err := echoBinary(args) + // result, err := Echo_EchoBinary_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoBinary: %v", err) + // } + // serialize(result) + WrapResponse func([]byte, error) (*Echo_EchoBinary_Result, error) + + // UnwrapResponse takes the result struct for echoBinary + // and returns the value or error returned by it. + // + // The error is non-nil only if echoBinary threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoBinary_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoBinary_Result) ([]byte, error) +}{} + +func init() { + Echo_EchoBinary_Helper.Args = func( + arg []byte, + ) *Echo_EchoBinary_Args { + return &Echo_EchoBinary_Args{ + Arg: arg, + } + } + + Echo_EchoBinary_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoBinary_Helper.WrapResponse = func(success []byte, err error) (*Echo_EchoBinary_Result, error) { + if err == nil { + return &Echo_EchoBinary_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoBinary_Helper.UnwrapResponse = func(result *Echo_EchoBinary_Result) (success []byte, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoBinary_Result represents the result of a Echo.echoBinary function call. +// +// The result of a echoBinary execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoBinary_Result struct { + // Value returned by echoBinary after a successful execution. + Success []byte `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoBinary_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoBinary_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueBinary(v.Success), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoBinary_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoBinary_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoBinary_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoBinary_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoBinary_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + v.Success, err = field.Value.GetBinary(), error(nil) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoBinary_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoBinary_Result +// struct. +func (v *Echo_EchoBinary_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoBinary_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoBinary_Result match the +// provided Echo_EchoBinary_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoBinary_Result) Equals(rhs *Echo_EchoBinary_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && bytes.Equal(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoBinary_Result. +func (v *Echo_EchoBinary_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", base64.StdEncoding.EncodeToString(v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoBinary_Result) GetSuccess() (o []byte) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoBinary_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoBinary" for this struct. +func (v *Echo_EchoBinary_Result) MethodName() string { + return "echoBinary" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoBinary_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoBool_Args represents the arguments for the Echo.echoBool function. +// +// The arguments for echoBool are sent and received over the wire as this struct. +type Echo_EchoBool_Args struct { + Arg bool `json:"arg,required"` +} + +// ToWire translates a Echo_EchoBool_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoBool_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueBool(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoBool_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoBool_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoBool_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoBool_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBool { + v.Arg, err = field.Value.GetBool(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoBool_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoBool_Args +// struct. +func (v *Echo_EchoBool_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoBool_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoBool_Args match the +// provided Echo_EchoBool_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoBool_Args) Equals(rhs *Echo_EchoBool_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoBool_Args. +func (v *Echo_EchoBool_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddBool("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoBool_Args) GetArg() (o bool) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoBool" for this struct. +func (v *Echo_EchoBool_Args) MethodName() string { + return "echoBool" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoBool_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoBool_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoBool +// function. +var Echo_EchoBool_Helper = struct { + // Args accepts the parameters of echoBool in-order and returns + // the arguments struct for the function. + Args func( + arg bool, + ) *Echo_EchoBool_Args + + // IsException returns true if the given error can be thrown + // by echoBool. + // + // An error can be thrown by echoBool only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoBool + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoBool into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoBool + // + // value, err := echoBool(args) + // result, err := Echo_EchoBool_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoBool: %v", err) + // } + // serialize(result) + WrapResponse func(bool, error) (*Echo_EchoBool_Result, error) + + // UnwrapResponse takes the result struct for echoBool + // and returns the value or error returned by it. + // + // The error is non-nil only if echoBool threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoBool_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoBool_Result) (bool, error) +}{} + +func init() { + Echo_EchoBool_Helper.Args = func( + arg bool, + ) *Echo_EchoBool_Args { + return &Echo_EchoBool_Args{ + Arg: arg, + } + } + + Echo_EchoBool_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoBool_Helper.WrapResponse = func(success bool, err error) (*Echo_EchoBool_Result, error) { + if err == nil { + return &Echo_EchoBool_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoBool_Helper.UnwrapResponse = func(result *Echo_EchoBool_Result) (success bool, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoBool_Result represents the result of a Echo.echoBool function call. +// +// The result of a echoBool execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoBool_Result struct { + // Value returned by echoBool after a successful execution. + Success *bool `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoBool_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoBool_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueBool(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoBool_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoBool_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoBool_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoBool_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoBool_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBool { + var x bool + x, err = field.Value.GetBool(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoBool_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoBool_Result +// struct. +func (v *Echo_EchoBool_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoBool_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoBool_Result match the +// provided Echo_EchoBool_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoBool_Result) Equals(rhs *Echo_EchoBool_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Bool_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoBool_Result. +func (v *Echo_EchoBool_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddBool("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoBool_Result) GetSuccess() (o bool) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoBool_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoBool" for this struct. +func (v *Echo_EchoBool_Result) MethodName() string { + return "echoBool" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoBool_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoDouble_Args represents the arguments for the Echo.echoDouble function. +// +// The arguments for echoDouble are sent and received over the wire as this struct. +type Echo_EchoDouble_Args struct { + Arg float64 `json:"arg,required"` +} + +// ToWire translates a Echo_EchoDouble_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoDouble_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueDouble(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoDouble_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoDouble_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoDouble_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoDouble_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TDouble { + v.Arg, err = field.Value.GetDouble(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoDouble_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoDouble_Args +// struct. +func (v *Echo_EchoDouble_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoDouble_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoDouble_Args match the +// provided Echo_EchoDouble_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoDouble_Args) Equals(rhs *Echo_EchoDouble_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoDouble_Args. +func (v *Echo_EchoDouble_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddFloat64("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoDouble_Args) GetArg() (o float64) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoDouble" for this struct. +func (v *Echo_EchoDouble_Args) MethodName() string { + return "echoDouble" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoDouble_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoDouble_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoDouble +// function. +var Echo_EchoDouble_Helper = struct { + // Args accepts the parameters of echoDouble in-order and returns + // the arguments struct for the function. + Args func( + arg float64, + ) *Echo_EchoDouble_Args + + // IsException returns true if the given error can be thrown + // by echoDouble. + // + // An error can be thrown by echoDouble only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoDouble + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoDouble into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoDouble + // + // value, err := echoDouble(args) + // result, err := Echo_EchoDouble_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoDouble: %v", err) + // } + // serialize(result) + WrapResponse func(float64, error) (*Echo_EchoDouble_Result, error) + + // UnwrapResponse takes the result struct for echoDouble + // and returns the value or error returned by it. + // + // The error is non-nil only if echoDouble threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoDouble_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoDouble_Result) (float64, error) +}{} + +func init() { + Echo_EchoDouble_Helper.Args = func( + arg float64, + ) *Echo_EchoDouble_Args { + return &Echo_EchoDouble_Args{ + Arg: arg, + } + } + + Echo_EchoDouble_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoDouble_Helper.WrapResponse = func(success float64, err error) (*Echo_EchoDouble_Result, error) { + if err == nil { + return &Echo_EchoDouble_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoDouble_Helper.UnwrapResponse = func(result *Echo_EchoDouble_Result) (success float64, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoDouble_Result represents the result of a Echo.echoDouble function call. +// +// The result of a echoDouble execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoDouble_Result struct { + // Value returned by echoDouble after a successful execution. + Success *float64 `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoDouble_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoDouble_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueDouble(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoDouble_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoDouble_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoDouble_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoDouble_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoDouble_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TDouble { + var x float64 + x, err = field.Value.GetDouble(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoDouble_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoDouble_Result +// struct. +func (v *Echo_EchoDouble_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoDouble_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoDouble_Result match the +// provided Echo_EchoDouble_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoDouble_Result) Equals(rhs *Echo_EchoDouble_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Double_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoDouble_Result. +func (v *Echo_EchoDouble_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddFloat64("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoDouble_Result) GetSuccess() (o float64) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoDouble_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoDouble" for this struct. +func (v *Echo_EchoDouble_Result) MethodName() string { + return "echoDouble" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoDouble_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoEnum_Args represents the arguments for the Echo.echoEnum function. +// +// The arguments for echoEnum are sent and received over the wire as this struct. +type Echo_EchoEnum_Args struct { + Arg *Fruit `json:"arg,omitempty"` +} + +func _Fruit_ptr(v Fruit) *Fruit { + return &v +} + +// ToWire translates a Echo_EchoEnum_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoEnum_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + v.Arg = _Fruit_ptr(FruitApple) + } + { + w, err = v.Arg.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoEnum_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoEnum_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoEnum_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoEnum_Args) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TI32 { + var x Fruit + x, err = _Fruit_Read(field.Value) + v.Arg = &x + if err != nil { + return err + } + + } + } + } + + if v.Arg == nil { + v.Arg = _Fruit_ptr(FruitApple) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoEnum_Args +// struct. +func (v *Echo_EchoEnum_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Arg != nil { + fields[i] = fmt.Sprintf("Arg: %v", *(v.Arg)) + i++ + } + + return fmt.Sprintf("Echo_EchoEnum_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoEnum_Args match the +// provided Echo_EchoEnum_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoEnum_Args) Equals(rhs *Echo_EchoEnum_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Fruit_EqualsPtr(v.Arg, rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoEnum_Args. +func (v *Echo_EchoEnum_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Arg != nil { + err = multierr.Append(err, enc.AddObject("arg", *v.Arg)) + } + return err +} + +// GetArg returns the value of Arg if it is set or its +// default value if it is unset. +func (v *Echo_EchoEnum_Args) GetArg() (o Fruit) { + if v != nil && v.Arg != nil { + return *v.Arg + } + o = FruitApple + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoEnum_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoEnum" for this struct. +func (v *Echo_EchoEnum_Args) MethodName() string { + return "echoEnum" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoEnum_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoEnum_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoEnum +// function. +var Echo_EchoEnum_Helper = struct { + // Args accepts the parameters of echoEnum in-order and returns + // the arguments struct for the function. + Args func( + arg *Fruit, + ) *Echo_EchoEnum_Args + + // IsException returns true if the given error can be thrown + // by echoEnum. + // + // An error can be thrown by echoEnum only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoEnum + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoEnum into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoEnum + // + // value, err := echoEnum(args) + // result, err := Echo_EchoEnum_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoEnum: %v", err) + // } + // serialize(result) + WrapResponse func(Fruit, error) (*Echo_EchoEnum_Result, error) + + // UnwrapResponse takes the result struct for echoEnum + // and returns the value or error returned by it. + // + // The error is non-nil only if echoEnum threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoEnum_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoEnum_Result) (Fruit, error) +}{} + +func init() { + Echo_EchoEnum_Helper.Args = func( + arg *Fruit, + ) *Echo_EchoEnum_Args { + return &Echo_EchoEnum_Args{ + Arg: arg, + } + } + + Echo_EchoEnum_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoEnum_Helper.WrapResponse = func(success Fruit, err error) (*Echo_EchoEnum_Result, error) { + if err == nil { + return &Echo_EchoEnum_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoEnum_Helper.UnwrapResponse = func(result *Echo_EchoEnum_Result) (success Fruit, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoEnum_Result represents the result of a Echo.echoEnum function call. +// +// The result of a echoEnum execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoEnum_Result struct { + // Value returned by echoEnum after a successful execution. + Success *Fruit `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoEnum_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoEnum_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoEnum_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoEnum_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoEnum_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoEnum_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoEnum_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TI32 { + var x Fruit + x, err = _Fruit_Read(field.Value) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoEnum_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoEnum_Result +// struct. +func (v *Echo_EchoEnum_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoEnum_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoEnum_Result match the +// provided Echo_EchoEnum_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoEnum_Result) Equals(rhs *Echo_EchoEnum_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Fruit_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoEnum_Result. +func (v *Echo_EchoEnum_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", *v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoEnum_Result) GetSuccess() (o Fruit) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoEnum_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoEnum" for this struct. +func (v *Echo_EchoEnum_Result) MethodName() string { + return "echoEnum" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoEnum_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoI16_Args represents the arguments for the Echo.echoI16 function. +// +// The arguments for echoI16 are sent and received over the wire as this struct. +type Echo_EchoI16_Args struct { + Arg int16 `json:"arg,required"` +} + +// ToWire translates a Echo_EchoI16_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI16_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueI16(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI16_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI16_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI16_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI16_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TI16 { + v.Arg, err = field.Value.GetI16(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoI16_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI16_Args +// struct. +func (v *Echo_EchoI16_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoI16_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI16_Args match the +// provided Echo_EchoI16_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoI16_Args) Equals(rhs *Echo_EchoI16_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI16_Args. +func (v *Echo_EchoI16_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddInt16("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI16_Args) GetArg() (o int16) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoI16" for this struct. +func (v *Echo_EchoI16_Args) MethodName() string { + return "echoI16" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoI16_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoI16_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoI16 +// function. +var Echo_EchoI16_Helper = struct { + // Args accepts the parameters of echoI16 in-order and returns + // the arguments struct for the function. + Args func( + arg int16, + ) *Echo_EchoI16_Args + + // IsException returns true if the given error can be thrown + // by echoI16. + // + // An error can be thrown by echoI16 only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoI16 + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoI16 into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoI16 + // + // value, err := echoI16(args) + // result, err := Echo_EchoI16_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoI16: %v", err) + // } + // serialize(result) + WrapResponse func(int16, error) (*Echo_EchoI16_Result, error) + + // UnwrapResponse takes the result struct for echoI16 + // and returns the value or error returned by it. + // + // The error is non-nil only if echoI16 threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoI16_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoI16_Result) (int16, error) +}{} + +func init() { + Echo_EchoI16_Helper.Args = func( + arg int16, + ) *Echo_EchoI16_Args { + return &Echo_EchoI16_Args{ + Arg: arg, + } + } + + Echo_EchoI16_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoI16_Helper.WrapResponse = func(success int16, err error) (*Echo_EchoI16_Result, error) { + if err == nil { + return &Echo_EchoI16_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoI16_Helper.UnwrapResponse = func(result *Echo_EchoI16_Result) (success int16, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoI16_Result represents the result of a Echo.echoI16 function call. +// +// The result of a echoI16 execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoI16_Result struct { + // Value returned by echoI16 after a successful execution. + Success *int16 `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoI16_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI16_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueI16(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoI16_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI16_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI16_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI16_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI16_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TI16 { + var x int16 + x, err = field.Value.GetI16(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoI16_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI16_Result +// struct. +func (v *Echo_EchoI16_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoI16_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI16_Result match the +// provided Echo_EchoI16_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoI16_Result) Equals(rhs *Echo_EchoI16_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_I16_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI16_Result. +func (v *Echo_EchoI16_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddInt16("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI16_Result) GetSuccess() (o int16) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoI16_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoI16" for this struct. +func (v *Echo_EchoI16_Result) MethodName() string { + return "echoI16" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoI16_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoI32_Args represents the arguments for the Echo.echoI32 function. +// +// The arguments for echoI32 are sent and received over the wire as this struct. +type Echo_EchoI32_Args struct { + Arg int32 `json:"arg,required"` +} + +// ToWire translates a Echo_EchoI32_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI32_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueI32(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI32_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI32_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI32_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI32_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TI32 { + v.Arg, err = field.Value.GetI32(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoI32_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI32_Args +// struct. +func (v *Echo_EchoI32_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoI32_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI32_Args match the +// provided Echo_EchoI32_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoI32_Args) Equals(rhs *Echo_EchoI32_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI32_Args. +func (v *Echo_EchoI32_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddInt32("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI32_Args) GetArg() (o int32) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoI32" for this struct. +func (v *Echo_EchoI32_Args) MethodName() string { + return "echoI32" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoI32_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoI32_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoI32 +// function. +var Echo_EchoI32_Helper = struct { + // Args accepts the parameters of echoI32 in-order and returns + // the arguments struct for the function. + Args func( + arg int32, + ) *Echo_EchoI32_Args + + // IsException returns true if the given error can be thrown + // by echoI32. + // + // An error can be thrown by echoI32 only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoI32 + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoI32 into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoI32 + // + // value, err := echoI32(args) + // result, err := Echo_EchoI32_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoI32: %v", err) + // } + // serialize(result) + WrapResponse func(int32, error) (*Echo_EchoI32_Result, error) + + // UnwrapResponse takes the result struct for echoI32 + // and returns the value or error returned by it. + // + // The error is non-nil only if echoI32 threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoI32_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoI32_Result) (int32, error) +}{} + +func init() { + Echo_EchoI32_Helper.Args = func( + arg int32, + ) *Echo_EchoI32_Args { + return &Echo_EchoI32_Args{ + Arg: arg, + } + } + + Echo_EchoI32_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoI32_Helper.WrapResponse = func(success int32, err error) (*Echo_EchoI32_Result, error) { + if err == nil { + return &Echo_EchoI32_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoI32_Helper.UnwrapResponse = func(result *Echo_EchoI32_Result) (success int32, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoI32_Result represents the result of a Echo.echoI32 function call. +// +// The result of a echoI32 execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoI32_Result struct { + // Value returned by echoI32 after a successful execution. + Success *int32 `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoI32_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI32_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueI32(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoI32_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI32_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI32_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI32_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI32_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TI32 { + var x int32 + x, err = field.Value.GetI32(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoI32_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI32_Result +// struct. +func (v *Echo_EchoI32_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoI32_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI32_Result match the +// provided Echo_EchoI32_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoI32_Result) Equals(rhs *Echo_EchoI32_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_I32_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI32_Result. +func (v *Echo_EchoI32_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddInt32("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI32_Result) GetSuccess() (o int32) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoI32_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoI32" for this struct. +func (v *Echo_EchoI32_Result) MethodName() string { + return "echoI32" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoI32_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoI32Map_Args represents the arguments for the Echo.echoI32Map function. +// +// The arguments for echoI32Map are sent and received over the wire as this struct. +type Echo_EchoI32Map_Args struct { + Arg map[int32]*BarResponse `json:"arg,required"` +} + +type _Map_I32_BarResponse_MapItemList map[int32]*BarResponse + +func (m _Map_I32_BarResponse_MapItemList) ForEach(f func(wire.MapItem) error) error { + for k, v := range m { + if v == nil { + return fmt.Errorf("invalid [%v]: value is nil", k) + } + kw, err := wire.NewValueI32(k), error(nil) + if err != nil { + return err + } + + vw, err := v.ToWire() + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_I32_BarResponse_MapItemList) Size() int { + return len(m) +} + +func (_Map_I32_BarResponse_MapItemList) KeyType() wire.Type { + return wire.TI32 +} + +func (_Map_I32_BarResponse_MapItemList) ValueType() wire.Type { + return wire.TStruct +} + +func (_Map_I32_BarResponse_MapItemList) Close() {} + +// ToWire translates a Echo_EchoI32Map_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI32Map_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoI32Map_Args is required") + } + w, err = wire.NewValueMap(_Map_I32_BarResponse_MapItemList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Map_I32_BarResponse_Read(m wire.MapItemList) (map[int32]*BarResponse, error) { + if m.KeyType() != wire.TI32 { + return nil, nil + } + + if m.ValueType() != wire.TStruct { + return nil, nil + } + + o := make(map[int32]*BarResponse, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := x.Key.GetI32(), error(nil) + if err != nil { + return err + } + + v, err := _BarResponse_Read(x.Value) + if err != nil { + return err + } + + o[k] = v + return nil + }) + m.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoI32Map_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI32Map_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI32Map_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI32Map_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TMap { + v.Arg, err = _Map_I32_BarResponse_Read(field.Value.GetMap()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoI32Map_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI32Map_Args +// struct. +func (v *Echo_EchoI32Map_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoI32Map_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Map_I32_BarResponse_Equals(lhs, rhs map[int32]*BarResponse) bool { + if len(lhs) != len(rhs) { + return false + } + + for lk, lv := range lhs { + rv, ok := rhs[lk] + if !ok { + return false + } + if !lv.Equals(rv) { + return false + } + } + return true +} + +// Equals returns true if all the fields of this Echo_EchoI32Map_Args match the +// provided Echo_EchoI32Map_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoI32Map_Args) Equals(rhs *Echo_EchoI32Map_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Map_I32_BarResponse_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _Map_I32_BarResponse_Item_Zapper struct { + Key int32 + Value *BarResponse +} + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Map_I32_BarResponse_Item_Zapper. +func (v _Map_I32_BarResponse_Item_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + enc.AddInt32("key", v.Key) + err = multierr.Append(err, enc.AddObject("value", v.Value)) + return err +} + +type _Map_I32_BarResponse_Zapper map[int32]*BarResponse + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Map_I32_BarResponse_Zapper. +func (m _Map_I32_BarResponse_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for k, v := range m { + err = multierr.Append(err, enc.AppendObject(_Map_I32_BarResponse_Item_Zapper{Key: k, Value: v})) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI32Map_Args. +func (v *Echo_EchoI32Map_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_Map_I32_BarResponse_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI32Map_Args) GetArg() (o map[int32]*BarResponse) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoI32Map_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoI32Map" for this struct. +func (v *Echo_EchoI32Map_Args) MethodName() string { + return "echoI32Map" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoI32Map_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoI32Map_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoI32Map +// function. +var Echo_EchoI32Map_Helper = struct { + // Args accepts the parameters of echoI32Map in-order and returns + // the arguments struct for the function. + Args func( + arg map[int32]*BarResponse, + ) *Echo_EchoI32Map_Args + + // IsException returns true if the given error can be thrown + // by echoI32Map. + // + // An error can be thrown by echoI32Map only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoI32Map + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoI32Map into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoI32Map + // + // value, err := echoI32Map(args) + // result, err := Echo_EchoI32Map_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoI32Map: %v", err) + // } + // serialize(result) + WrapResponse func(map[int32]*BarResponse, error) (*Echo_EchoI32Map_Result, error) + + // UnwrapResponse takes the result struct for echoI32Map + // and returns the value or error returned by it. + // + // The error is non-nil only if echoI32Map threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoI32Map_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoI32Map_Result) (map[int32]*BarResponse, error) +}{} + +func init() { + Echo_EchoI32Map_Helper.Args = func( + arg map[int32]*BarResponse, + ) *Echo_EchoI32Map_Args { + return &Echo_EchoI32Map_Args{ + Arg: arg, + } + } + + Echo_EchoI32Map_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoI32Map_Helper.WrapResponse = func(success map[int32]*BarResponse, err error) (*Echo_EchoI32Map_Result, error) { + if err == nil { + return &Echo_EchoI32Map_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoI32Map_Helper.UnwrapResponse = func(result *Echo_EchoI32Map_Result) (success map[int32]*BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoI32Map_Result represents the result of a Echo.echoI32Map function call. +// +// The result of a echoI32Map execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoI32Map_Result struct { + // Value returned by echoI32Map after a successful execution. + Success map[int32]*BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoI32Map_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI32Map_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueMap(_Map_I32_BarResponse_MapItemList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoI32Map_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI32Map_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI32Map_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI32Map_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI32Map_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TMap { + v.Success, err = _Map_I32_BarResponse_Read(field.Value.GetMap()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoI32Map_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI32Map_Result +// struct. +func (v *Echo_EchoI32Map_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoI32Map_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI32Map_Result match the +// provided Echo_EchoI32Map_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoI32Map_Result) Equals(rhs *Echo_EchoI32Map_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _Map_I32_BarResponse_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI32Map_Result. +func (v *Echo_EchoI32Map_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_Map_I32_BarResponse_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI32Map_Result) GetSuccess() (o map[int32]*BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoI32Map_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoI32Map" for this struct. +func (v *Echo_EchoI32Map_Result) MethodName() string { + return "echoI32Map" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoI32Map_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoI64_Args represents the arguments for the Echo.echoI64 function. +// +// The arguments for echoI64 are sent and received over the wire as this struct. +type Echo_EchoI64_Args struct { + Arg int64 `json:"arg,required"` +} + +// ToWire translates a Echo_EchoI64_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI64_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueI64(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI64_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI64_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI64_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI64_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TI64 { + v.Arg, err = field.Value.GetI64(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoI64_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI64_Args +// struct. +func (v *Echo_EchoI64_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoI64_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI64_Args match the +// provided Echo_EchoI64_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoI64_Args) Equals(rhs *Echo_EchoI64_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI64_Args. +func (v *Echo_EchoI64_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddInt64("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI64_Args) GetArg() (o int64) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoI64" for this struct. +func (v *Echo_EchoI64_Args) MethodName() string { + return "echoI64" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoI64_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoI64_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoI64 +// function. +var Echo_EchoI64_Helper = struct { + // Args accepts the parameters of echoI64 in-order and returns + // the arguments struct for the function. + Args func( + arg int64, + ) *Echo_EchoI64_Args + + // IsException returns true if the given error can be thrown + // by echoI64. + // + // An error can be thrown by echoI64 only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoI64 + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoI64 into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoI64 + // + // value, err := echoI64(args) + // result, err := Echo_EchoI64_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoI64: %v", err) + // } + // serialize(result) + WrapResponse func(int64, error) (*Echo_EchoI64_Result, error) + + // UnwrapResponse takes the result struct for echoI64 + // and returns the value or error returned by it. + // + // The error is non-nil only if echoI64 threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoI64_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoI64_Result) (int64, error) +}{} + +func init() { + Echo_EchoI64_Helper.Args = func( + arg int64, + ) *Echo_EchoI64_Args { + return &Echo_EchoI64_Args{ + Arg: arg, + } + } + + Echo_EchoI64_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoI64_Helper.WrapResponse = func(success int64, err error) (*Echo_EchoI64_Result, error) { + if err == nil { + return &Echo_EchoI64_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoI64_Helper.UnwrapResponse = func(result *Echo_EchoI64_Result) (success int64, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoI64_Result represents the result of a Echo.echoI64 function call. +// +// The result of a echoI64 execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoI64_Result struct { + // Value returned by echoI64 after a successful execution. + Success *int64 `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoI64_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI64_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueI64(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoI64_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI64_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI64_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI64_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI64_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TI64 { + var x int64 + x, err = field.Value.GetI64(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoI64_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI64_Result +// struct. +func (v *Echo_EchoI64_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoI64_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI64_Result match the +// provided Echo_EchoI64_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoI64_Result) Equals(rhs *Echo_EchoI64_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_I64_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI64_Result. +func (v *Echo_EchoI64_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddInt64("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI64_Result) GetSuccess() (o int64) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoI64_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoI64" for this struct. +func (v *Echo_EchoI64_Result) MethodName() string { + return "echoI64" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoI64_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoI8_Args represents the arguments for the Echo.echoI8 function. +// +// The arguments for echoI8 are sent and received over the wire as this struct. +type Echo_EchoI8_Args struct { + Arg int8 `json:"arg,required"` +} + +// ToWire translates a Echo_EchoI8_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI8_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueI8(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI8_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI8_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI8_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI8_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TI8 { + v.Arg, err = field.Value.GetI8(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoI8_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI8_Args +// struct. +func (v *Echo_EchoI8_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoI8_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI8_Args match the +// provided Echo_EchoI8_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoI8_Args) Equals(rhs *Echo_EchoI8_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI8_Args. +func (v *Echo_EchoI8_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddInt8("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI8_Args) GetArg() (o int8) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoI8" for this struct. +func (v *Echo_EchoI8_Args) MethodName() string { + return "echoI8" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoI8_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoI8_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoI8 +// function. +var Echo_EchoI8_Helper = struct { + // Args accepts the parameters of echoI8 in-order and returns + // the arguments struct for the function. + Args func( + arg int8, + ) *Echo_EchoI8_Args + + // IsException returns true if the given error can be thrown + // by echoI8. + // + // An error can be thrown by echoI8 only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoI8 + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoI8 into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoI8 + // + // value, err := echoI8(args) + // result, err := Echo_EchoI8_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoI8: %v", err) + // } + // serialize(result) + WrapResponse func(int8, error) (*Echo_EchoI8_Result, error) + + // UnwrapResponse takes the result struct for echoI8 + // and returns the value or error returned by it. + // + // The error is non-nil only if echoI8 threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoI8_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoI8_Result) (int8, error) +}{} + +func init() { + Echo_EchoI8_Helper.Args = func( + arg int8, + ) *Echo_EchoI8_Args { + return &Echo_EchoI8_Args{ + Arg: arg, + } + } + + Echo_EchoI8_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoI8_Helper.WrapResponse = func(success int8, err error) (*Echo_EchoI8_Result, error) { + if err == nil { + return &Echo_EchoI8_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoI8_Helper.UnwrapResponse = func(result *Echo_EchoI8_Result) (success int8, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoI8_Result represents the result of a Echo.echoI8 function call. +// +// The result of a echoI8 execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoI8_Result struct { + // Value returned by echoI8 after a successful execution. + Success *int8 `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoI8_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoI8_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueI8(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoI8_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoI8_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoI8_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoI8_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoI8_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TI8 { + var x int8 + x, err = field.Value.GetI8(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoI8_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoI8_Result +// struct. +func (v *Echo_EchoI8_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoI8_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoI8_Result match the +// provided Echo_EchoI8_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoI8_Result) Equals(rhs *Echo_EchoI8_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Byte_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoI8_Result. +func (v *Echo_EchoI8_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddInt8("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoI8_Result) GetSuccess() (o int8) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoI8_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoI8" for this struct. +func (v *Echo_EchoI8_Result) MethodName() string { + return "echoI8" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoI8_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoString_Args represents the arguments for the Echo.echoString function. +// +// The arguments for echoString are sent and received over the wire as this struct. +type Echo_EchoString_Args struct { + Arg string `json:"arg,required"` +} + +// ToWire translates a Echo_EchoString_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoString_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Arg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoString_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoString_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoString_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoString_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Arg, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoString_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoString_Args +// struct. +func (v *Echo_EchoString_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoString_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoString_Args match the +// provided Echo_EchoString_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoString_Args) Equals(rhs *Echo_EchoString_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoString_Args. +func (v *Echo_EchoString_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("arg", v.Arg) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoString_Args) GetArg() (o string) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoString" for this struct. +func (v *Echo_EchoString_Args) MethodName() string { + return "echoString" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoString_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoString_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoString +// function. +var Echo_EchoString_Helper = struct { + // Args accepts the parameters of echoString in-order and returns + // the arguments struct for the function. + Args func( + arg string, + ) *Echo_EchoString_Args + + // IsException returns true if the given error can be thrown + // by echoString. + // + // An error can be thrown by echoString only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoString + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoString into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoString + // + // value, err := echoString(args) + // result, err := Echo_EchoString_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoString: %v", err) + // } + // serialize(result) + WrapResponse func(string, error) (*Echo_EchoString_Result, error) + + // UnwrapResponse takes the result struct for echoString + // and returns the value or error returned by it. + // + // The error is non-nil only if echoString threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoString_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoString_Result) (string, error) +}{} + +func init() { + Echo_EchoString_Helper.Args = func( + arg string, + ) *Echo_EchoString_Args { + return &Echo_EchoString_Args{ + Arg: arg, + } + } + + Echo_EchoString_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoString_Helper.WrapResponse = func(success string, err error) (*Echo_EchoString_Result, error) { + if err == nil { + return &Echo_EchoString_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoString_Helper.UnwrapResponse = func(result *Echo_EchoString_Result) (success string, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoString_Result represents the result of a Echo.echoString function call. +// +// The result of a echoString execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoString_Result struct { + // Value returned by echoString after a successful execution. + Success *string `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoString_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoString_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueString(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoString_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoString_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoString_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoString_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoString_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoString_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoString_Result +// struct. +func (v *Echo_EchoString_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoString_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoString_Result match the +// provided Echo_EchoString_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoString_Result) Equals(rhs *Echo_EchoString_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoString_Result. +func (v *Echo_EchoString_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoString_Result) GetSuccess() (o string) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoString_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoString" for this struct. +func (v *Echo_EchoString_Result) MethodName() string { + return "echoString" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoString_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStringList_Args represents the arguments for the Echo.echoStringList function. +// +// The arguments for echoStringList are sent and received over the wire as this struct. +type Echo_EchoStringList_Args struct { + Arg []string `json:"arg,required"` +} + +// ToWire translates a Echo_EchoStringList_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringList_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStringList_Args is required") + } + w, err = wire.NewValueList(_List_String_ValueList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStringList_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringList_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringList_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringList_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TList { + v.Arg, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStringList_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringList_Args +// struct. +func (v *Echo_EchoStringList_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStringList_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStringList_Args match the +// provided Echo_EchoStringList_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringList_Args) Equals(rhs *Echo_EchoStringList_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_List_String_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringList_Args. +func (v *Echo_EchoStringList_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_List_String_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringList_Args) GetArg() (o []string) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStringList_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStringList" for this struct. +func (v *Echo_EchoStringList_Args) MethodName() string { + return "echoStringList" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStringList_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStringList_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStringList +// function. +var Echo_EchoStringList_Helper = struct { + // Args accepts the parameters of echoStringList in-order and returns + // the arguments struct for the function. + Args func( + arg []string, + ) *Echo_EchoStringList_Args + + // IsException returns true if the given error can be thrown + // by echoStringList. + // + // An error can be thrown by echoStringList only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStringList + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStringList into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStringList + // + // value, err := echoStringList(args) + // result, err := Echo_EchoStringList_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStringList: %v", err) + // } + // serialize(result) + WrapResponse func([]string, error) (*Echo_EchoStringList_Result, error) + + // UnwrapResponse takes the result struct for echoStringList + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStringList threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStringList_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStringList_Result) ([]string, error) +}{} + +func init() { + Echo_EchoStringList_Helper.Args = func( + arg []string, + ) *Echo_EchoStringList_Args { + return &Echo_EchoStringList_Args{ + Arg: arg, + } + } + + Echo_EchoStringList_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStringList_Helper.WrapResponse = func(success []string, err error) (*Echo_EchoStringList_Result, error) { + if err == nil { + return &Echo_EchoStringList_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStringList_Helper.UnwrapResponse = func(result *Echo_EchoStringList_Result) (success []string, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStringList_Result represents the result of a Echo.echoStringList function call. +// +// The result of a echoStringList execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStringList_Result struct { + // Value returned by echoStringList after a successful execution. + Success []string `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStringList_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringList_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueList(_List_String_ValueList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStringList_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStringList_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringList_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringList_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringList_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TList { + v.Success, err = _List_String_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStringList_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringList_Result +// struct. +func (v *Echo_EchoStringList_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStringList_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStringList_Result match the +// provided Echo_EchoStringList_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringList_Result) Equals(rhs *Echo_EchoStringList_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _List_String_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringList_Result. +func (v *Echo_EchoStringList_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_List_String_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringList_Result) GetSuccess() (o []string) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStringList_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStringList" for this struct. +func (v *Echo_EchoStringList_Result) MethodName() string { + return "echoStringList" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStringList_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStringMap_Args represents the arguments for the Echo.echoStringMap function. +// +// The arguments for echoStringMap are sent and received over the wire as this struct. +type Echo_EchoStringMap_Args struct { + Arg map[string]*BarResponse `json:"arg,required"` +} + +type _Map_String_BarResponse_MapItemList map[string]*BarResponse + +func (m _Map_String_BarResponse_MapItemList) ForEach(f func(wire.MapItem) error) error { + for k, v := range m { + if v == nil { + return fmt.Errorf("invalid [%v]: value is nil", k) + } + kw, err := wire.NewValueString(k), error(nil) + if err != nil { + return err + } + + vw, err := v.ToWire() + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_String_BarResponse_MapItemList) Size() int { + return len(m) +} + +func (_Map_String_BarResponse_MapItemList) KeyType() wire.Type { + return wire.TBinary +} + +func (_Map_String_BarResponse_MapItemList) ValueType() wire.Type { + return wire.TStruct +} + +func (_Map_String_BarResponse_MapItemList) Close() {} + +// ToWire translates a Echo_EchoStringMap_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringMap_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStringMap_Args is required") + } + w, err = wire.NewValueMap(_Map_String_BarResponse_MapItemList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Map_String_BarResponse_Read(m wire.MapItemList) (map[string]*BarResponse, error) { + if m.KeyType() != wire.TBinary { + return nil, nil + } + + if m.ValueType() != wire.TStruct { + return nil, nil + } + + o := make(map[string]*BarResponse, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := x.Key.GetString(), error(nil) + if err != nil { + return err + } + + v, err := _BarResponse_Read(x.Value) + if err != nil { + return err + } + + o[k] = v + return nil + }) + m.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoStringMap_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringMap_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringMap_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringMap_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TMap { + v.Arg, err = _Map_String_BarResponse_Read(field.Value.GetMap()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStringMap_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringMap_Args +// struct. +func (v *Echo_EchoStringMap_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStringMap_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Map_String_BarResponse_Equals(lhs, rhs map[string]*BarResponse) bool { + if len(lhs) != len(rhs) { + return false + } + + for lk, lv := range lhs { + rv, ok := rhs[lk] + if !ok { + return false + } + if !lv.Equals(rv) { + return false + } + } + return true +} + +// Equals returns true if all the fields of this Echo_EchoStringMap_Args match the +// provided Echo_EchoStringMap_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringMap_Args) Equals(rhs *Echo_EchoStringMap_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Map_String_BarResponse_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _Map_String_BarResponse_Zapper map[string]*BarResponse + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of _Map_String_BarResponse_Zapper. +func (m _Map_String_BarResponse_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + for k, v := range m { + err = multierr.Append(err, enc.AddObject((string)(k), v)) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringMap_Args. +func (v *Echo_EchoStringMap_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddObject("arg", (_Map_String_BarResponse_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringMap_Args) GetArg() (o map[string]*BarResponse) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStringMap_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStringMap" for this struct. +func (v *Echo_EchoStringMap_Args) MethodName() string { + return "echoStringMap" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStringMap_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStringMap_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStringMap +// function. +var Echo_EchoStringMap_Helper = struct { + // Args accepts the parameters of echoStringMap in-order and returns + // the arguments struct for the function. + Args func( + arg map[string]*BarResponse, + ) *Echo_EchoStringMap_Args + + // IsException returns true if the given error can be thrown + // by echoStringMap. + // + // An error can be thrown by echoStringMap only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStringMap + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStringMap into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStringMap + // + // value, err := echoStringMap(args) + // result, err := Echo_EchoStringMap_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStringMap: %v", err) + // } + // serialize(result) + WrapResponse func(map[string]*BarResponse, error) (*Echo_EchoStringMap_Result, error) + + // UnwrapResponse takes the result struct for echoStringMap + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStringMap threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStringMap_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStringMap_Result) (map[string]*BarResponse, error) +}{} + +func init() { + Echo_EchoStringMap_Helper.Args = func( + arg map[string]*BarResponse, + ) *Echo_EchoStringMap_Args { + return &Echo_EchoStringMap_Args{ + Arg: arg, + } + } + + Echo_EchoStringMap_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStringMap_Helper.WrapResponse = func(success map[string]*BarResponse, err error) (*Echo_EchoStringMap_Result, error) { + if err == nil { + return &Echo_EchoStringMap_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStringMap_Helper.UnwrapResponse = func(result *Echo_EchoStringMap_Result) (success map[string]*BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStringMap_Result represents the result of a Echo.echoStringMap function call. +// +// The result of a echoStringMap execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStringMap_Result struct { + // Value returned by echoStringMap after a successful execution. + Success map[string]*BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStringMap_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringMap_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueMap(_Map_String_BarResponse_MapItemList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStringMap_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStringMap_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringMap_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringMap_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringMap_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TMap { + v.Success, err = _Map_String_BarResponse_Read(field.Value.GetMap()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStringMap_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringMap_Result +// struct. +func (v *Echo_EchoStringMap_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStringMap_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStringMap_Result match the +// provided Echo_EchoStringMap_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringMap_Result) Equals(rhs *Echo_EchoStringMap_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _Map_String_BarResponse_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringMap_Result. +func (v *Echo_EchoStringMap_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddObject("success", (_Map_String_BarResponse_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringMap_Result) GetSuccess() (o map[string]*BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStringMap_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStringMap" for this struct. +func (v *Echo_EchoStringMap_Result) MethodName() string { + return "echoStringMap" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStringMap_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStringSet_Args represents the arguments for the Echo.echoStringSet function. +// +// The arguments for echoStringSet are sent and received over the wire as this struct. +type Echo_EchoStringSet_Args struct { + Arg map[string]struct{} `json:"arg,required"` +} + +type _Set_String_mapType_ValueList map[string]struct{} + +func (v _Set_String_mapType_ValueList) ForEach(f func(wire.Value) error) error { + for x := range v { + w, err := wire.NewValueString(x), error(nil) + if err != nil { + return err + } + + if err := f(w); err != nil { + return err + } + } + return nil +} + +func (v _Set_String_mapType_ValueList) Size() int { + return len(v) +} + +func (_Set_String_mapType_ValueList) ValueType() wire.Type { + return wire.TBinary +} + +func (_Set_String_mapType_ValueList) Close() {} + +// ToWire translates a Echo_EchoStringSet_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringSet_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStringSet_Args is required") + } + w, err = wire.NewValueSet(_Set_String_mapType_ValueList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Set_String_mapType_Read(s wire.ValueList) (map[string]struct{}, error) { + if s.ValueType() != wire.TBinary { + return nil, nil + } + + o := make(map[string]struct{}, s.Size()) + err := s.ForEach(func(x wire.Value) error { + i, err := x.GetString(), error(nil) + if err != nil { + return err + } + + o[i] = struct{}{} + return nil + }) + s.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoStringSet_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringSet_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringSet_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringSet_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TSet { + v.Arg, err = _Set_String_mapType_Read(field.Value.GetSet()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStringSet_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringSet_Args +// struct. +func (v *Echo_EchoStringSet_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStringSet_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Set_String_mapType_Equals(lhs, rhs map[string]struct{}) bool { + if len(lhs) != len(rhs) { + return false + } + + for x := range rhs { + if _, ok := lhs[x]; !ok { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this Echo_EchoStringSet_Args match the +// provided Echo_EchoStringSet_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringSet_Args) Equals(rhs *Echo_EchoStringSet_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Set_String_mapType_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _Set_String_mapType_Zapper map[string]struct{} + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Set_String_mapType_Zapper. +func (s _Set_String_mapType_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for v := range s { + enc.AppendString(v) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringSet_Args. +func (v *Echo_EchoStringSet_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_Set_String_mapType_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringSet_Args) GetArg() (o map[string]struct{}) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStringSet_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStringSet" for this struct. +func (v *Echo_EchoStringSet_Args) MethodName() string { + return "echoStringSet" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStringSet_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStringSet_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStringSet +// function. +var Echo_EchoStringSet_Helper = struct { + // Args accepts the parameters of echoStringSet in-order and returns + // the arguments struct for the function. + Args func( + arg map[string]struct{}, + ) *Echo_EchoStringSet_Args + + // IsException returns true if the given error can be thrown + // by echoStringSet. + // + // An error can be thrown by echoStringSet only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStringSet + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStringSet into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStringSet + // + // value, err := echoStringSet(args) + // result, err := Echo_EchoStringSet_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStringSet: %v", err) + // } + // serialize(result) + WrapResponse func(map[string]struct{}, error) (*Echo_EchoStringSet_Result, error) + + // UnwrapResponse takes the result struct for echoStringSet + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStringSet threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStringSet_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStringSet_Result) (map[string]struct{}, error) +}{} + +func init() { + Echo_EchoStringSet_Helper.Args = func( + arg map[string]struct{}, + ) *Echo_EchoStringSet_Args { + return &Echo_EchoStringSet_Args{ + Arg: arg, + } + } + + Echo_EchoStringSet_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStringSet_Helper.WrapResponse = func(success map[string]struct{}, err error) (*Echo_EchoStringSet_Result, error) { + if err == nil { + return &Echo_EchoStringSet_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStringSet_Helper.UnwrapResponse = func(result *Echo_EchoStringSet_Result) (success map[string]struct{}, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStringSet_Result represents the result of a Echo.echoStringSet function call. +// +// The result of a echoStringSet execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStringSet_Result struct { + // Value returned by echoStringSet after a successful execution. + Success map[string]struct{} `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStringSet_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStringSet_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueSet(_Set_String_mapType_ValueList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStringSet_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStringSet_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStringSet_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStringSet_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStringSet_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TSet { + v.Success, err = _Set_String_mapType_Read(field.Value.GetSet()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStringSet_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStringSet_Result +// struct. +func (v *Echo_EchoStringSet_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStringSet_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStringSet_Result match the +// provided Echo_EchoStringSet_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStringSet_Result) Equals(rhs *Echo_EchoStringSet_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _Set_String_mapType_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStringSet_Result. +func (v *Echo_EchoStringSet_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_Set_String_mapType_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStringSet_Result) GetSuccess() (o map[string]struct{}) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStringSet_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStringSet" for this struct. +func (v *Echo_EchoStringSet_Result) MethodName() string { + return "echoStringSet" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStringSet_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStructList_Args represents the arguments for the Echo.echoStructList function. +// +// The arguments for echoStructList are sent and received over the wire as this struct. +type Echo_EchoStructList_Args struct { + Arg []*BarResponse `json:"arg,required"` +} + +type _List_BarResponse_ValueList []*BarResponse + +func (v _List_BarResponse_ValueList) ForEach(f func(wire.Value) error) error { + for i, x := range v { + if x == nil { + return fmt.Errorf("invalid [%v]: value is nil", i) + } + w, err := x.ToWire() + if err != nil { + return err + } + err = f(w) + if err != nil { + return err + } + } + return nil +} + +func (v _List_BarResponse_ValueList) Size() int { + return len(v) +} + +func (_List_BarResponse_ValueList) ValueType() wire.Type { + return wire.TStruct +} + +func (_List_BarResponse_ValueList) Close() {} + +// ToWire translates a Echo_EchoStructList_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructList_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStructList_Args is required") + } + w, err = wire.NewValueList(_List_BarResponse_ValueList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _List_BarResponse_Read(l wire.ValueList) ([]*BarResponse, error) { + if l.ValueType() != wire.TStruct { + return nil, nil + } + + o := make([]*BarResponse, 0, l.Size()) + err := l.ForEach(func(x wire.Value) error { + i, err := _BarResponse_Read(x) + if err != nil { + return err + } + o = append(o, i) + return nil + }) + l.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoStructList_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructList_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructList_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructList_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TList { + v.Arg, err = _List_BarResponse_Read(field.Value.GetList()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStructList_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructList_Args +// struct. +func (v *Echo_EchoStructList_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStructList_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _List_BarResponse_Equals(lhs, rhs []*BarResponse) bool { + if len(lhs) != len(rhs) { + return false + } + + for i, lv := range lhs { + rv := rhs[i] + if !lv.Equals(rv) { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this Echo_EchoStructList_Args match the +// provided Echo_EchoStructList_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructList_Args) Equals(rhs *Echo_EchoStructList_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_List_BarResponse_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _List_BarResponse_Zapper []*BarResponse + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _List_BarResponse_Zapper. +func (l _List_BarResponse_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range l { + err = multierr.Append(err, enc.AppendObject(v)) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructList_Args. +func (v *Echo_EchoStructList_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_List_BarResponse_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructList_Args) GetArg() (o []*BarResponse) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStructList_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStructList" for this struct. +func (v *Echo_EchoStructList_Args) MethodName() string { + return "echoStructList" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStructList_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStructList_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStructList +// function. +var Echo_EchoStructList_Helper = struct { + // Args accepts the parameters of echoStructList in-order and returns + // the arguments struct for the function. + Args func( + arg []*BarResponse, + ) *Echo_EchoStructList_Args + + // IsException returns true if the given error can be thrown + // by echoStructList. + // + // An error can be thrown by echoStructList only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStructList + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStructList into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStructList + // + // value, err := echoStructList(args) + // result, err := Echo_EchoStructList_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStructList: %v", err) + // } + // serialize(result) + WrapResponse func([]*BarResponse, error) (*Echo_EchoStructList_Result, error) + + // UnwrapResponse takes the result struct for echoStructList + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStructList threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStructList_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStructList_Result) ([]*BarResponse, error) +}{} + +func init() { + Echo_EchoStructList_Helper.Args = func( + arg []*BarResponse, + ) *Echo_EchoStructList_Args { + return &Echo_EchoStructList_Args{ + Arg: arg, + } + } + + Echo_EchoStructList_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStructList_Helper.WrapResponse = func(success []*BarResponse, err error) (*Echo_EchoStructList_Result, error) { + if err == nil { + return &Echo_EchoStructList_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStructList_Helper.UnwrapResponse = func(result *Echo_EchoStructList_Result) (success []*BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStructList_Result represents the result of a Echo.echoStructList function call. +// +// The result of a echoStructList execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStructList_Result struct { + // Value returned by echoStructList after a successful execution. + Success []*BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStructList_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructList_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueList(_List_BarResponse_ValueList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStructList_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStructList_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructList_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructList_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructList_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TList { + v.Success, err = _List_BarResponse_Read(field.Value.GetList()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStructList_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructList_Result +// struct. +func (v *Echo_EchoStructList_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStructList_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStructList_Result match the +// provided Echo_EchoStructList_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructList_Result) Equals(rhs *Echo_EchoStructList_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _List_BarResponse_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructList_Result. +func (v *Echo_EchoStructList_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_List_BarResponse_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructList_Result) GetSuccess() (o []*BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStructList_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStructList" for this struct. +func (v *Echo_EchoStructList_Result) MethodName() string { + return "echoStructList" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStructList_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStructMap_Args represents the arguments for the Echo.echoStructMap function. +// +// The arguments for echoStructMap are sent and received over the wire as this struct. +type Echo_EchoStructMap_Args struct { + Arg []struct { + Key *BarResponse + Value string + } `json:"arg,required"` +} + +type _Map_BarResponse_String_MapItemList []struct { + Key *BarResponse + Value string +} + +func (m _Map_BarResponse_String_MapItemList) ForEach(f func(wire.MapItem) error) error { + for _, i := range m { + k := i.Key + v := i.Value + if k == nil { + return fmt.Errorf("invalid map key: value is nil") + } + kw, err := k.ToWire() + if err != nil { + return err + } + + vw, err := wire.NewValueString(v), error(nil) + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_BarResponse_String_MapItemList) Size() int { + return len(m) +} + +func (_Map_BarResponse_String_MapItemList) KeyType() wire.Type { + return wire.TStruct +} + +func (_Map_BarResponse_String_MapItemList) ValueType() wire.Type { + return wire.TBinary +} + +func (_Map_BarResponse_String_MapItemList) Close() {} + +// ToWire translates a Echo_EchoStructMap_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructMap_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStructMap_Args is required") + } + w, err = wire.NewValueMap(_Map_BarResponse_String_MapItemList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Map_BarResponse_String_Read(m wire.MapItemList) ([]struct { + Key *BarResponse + Value string +}, error) { + if m.KeyType() != wire.TStruct { + return nil, nil + } + + if m.ValueType() != wire.TBinary { + return nil, nil + } + + o := make([]struct { + Key *BarResponse + Value string + }, 0, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := _BarResponse_Read(x.Key) + if err != nil { + return err + } + + v, err := x.Value.GetString(), error(nil) + if err != nil { + return err + } + + o = append(o, struct { + Key *BarResponse + Value string + }{k, v}) + return nil + }) + m.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoStructMap_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructMap_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructMap_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructMap_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TMap { + v.Arg, err = _Map_BarResponse_String_Read(field.Value.GetMap()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStructMap_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructMap_Args +// struct. +func (v *Echo_EchoStructMap_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStructMap_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Map_BarResponse_String_Equals(lhs, rhs []struct { + Key *BarResponse + Value string +}) bool { + if len(lhs) != len(rhs) { + return false + } + + for _, i := range lhs { + lk := i.Key + lv := i.Value + ok := false + for _, j := range rhs { + rk := j.Key + rv := j.Value + if !lk.Equals(rk) { + continue + } + + if !(lv == rv) { + return false + } + ok = true + break + } + + if !ok { + return false + } + } + return true +} + +// Equals returns true if all the fields of this Echo_EchoStructMap_Args match the +// provided Echo_EchoStructMap_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructMap_Args) Equals(rhs *Echo_EchoStructMap_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Map_BarResponse_String_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _Map_BarResponse_String_Item_Zapper struct { + Key *BarResponse + Value string +} + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Map_BarResponse_String_Item_Zapper. +func (v _Map_BarResponse_String_Item_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + err = multierr.Append(err, enc.AddObject("key", v.Key)) + enc.AddString("value", v.Value) + return err +} + +type _Map_BarResponse_String_Zapper []struct { + Key *BarResponse + Value string +} + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Map_BarResponse_String_Zapper. +func (m _Map_BarResponse_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, i := range m { + k := i.Key + v := i.Value + err = multierr.Append(err, enc.AppendObject(_Map_BarResponse_String_Item_Zapper{Key: k, Value: v})) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructMap_Args. +func (v *Echo_EchoStructMap_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_Map_BarResponse_String_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructMap_Args) GetArg() (o []struct { + Key *BarResponse + Value string +}) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStructMap_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStructMap" for this struct. +func (v *Echo_EchoStructMap_Args) MethodName() string { + return "echoStructMap" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStructMap_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStructMap_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStructMap +// function. +var Echo_EchoStructMap_Helper = struct { + // Args accepts the parameters of echoStructMap in-order and returns + // the arguments struct for the function. + Args func( + arg []struct { + Key *BarResponse + Value string + }, + ) *Echo_EchoStructMap_Args + + // IsException returns true if the given error can be thrown + // by echoStructMap. + // + // An error can be thrown by echoStructMap only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStructMap + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStructMap into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStructMap + // + // value, err := echoStructMap(args) + // result, err := Echo_EchoStructMap_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStructMap: %v", err) + // } + // serialize(result) + WrapResponse func([]struct { + Key *BarResponse + Value string + }, error) (*Echo_EchoStructMap_Result, error) + + // UnwrapResponse takes the result struct for echoStructMap + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStructMap threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStructMap_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStructMap_Result) ([]struct { + Key *BarResponse + Value string + }, error) +}{} + +func init() { + Echo_EchoStructMap_Helper.Args = func( + arg []struct { + Key *BarResponse + Value string + }, + ) *Echo_EchoStructMap_Args { + return &Echo_EchoStructMap_Args{ + Arg: arg, + } + } + + Echo_EchoStructMap_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStructMap_Helper.WrapResponse = func(success []struct { + Key *BarResponse + Value string + }, err error) (*Echo_EchoStructMap_Result, error) { + if err == nil { + return &Echo_EchoStructMap_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStructMap_Helper.UnwrapResponse = func(result *Echo_EchoStructMap_Result) (success []struct { + Key *BarResponse + Value string + }, err error) { + if result.Success != nil { + success = result.Success + return + } + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStructMap_Result represents the result of a Echo.echoStructMap function call. +// +// The result of a echoStructMap execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStructMap_Result struct { + // Value returned by echoStructMap after a successful execution. + Success []struct { + Key *BarResponse + Value string + } `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStructMap_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructMap_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueMap(_Map_BarResponse_String_MapItemList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStructMap_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStructMap_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructMap_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructMap_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructMap_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TMap { + v.Success, err = _Map_BarResponse_String_Read(field.Value.GetMap()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStructMap_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructMap_Result +// struct. +func (v *Echo_EchoStructMap_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStructMap_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStructMap_Result match the +// provided Echo_EchoStructMap_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructMap_Result) Equals(rhs *Echo_EchoStructMap_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _Map_BarResponse_String_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructMap_Result. +func (v *Echo_EchoStructMap_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_Map_BarResponse_String_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructMap_Result) GetSuccess() (o []struct { + Key *BarResponse + Value string +}) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStructMap_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStructMap" for this struct. +func (v *Echo_EchoStructMap_Result) MethodName() string { + return "echoStructMap" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStructMap_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoStructSet_Args represents the arguments for the Echo.echoStructSet function. +// +// The arguments for echoStructSet are sent and received over the wire as this struct. +type Echo_EchoStructSet_Args struct { + Arg []*BarResponse `json:"arg,required"` +} + +type _Set_BarResponse_sliceType_ValueList []*BarResponse + +func (v _Set_BarResponse_sliceType_ValueList) ForEach(f func(wire.Value) error) error { + for _, x := range v { + if x == nil { + return fmt.Errorf("invalid set item: value is nil") + } + w, err := x.ToWire() + if err != nil { + return err + } + + if err := f(w); err != nil { + return err + } + } + return nil +} + +func (v _Set_BarResponse_sliceType_ValueList) Size() int { + return len(v) +} + +func (_Set_BarResponse_sliceType_ValueList) ValueType() wire.Type { + return wire.TStruct +} + +func (_Set_BarResponse_sliceType_ValueList) Close() {} + +// ToWire translates a Echo_EchoStructSet_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructSet_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Arg == nil { + return w, errors.New("field Arg of Echo_EchoStructSet_Args is required") + } + w, err = wire.NewValueSet(_Set_BarResponse_sliceType_ValueList(v.Arg)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Set_BarResponse_sliceType_Read(s wire.ValueList) ([]*BarResponse, error) { + if s.ValueType() != wire.TStruct { + return nil, nil + } + + o := make([]*BarResponse, 0, s.Size()) + err := s.ForEach(func(x wire.Value) error { + i, err := _BarResponse_Read(x) + if err != nil { + return err + } + + o = append(o, i) + return nil + }) + s.Close() + return o, err +} + +// FromWire deserializes a Echo_EchoStructSet_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructSet_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructSet_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructSet_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TSet { + v.Arg, err = _Set_BarResponse_sliceType_Read(field.Value.GetSet()) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoStructSet_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructSet_Args +// struct. +func (v *Echo_EchoStructSet_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoStructSet_Args{%v}", strings.Join(fields[:i], ", ")) +} + +func _Set_BarResponse_sliceType_Equals(lhs, rhs []*BarResponse) bool { + if len(lhs) != len(rhs) { + return false + } + + for _, x := range lhs { + ok := false + for _, y := range rhs { + if x.Equals(y) { + ok = true + break + } + } + if !ok { + return false + } + } + + return true +} + +// Equals returns true if all the fields of this Echo_EchoStructSet_Args match the +// provided Echo_EchoStructSet_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructSet_Args) Equals(rhs *Echo_EchoStructSet_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_Set_BarResponse_sliceType_Equals(v.Arg, rhs.Arg) { + return false + } + + return true +} + +type _Set_BarResponse_sliceType_Zapper []*BarResponse + +// MarshalLogArray implements zapcore.ArrayMarshaler, enabling +// fast logging of _Set_BarResponse_sliceType_Zapper. +func (s _Set_BarResponse_sliceType_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) (err error) { + for _, v := range s { + err = multierr.Append(err, enc.AppendObject(v)) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructSet_Args. +func (v *Echo_EchoStructSet_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + err = multierr.Append(err, enc.AddArray("arg", (_Set_BarResponse_sliceType_Zapper)(v.Arg))) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructSet_Args) GetArg() (o []*BarResponse) { + if v != nil { + o = v.Arg + } + return +} + +// IsSetArg returns true if Arg is not nil. +func (v *Echo_EchoStructSet_Args) IsSetArg() bool { + return v != nil && v.Arg != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoStructSet" for this struct. +func (v *Echo_EchoStructSet_Args) MethodName() string { + return "echoStructSet" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoStructSet_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoStructSet_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoStructSet +// function. +var Echo_EchoStructSet_Helper = struct { + // Args accepts the parameters of echoStructSet in-order and returns + // the arguments struct for the function. + Args func( + arg []*BarResponse, + ) *Echo_EchoStructSet_Args + + // IsException returns true if the given error can be thrown + // by echoStructSet. + // + // An error can be thrown by echoStructSet only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoStructSet + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoStructSet into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoStructSet + // + // value, err := echoStructSet(args) + // result, err := Echo_EchoStructSet_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoStructSet: %v", err) + // } + // serialize(result) + WrapResponse func([]*BarResponse, error) (*Echo_EchoStructSet_Result, error) + + // UnwrapResponse takes the result struct for echoStructSet + // and returns the value or error returned by it. + // + // The error is non-nil only if echoStructSet threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoStructSet_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoStructSet_Result) ([]*BarResponse, error) +}{} + +func init() { + Echo_EchoStructSet_Helper.Args = func( + arg []*BarResponse, + ) *Echo_EchoStructSet_Args { + return &Echo_EchoStructSet_Args{ + Arg: arg, + } + } + + Echo_EchoStructSet_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoStructSet_Helper.WrapResponse = func(success []*BarResponse, err error) (*Echo_EchoStructSet_Result, error) { + if err == nil { + return &Echo_EchoStructSet_Result{Success: success}, nil + } + + return nil, err + } + Echo_EchoStructSet_Helper.UnwrapResponse = func(result *Echo_EchoStructSet_Result) (success []*BarResponse, err error) { + + if result.Success != nil { + success = result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoStructSet_Result represents the result of a Echo.echoStructSet function call. +// +// The result of a echoStructSet execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoStructSet_Result struct { + // Value returned by echoStructSet after a successful execution. + Success []*BarResponse `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoStructSet_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoStructSet_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueSet(_Set_BarResponse_sliceType_ValueList(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoStructSet_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoStructSet_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoStructSet_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoStructSet_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoStructSet_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TSet { + v.Success, err = _Set_BarResponse_sliceType_Read(field.Value.GetSet()) + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoStructSet_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoStructSet_Result +// struct. +func (v *Echo_EchoStructSet_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", v.Success) + i++ + } + + return fmt.Sprintf("Echo_EchoStructSet_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoStructSet_Result match the +// provided Echo_EchoStructSet_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoStructSet_Result) Equals(rhs *Echo_EchoStructSet_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !((v.Success == nil && rhs.Success == nil) || (v.Success != nil && rhs.Success != nil && _Set_BarResponse_sliceType_Equals(v.Success, rhs.Success))) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoStructSet_Result. +func (v *Echo_EchoStructSet_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + err = multierr.Append(err, enc.AddArray("success", (_Set_BarResponse_sliceType_Zapper)(v.Success))) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoStructSet_Result) GetSuccess() (o []*BarResponse) { + if v != nil && v.Success != nil { + return v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoStructSet_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoStructSet" for this struct. +func (v *Echo_EchoStructSet_Result) MethodName() string { + return "echoStructSet" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoStructSet_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} + +// Echo_EchoTypedef_Args represents the arguments for the Echo.echoTypedef function. +// +// The arguments for echoTypedef are sent and received over the wire as this struct. +type Echo_EchoTypedef_Args struct { + Arg UUID `json:"arg,required"` +} + +// ToWire translates a Echo_EchoTypedef_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoTypedef_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = v.Arg.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoTypedef_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoTypedef_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoTypedef_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoTypedef_Args) FromWire(w wire.Value) error { + var err error + + argIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Arg, err = _UUID_Read(field.Value) + if err != nil { + return err + } + argIsSet = true + } + } + } + + if !argIsSet { + return errors.New("field Arg of Echo_EchoTypedef_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoTypedef_Args +// struct. +func (v *Echo_EchoTypedef_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Arg: %v", v.Arg) + i++ + + return fmt.Sprintf("Echo_EchoTypedef_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoTypedef_Args match the +// provided Echo_EchoTypedef_Args. +// +// This function performs a deep comparison. +func (v *Echo_EchoTypedef_Args) Equals(rhs *Echo_EchoTypedef_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Arg == rhs.Arg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoTypedef_Args. +func (v *Echo_EchoTypedef_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("arg", (string)(v.Arg)) + return err +} + +// GetArg returns the value of Arg if it is set or its +// zero value if it is unset. +func (v *Echo_EchoTypedef_Args) GetArg() (o UUID) { + if v != nil { + o = v.Arg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echoTypedef" for this struct. +func (v *Echo_EchoTypedef_Args) MethodName() string { + return "echoTypedef" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_EchoTypedef_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_EchoTypedef_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echoTypedef +// function. +var Echo_EchoTypedef_Helper = struct { + // Args accepts the parameters of echoTypedef in-order and returns + // the arguments struct for the function. + Args func( + arg UUID, + ) *Echo_EchoTypedef_Args + + // IsException returns true if the given error can be thrown + // by echoTypedef. + // + // An error can be thrown by echoTypedef only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echoTypedef + // given its return value and error. + // + // This allows mapping values and errors returned by + // echoTypedef into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echoTypedef + // + // value, err := echoTypedef(args) + // result, err := Echo_EchoTypedef_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echoTypedef: %v", err) + // } + // serialize(result) + WrapResponse func(UUID, error) (*Echo_EchoTypedef_Result, error) + + // UnwrapResponse takes the result struct for echoTypedef + // and returns the value or error returned by it. + // + // The error is non-nil only if echoTypedef threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_EchoTypedef_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_EchoTypedef_Result) (UUID, error) +}{} + +func init() { + Echo_EchoTypedef_Helper.Args = func( + arg UUID, + ) *Echo_EchoTypedef_Args { + return &Echo_EchoTypedef_Args{ + Arg: arg, + } + } + + Echo_EchoTypedef_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_EchoTypedef_Helper.WrapResponse = func(success UUID, err error) (*Echo_EchoTypedef_Result, error) { + if err == nil { + return &Echo_EchoTypedef_Result{Success: &success}, nil + } + + return nil, err + } + Echo_EchoTypedef_Helper.UnwrapResponse = func(result *Echo_EchoTypedef_Result) (success UUID, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_EchoTypedef_Result represents the result of a Echo.echoTypedef function call. +// +// The result of a echoTypedef execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_EchoTypedef_Result struct { + // Value returned by echoTypedef after a successful execution. + Success *UUID `json:"success,omitempty"` +} + +// ToWire translates a Echo_EchoTypedef_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_EchoTypedef_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = v.Success.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_EchoTypedef_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_EchoTypedef_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_EchoTypedef_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_EchoTypedef_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_EchoTypedef_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x UUID + x, err = _UUID_Read(field.Value) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_EchoTypedef_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_EchoTypedef_Result +// struct. +func (v *Echo_EchoTypedef_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_EchoTypedef_Result{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_EchoTypedef_Result match the +// provided Echo_EchoTypedef_Result. +// +// This function performs a deep comparison. +func (v *Echo_EchoTypedef_Result) Equals(rhs *Echo_EchoTypedef_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_UUID_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_EchoTypedef_Result. +func (v *Echo_EchoTypedef_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", (string)(*v.Success)) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_EchoTypedef_Result) GetSuccess() (o UUID) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_EchoTypedef_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echoTypedef" for this struct. +func (v *Echo_EchoTypedef_Result) MethodName() string { + return "echoTypedef" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_EchoTypedef_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go new file mode 100644 index 000000000..5991198e2 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go @@ -0,0 +1,8366 @@ +// Code generated by zanzibar +// @generated +// Checksum : s+6isP8Se05NiVssDsTYNQ== +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. + +package bar + +import ( + json "encoding/json" + fmt "fmt" + + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" + base "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/foo/base/base" + foo "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/foo/foo" +) + +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) + +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(in *jlexer.Lexer, out *_Map_I32_BarResponse_Item_Zapper) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "Key": + out.Key = int32(in.Int32()) + case "Value": + if in.IsNull() { + in.Skip() + out.Value = nil + } else { + if out.Value == nil { + out.Value = new(BarResponse) + } + (*out.Value).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(out *jwriter.Writer, in _Map_I32_BarResponse_Item_Zapper) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"Key\":" + out.RawString(prefix[1:]) + out.Int32(int32(in.Key)) + } + { + const prefix string = ",\"Value\":" + out.RawString(prefix) + if in.Value == nil { + out.RawString("null") + } else { + (*in.Value).MarshalEasyJSON(out) + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v _Map_I32_BarResponse_Item_Zapper) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v _Map_I32_BarResponse_Item_Zapper) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *_Map_I32_BarResponse_Item_Zapper) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *_Map_I32_BarResponse_Item_Zapper) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapI32BarResponseItem(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(in *jlexer.Lexer, out *_Map_BarResponse_String_Item_Zapper) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "Key": + if in.IsNull() { + in.Skip() + out.Key = nil + } else { + if out.Key == nil { + out.Key = new(BarResponse) + } + (*out.Key).UnmarshalEasyJSON(in) + } + case "Value": + out.Value = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(out *jwriter.Writer, in _Map_BarResponse_String_Item_Zapper) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"Key\":" + out.RawString(prefix[1:]) + if in.Key == nil { + out.RawString("null") + } else { + (*in.Key).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"Value\":" + out.RawString(prefix) + out.String(string(in.Value)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v _Map_BarResponse_String_Item_Zapper) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v _Map_BarResponse_String_Item_Zapper) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *_Map_BarResponse_String_Item_Zapper) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *_Map_BarResponse_String_Item_Zapper) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarMapBarResponseStringItem(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(in *jlexer.Lexer, out *RequestWithDuplicateType) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request1": + if in.IsNull() { + in.Skip() + out.Request1 = nil + } else { + if out.Request1 == nil { + out.Request1 = new(BarRequest) + } + (*out.Request1).UnmarshalEasyJSON(in) + } + case "request2": + if in.IsNull() { + in.Skip() + out.Request2 = nil + } else { + if out.Request2 == nil { + out.Request2 = new(BarRequest) + } + (*out.Request2).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(out *jwriter.Writer, in RequestWithDuplicateType) { + out.RawByte('{') + first := true + _ = first + if in.Request1 != nil { + const prefix string = ",\"request1\":" + first = false + out.RawString(prefix[1:]) + (*in.Request1).MarshalEasyJSON(out) + } + if in.Request2 != nil { + const prefix string = ",\"request2\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.Request2).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v RequestWithDuplicateType) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v RequestWithDuplicateType) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *RequestWithDuplicateType) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *RequestWithDuplicateType) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(in *jlexer.Lexer, out *QueryParamsStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var NameSet bool + var FooSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "name": + out.Name = string(in.String()) + NameSet = true + case "userUUID": + if in.IsNull() { + in.Skip() + out.UserUUID = nil + } else { + if out.UserUUID == nil { + out.UserUUID = new(string) + } + *out.UserUUID = string(in.String()) + } + case "authUUID": + if in.IsNull() { + in.Skip() + out.AuthUUID = nil + } else { + if out.AuthUUID == nil { + out.AuthUUID = new(string) + } + *out.AuthUUID = string(in.String()) + } + case "authUUID2": + if in.IsNull() { + in.Skip() + out.AuthUUID2 = nil + } else { + if out.AuthUUID2 == nil { + out.AuthUUID2 = new(string) + } + *out.AuthUUID2 = string(in.String()) + } + case "foo": + if in.IsNull() { + in.Skip() + out.Foo = nil + } else { + in.Delim('[') + if out.Foo == nil { + if !in.IsDelim(']') { + out.Foo = make([]string, 0, 4) + } else { + out.Foo = []string{} + } + } else { + out.Foo = (out.Foo)[:0] + } + for !in.IsDelim(']') { + var v1 string + v1 = string(in.String()) + out.Foo = append(out.Foo, v1) + in.WantComma() + } + in.Delim(']') + } + FooSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !NameSet { + in.AddError(fmt.Errorf("key 'name' is required")) + } + if !FooSet { + in.AddError(fmt.Errorf("key 'foo' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(out *jwriter.Writer, in QueryParamsStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"name\":" + out.RawString(prefix[1:]) + out.String(string(in.Name)) + } + if in.UserUUID != nil { + const prefix string = ",\"userUUID\":" + out.RawString(prefix) + out.String(string(*in.UserUUID)) + } + if in.AuthUUID != nil { + const prefix string = ",\"authUUID\":" + out.RawString(prefix) + out.String(string(*in.AuthUUID)) + } + if in.AuthUUID2 != nil { + const prefix string = ",\"authUUID2\":" + out.RawString(prefix) + out.String(string(*in.AuthUUID2)) + } + { + const prefix string = ",\"foo\":" + out.RawString(prefix) + if in.Foo == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v2, v3 := range in.Foo { + if v2 > 0 { + out.RawByte(',') + } + out.String(string(v3)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v QueryParamsStruct) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v QueryParamsStruct) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *QueryParamsStruct) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *QueryParamsStruct) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(in *jlexer.Lexer, out *QueryParamsOptsStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var NameSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "name": + out.Name = string(in.String()) + NameSet = true + case "userUUID": + if in.IsNull() { + in.Skip() + out.UserUUID = nil + } else { + if out.UserUUID == nil { + out.UserUUID = new(string) + } + *out.UserUUID = string(in.String()) + } + case "authUUID": + if in.IsNull() { + in.Skip() + out.AuthUUID = nil + } else { + if out.AuthUUID == nil { + out.AuthUUID = new(string) + } + *out.AuthUUID = string(in.String()) + } + case "authUUID2": + if in.IsNull() { + in.Skip() + out.AuthUUID2 = nil + } else { + if out.AuthUUID2 == nil { + out.AuthUUID2 = new(string) + } + *out.AuthUUID2 = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !NameSet { + in.AddError(fmt.Errorf("key 'name' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(out *jwriter.Writer, in QueryParamsOptsStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"name\":" + out.RawString(prefix[1:]) + out.String(string(in.Name)) + } + if in.UserUUID != nil { + const prefix string = ",\"userUUID\":" + out.RawString(prefix) + out.String(string(*in.UserUUID)) + } + if in.AuthUUID != nil { + const prefix string = ",\"authUUID\":" + out.RawString(prefix) + out.String(string(*in.AuthUUID)) + } + if in.AuthUUID2 != nil { + const prefix string = ",\"authUUID2\":" + out.RawString(prefix) + out.String(string(*in.AuthUUID2)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v QueryParamsOptsStruct) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v QueryParamsOptsStruct) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *QueryParamsOptsStruct) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *QueryParamsOptsStruct) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar2(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(in *jlexer.Lexer, out *ParamsStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var UserUUIDSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userUUID": + out.UserUUID = string(in.String()) + UserUUIDSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !UserUUIDSet { + in.AddError(fmt.Errorf("key 'userUUID' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(out *jwriter.Writer, in ParamsStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"userUUID\":" + out.RawString(prefix[1:]) + out.String(string(in.UserUUID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v ParamsStruct) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v ParamsStruct) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *ParamsStruct) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *ParamsStruct) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar3(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(in *jlexer.Lexer, out *OptionalParamsStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userID": + if in.IsNull() { + in.Skip() + out.UserID = nil + } else { + if out.UserID == nil { + out.UserID = new(string) + } + *out.UserID = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(out *jwriter.Writer, in OptionalParamsStruct) { + out.RawByte('{') + first := true + _ = first + if in.UserID != nil { + const prefix string = ",\"userID\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.UserID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v OptionalParamsStruct) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v OptionalParamsStruct) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *OptionalParamsStruct) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *OptionalParamsStruct) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar4(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(in *jlexer.Lexer, out *Echo_EchoTypedef_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(UUID) + } + *out.Success = UUID(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(out *jwriter.Writer, in Echo_EchoTypedef_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoTypedef_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoTypedef_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoTypedef_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoTypedef_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(in *jlexer.Lexer, out *Echo_EchoTypedef_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = UUID(in.String()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(out *jwriter.Writer, in Echo_EchoTypedef_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.String(string(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoTypedef_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoTypedef_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoTypedef_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoTypedef_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoTypedef1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(in *jlexer.Lexer, out *Echo_EchoStructSet_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + in.Delim('[') + if out.Success == nil { + if !in.IsDelim(']') { + out.Success = make([]*BarResponse, 0, 8) + } else { + out.Success = []*BarResponse{} + } + } else { + out.Success = (out.Success)[:0] + } + for !in.IsDelim(']') { + var v4 *BarResponse + if in.IsNull() { + in.Skip() + v4 = nil + } else { + if v4 == nil { + v4 = new(BarResponse) + } + (*v4).UnmarshalEasyJSON(in) + } + out.Success = append(out.Success, v4) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(out *jwriter.Writer, in Echo_EchoStructSet_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('[') + for v5, v6 := range in.Success { + if v5 > 0 { + out.RawByte(',') + } + if v6 == nil { + out.RawString("null") + } else { + (*v6).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructSet_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructSet_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructSet_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructSet_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(in *jlexer.Lexer, out *Echo_EchoStructSet_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + in.Delim('[') + if out.Arg == nil { + if !in.IsDelim(']') { + out.Arg = make([]*BarResponse, 0, 8) + } else { + out.Arg = []*BarResponse{} + } + } else { + out.Arg = (out.Arg)[:0] + } + for !in.IsDelim(']') { + var v7 *BarResponse + if in.IsNull() { + in.Skip() + v7 = nil + } else { + if v7 == nil { + v7 = new(BarResponse) + } + (*v7).UnmarshalEasyJSON(in) + } + out.Arg = append(out.Arg, v7) + in.WantComma() + } + in.Delim(']') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(out *jwriter.Writer, in Echo_EchoStructSet_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v8, v9 := range in.Arg { + if v8 > 0 { + out.RawByte(',') + } + if v9 == nil { + out.RawString("null") + } else { + (*v9).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructSet_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructSet_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructSet_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructSet_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructSet1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(in *jlexer.Lexer, out *Echo_EchoStructMap_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + in.Delim('[') + if out.Success == nil { + if !in.IsDelim(']') { + out.Success = make([]struct { + Key *BarResponse + Value string + }, 0, 2) + } else { + out.Success = []struct { + Key *BarResponse + Value string + }{} + } + } else { + out.Success = (out.Success)[:0] + } + for !in.IsDelim(']') { + var v10 struct { + Key *BarResponse + Value string + } + easyjson4347b5c1Decode(in, &v10) + out.Success = append(out.Success, v10) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(out *jwriter.Writer, in Echo_EchoStructMap_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('[') + for v11, v12 := range in.Success { + if v11 > 0 { + out.RawByte(',') + } + easyjson4347b5c1Encode(out, v12) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructMap_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructMap_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructMap_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructMap_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap(l, v) +} +func easyjson4347b5c1Decode(in *jlexer.Lexer, out *struct { + Key *BarResponse + Value string +}) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "Key": + if in.IsNull() { + in.Skip() + out.Key = nil + } else { + if out.Key == nil { + out.Key = new(BarResponse) + } + (*out.Key).UnmarshalEasyJSON(in) + } + case "Value": + out.Value = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1Encode(out *jwriter.Writer, in struct { + Key *BarResponse + Value string +}) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"Key\":" + out.RawString(prefix[1:]) + if in.Key == nil { + out.RawString("null") + } else { + (*in.Key).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"Value\":" + out.RawString(prefix) + out.String(string(in.Value)) + } + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(in *jlexer.Lexer, out *Echo_EchoStructMap_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + in.Delim('[') + if out.Arg == nil { + if !in.IsDelim(']') { + out.Arg = make([]struct { + Key *BarResponse + Value string + }, 0, 2) + } else { + out.Arg = []struct { + Key *BarResponse + Value string + }{} + } + } else { + out.Arg = (out.Arg)[:0] + } + for !in.IsDelim(']') { + var v13 struct { + Key *BarResponse + Value string + } + easyjson4347b5c1Decode(in, &v13) + out.Arg = append(out.Arg, v13) + in.WantComma() + } + in.Delim(']') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(out *jwriter.Writer, in Echo_EchoStructMap_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v14, v15 := range in.Arg { + if v14 > 0 { + out.RawByte(',') + } + easyjson4347b5c1Encode(out, v15) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructMap_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructMap_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructMap_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructMap_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructMap1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(in *jlexer.Lexer, out *Echo_EchoStructList_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + in.Delim('[') + if out.Success == nil { + if !in.IsDelim(']') { + out.Success = make([]*BarResponse, 0, 8) + } else { + out.Success = []*BarResponse{} + } + } else { + out.Success = (out.Success)[:0] + } + for !in.IsDelim(']') { + var v16 *BarResponse + if in.IsNull() { + in.Skip() + v16 = nil + } else { + if v16 == nil { + v16 = new(BarResponse) + } + (*v16).UnmarshalEasyJSON(in) + } + out.Success = append(out.Success, v16) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(out *jwriter.Writer, in Echo_EchoStructList_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('[') + for v17, v18 := range in.Success { + if v17 > 0 { + out.RawByte(',') + } + if v18 == nil { + out.RawString("null") + } else { + (*v18).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructList_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructList_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructList_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructList_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(in *jlexer.Lexer, out *Echo_EchoStructList_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + in.Delim('[') + if out.Arg == nil { + if !in.IsDelim(']') { + out.Arg = make([]*BarResponse, 0, 8) + } else { + out.Arg = []*BarResponse{} + } + } else { + out.Arg = (out.Arg)[:0] + } + for !in.IsDelim(']') { + var v19 *BarResponse + if in.IsNull() { + in.Skip() + v19 = nil + } else { + if v19 == nil { + v19 = new(BarResponse) + } + (*v19).UnmarshalEasyJSON(in) + } + out.Arg = append(out.Arg, v19) + in.WantComma() + } + in.Delim(']') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(out *jwriter.Writer, in Echo_EchoStructList_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v20, v21 := range in.Arg { + if v20 > 0 { + out.RawByte(',') + } + if v21 == nil { + out.RawString("null") + } else { + (*v21).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStructList_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStructList_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStructList_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStructList_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStructList1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(in *jlexer.Lexer, out *Echo_EchoString_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(string) + } + *out.Success = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(out *jwriter.Writer, in Echo_EchoString_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoString_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoString_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoString_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoString_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(in *jlexer.Lexer, out *Echo_EchoString_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = string(in.String()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(out *jwriter.Writer, in Echo_EchoString_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.String(string(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoString_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoString_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoString_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoString_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoString1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(in *jlexer.Lexer, out *Echo_EchoStringSet_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.Success = make(map[string]struct{}) + } else { + out.Success = nil + } + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v22 struct{} + easyjson4347b5c1Decode1(in, &v22) + (out.Success)[key] = v22 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(out *jwriter.Writer, in Echo_EchoStringSet_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('{') + v23First := true + for v23Name, v23Value := range in.Success { + if v23First { + v23First = false + } else { + out.RawByte(',') + } + out.String(string(v23Name)) + out.RawByte(':') + easyjson4347b5c1Encode1(out, v23Value) + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringSet_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringSet_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringSet_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringSet_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet(l, v) +} +func easyjson4347b5c1Decode1(in *jlexer.Lexer, out *struct{}) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1Encode1(out *jwriter.Writer, in struct{}) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(in *jlexer.Lexer, out *Echo_EchoStringSet_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Arg = make(map[string]struct{}) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v24 struct{} + easyjson4347b5c1Decode1(in, &v24) + (out.Arg)[key] = v24 + in.WantComma() + } + in.Delim('}') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(out *jwriter.Writer, in Echo_EchoStringSet_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v25First := true + for v25Name, v25Value := range in.Arg { + if v25First { + v25First = false + } else { + out.RawByte(',') + } + out.String(string(v25Name)) + out.RawByte(':') + easyjson4347b5c1Encode1(out, v25Value) + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringSet_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringSet_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringSet_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringSet_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringSet1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(in *jlexer.Lexer, out *Echo_EchoStringMap_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.Success = make(map[string]*BarResponse) + } else { + out.Success = nil + } + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v26 *BarResponse + if in.IsNull() { + in.Skip() + v26 = nil + } else { + if v26 == nil { + v26 = new(BarResponse) + } + (*v26).UnmarshalEasyJSON(in) + } + (out.Success)[key] = v26 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(out *jwriter.Writer, in Echo_EchoStringMap_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('{') + v27First := true + for v27Name, v27Value := range in.Success { + if v27First { + v27First = false + } else { + out.RawByte(',') + } + out.String(string(v27Name)) + out.RawByte(':') + if v27Value == nil { + out.RawString("null") + } else { + (*v27Value).MarshalEasyJSON(out) + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringMap_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringMap_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringMap_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringMap_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(in *jlexer.Lexer, out *Echo_EchoStringMap_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Arg = make(map[string]*BarResponse) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v28 *BarResponse + if in.IsNull() { + in.Skip() + v28 = nil + } else { + if v28 == nil { + v28 = new(BarResponse) + } + (*v28).UnmarshalEasyJSON(in) + } + (out.Arg)[key] = v28 + in.WantComma() + } + in.Delim('}') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(out *jwriter.Writer, in Echo_EchoStringMap_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v29First := true + for v29Name, v29Value := range in.Arg { + if v29First { + v29First = false + } else { + out.RawByte(',') + } + out.String(string(v29Name)) + out.RawByte(':') + if v29Value == nil { + out.RawString("null") + } else { + (*v29Value).MarshalEasyJSON(out) + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringMap_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringMap_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringMap_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringMap_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringMap1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(in *jlexer.Lexer, out *Echo_EchoStringList_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + in.Delim('[') + if out.Success == nil { + if !in.IsDelim(']') { + out.Success = make([]string, 0, 4) + } else { + out.Success = []string{} + } + } else { + out.Success = (out.Success)[:0] + } + for !in.IsDelim(']') { + var v30 string + v30 = string(in.String()) + out.Success = append(out.Success, v30) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(out *jwriter.Writer, in Echo_EchoStringList_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('[') + for v31, v32 := range in.Success { + if v31 > 0 { + out.RawByte(',') + } + out.String(string(v32)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringList_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringList_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringList_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringList_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(in *jlexer.Lexer, out *Echo_EchoStringList_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + in.Delim('[') + if out.Arg == nil { + if !in.IsDelim(']') { + out.Arg = make([]string, 0, 4) + } else { + out.Arg = []string{} + } + } else { + out.Arg = (out.Arg)[:0] + } + for !in.IsDelim(']') { + var v33 string + v33 = string(in.String()) + out.Arg = append(out.Arg, v33) + in.WantComma() + } + in.Delim(']') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(out *jwriter.Writer, in Echo_EchoStringList_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v34, v35 := range in.Arg { + if v34 > 0 { + out.RawByte(',') + } + out.String(string(v35)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoStringList_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoStringList_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoStringList_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoStringList_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoStringList1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(in *jlexer.Lexer, out *Echo_EchoI8_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(int8) + } + *out.Success = int8(in.Int8()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(out *jwriter.Writer, in Echo_EchoI8_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Int8(int8(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI8_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI8_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI8_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI8_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI8(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(in *jlexer.Lexer, out *Echo_EchoI8_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = int8(in.Int8()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(out *jwriter.Writer, in Echo_EchoI8_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Int8(int8(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI8_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI8_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI8_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI8_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI81(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(in *jlexer.Lexer, out *Echo_EchoI64_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(int64) + } + *out.Success = int64(in.Int64()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(out *jwriter.Writer, in Echo_EchoI64_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Int64(int64(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI64_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI64_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI64_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI64_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI64(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(in *jlexer.Lexer, out *Echo_EchoI64_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = int64(in.Int64()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(out *jwriter.Writer, in Echo_EchoI64_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Int64(int64(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI64_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI64_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI64_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI64_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI641(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(in *jlexer.Lexer, out *Echo_EchoI32_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(int32) + } + *out.Success = int32(in.Int32()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(out *jwriter.Writer, in Echo_EchoI32_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Int32(int32(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI32_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI32_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI32_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI32_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(in *jlexer.Lexer, out *Echo_EchoI32_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = int32(in.Int32()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(out *jwriter.Writer, in Echo_EchoI32_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Int32(int32(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI32_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI32_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI32_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI32_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI321(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(in *jlexer.Lexer, out *Echo_EchoI32Map_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.Success = make(map[int32]*BarResponse) + } else { + out.Success = nil + } + for !in.IsDelim('}') { + key := int32(in.Int32Str()) + in.WantColon() + var v36 *BarResponse + if in.IsNull() { + in.Skip() + v36 = nil + } else { + if v36 == nil { + v36 = new(BarResponse) + } + (*v36).UnmarshalEasyJSON(in) + } + (out.Success)[key] = v36 + in.WantComma() + } + in.Delim('}') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(out *jwriter.Writer, in Echo_EchoI32Map_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + { + out.RawByte('{') + v37First := true + for v37Name, v37Value := range in.Success { + if v37First { + v37First = false + } else { + out.RawByte(',') + } + out.Int32Str(int32(v37Name)) + out.RawByte(':') + if v37Value == nil { + out.RawString("null") + } else { + (*v37Value).MarshalEasyJSON(out) + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI32Map_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI32Map_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI32Map_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI32Map_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(in *jlexer.Lexer, out *Echo_EchoI32Map_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.Arg = make(map[int32]*BarResponse) + for !in.IsDelim('}') { + key := int32(in.Int32Str()) + in.WantColon() + var v38 *BarResponse + if in.IsNull() { + in.Skip() + v38 = nil + } else { + if v38 == nil { + v38 = new(BarResponse) + } + (*v38).UnmarshalEasyJSON(in) + } + (out.Arg)[key] = v38 + in.WantComma() + } + in.Delim('}') + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(out *jwriter.Writer, in Echo_EchoI32Map_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + if in.Arg == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v39First := true + for v39Name, v39Value := range in.Arg { + if v39First { + v39First = false + } else { + out.RawByte(',') + } + out.Int32Str(int32(v39Name)) + out.RawByte(':') + if v39Value == nil { + out.RawString("null") + } else { + (*v39Value).MarshalEasyJSON(out) + } + } + out.RawByte('}') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI32Map_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI32Map_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI32Map_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI32Map_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI32Map1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(in *jlexer.Lexer, out *Echo_EchoI16_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(int16) + } + *out.Success = int16(in.Int16()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(out *jwriter.Writer, in Echo_EchoI16_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Int16(int16(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI16_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI16_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI16_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI16_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI16(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(in *jlexer.Lexer, out *Echo_EchoI16_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = int16(in.Int16()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(out *jwriter.Writer, in Echo_EchoI16_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Int16(int16(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoI16_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoI16_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoI16_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoI16_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoI161(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(in *jlexer.Lexer, out *Echo_EchoEnum_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(Fruit) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.Success).UnmarshalJSON(data)) + } + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(out *jwriter.Writer, in Echo_EchoEnum_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Raw((*in.Success).MarshalJSON()) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoEnum_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoEnum_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoEnum_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoEnum_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(in *jlexer.Lexer, out *Echo_EchoEnum_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + if out.Arg == nil { + out.Arg = new(Fruit) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.Arg).UnmarshalJSON(data)) + } + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(out *jwriter.Writer, in Echo_EchoEnum_Args) { + out.RawByte('{') + first := true + _ = first + if in.Arg != nil { + const prefix string = ",\"arg\":" + first = false + out.RawString(prefix[1:]) + out.Raw((*in.Arg).MarshalJSON()) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoEnum_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoEnum_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoEnum_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoEnum_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoEnum1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(in *jlexer.Lexer, out *Echo_EchoDouble_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(float64) + } + *out.Success = float64(in.Float64()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(out *jwriter.Writer, in Echo_EchoDouble_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Float64(float64(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoDouble_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoDouble_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoDouble_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoDouble_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(in *jlexer.Lexer, out *Echo_EchoDouble_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = float64(in.Float64()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(out *jwriter.Writer, in Echo_EchoDouble_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Float64(float64(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoDouble_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoDouble_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoDouble_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoDouble_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoDouble1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(in *jlexer.Lexer, out *Echo_EchoBool_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(bool) + } + *out.Success = bool(in.Bool()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(out *jwriter.Writer, in Echo_EchoBool_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Bool(bool(*in.Success)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoBool_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoBool_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoBool_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoBool_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(in *jlexer.Lexer, out *Echo_EchoBool_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + out.Arg = bool(in.Bool()) + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(out *jwriter.Writer, in Echo_EchoBool_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Bool(bool(in.Arg)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoBool_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoBool_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoBool_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoBool_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBool1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(in *jlexer.Lexer, out *Echo_EchoBinary_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + out.Success = in.Bytes() + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(out *jwriter.Writer, in Echo_EchoBinary_Result) { + out.RawByte('{') + first := true + _ = first + if len(in.Success) != 0 { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.Base64Bytes(in.Success) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoBinary_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoBinary_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoBinary_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoBinary_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(in *jlexer.Lexer, out *Echo_EchoBinary_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var ArgSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "arg": + if in.IsNull() { + in.Skip() + out.Arg = nil + } else { + out.Arg = in.Bytes() + } + ArgSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !ArgSet { + in.AddError(fmt.Errorf("key 'arg' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(out *jwriter.Writer, in Echo_EchoBinary_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"arg\":" + out.RawString(prefix[1:]) + out.Base64Bytes(in.Arg) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Echo_EchoBinary_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Echo_EchoBinary_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Echo_EchoBinary_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Echo_EchoBinary_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarEchoEchoBinary1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(in *jlexer.Lexer, out *Bar_TooManyArgs_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + case "fooException": + if in.IsNull() { + in.Skip() + out.FooException = nil + } else { + if out.FooException == nil { + out.FooException = new(foo.FooException) + } + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(in, out.FooException) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(out *jwriter.Writer, in Bar_TooManyArgs_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + if in.FooException != nil { + const prefix string = ",\"fooException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(out, *in.FooException) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_TooManyArgs_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_TooManyArgs_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_TooManyArgs_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_TooManyArgs_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(in *jlexer.Lexer, out *foo.FooException) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var TeapotSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "teapot": + out.Teapot = string(in.String()) + TeapotSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !TeapotSet { + in.AddError(fmt.Errorf("key 'teapot' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(out *jwriter.Writer, in foo.FooException) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"teapot\":" + out.RawString(prefix[1:]) + out.String(string(in.Teapot)) + } + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(in *jlexer.Lexer, out *Bar_TooManyArgs_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + if in.IsNull() { + in.Skip() + out.Request = nil + } else { + if out.Request == nil { + out.Request = new(BarRequest) + } + (*out.Request).UnmarshalEasyJSON(in) + } + RequestSet = true + case "foo": + if in.IsNull() { + in.Skip() + out.Foo = nil + } else { + if out.Foo == nil { + out.Foo = new(foo.FooStruct) + } + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(in, out.Foo) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(out *jwriter.Writer, in Bar_TooManyArgs_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + if in.Request == nil { + out.RawString("null") + } else { + (*in.Request).MarshalEasyJSON(out) + } + } + if in.Foo != nil { + const prefix string = ",\"foo\":" + out.RawString(prefix) + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(out, *in.Foo) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_TooManyArgs_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_TooManyArgs_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_TooManyArgs_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_TooManyArgs_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(in *jlexer.Lexer, out *foo.FooStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var FooStringSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "fooString": + out.FooString = string(in.String()) + FooStringSet = true + case "fooI32": + if in.IsNull() { + in.Skip() + out.FooI32 = nil + } else { + if out.FooI32 == nil { + out.FooI32 = new(int32) + } + *out.FooI32 = int32(in.Int32()) + } + case "fooI16": + if in.IsNull() { + in.Skip() + out.FooI16 = nil + } else { + if out.FooI16 == nil { + out.FooI16 = new(int16) + } + *out.FooI16 = int16(in.Int16()) + } + case "fooDouble": + if in.IsNull() { + in.Skip() + out.FooDouble = nil + } else { + if out.FooDouble == nil { + out.FooDouble = new(float64) + } + *out.FooDouble = float64(in.Float64()) + } + case "fooBool": + if in.IsNull() { + in.Skip() + out.FooBool = nil + } else { + if out.FooBool == nil { + out.FooBool = new(bool) + } + *out.FooBool = bool(in.Bool()) + } + case "fooMap": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.FooMap = make(map[string]string) + } else { + out.FooMap = nil + } + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v46 string + v46 = string(in.String()) + (out.FooMap)[key] = v46 + in.WantComma() + } + in.Delim('}') + } + case "message": + if in.IsNull() { + in.Skip() + out.Message = nil + } else { + if out.Message == nil { + out.Message = new(base.Message) + } + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(in, out.Message) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !FooStringSet { + in.AddError(fmt.Errorf("key 'fooString' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(out *jwriter.Writer, in foo.FooStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"fooString\":" + out.RawString(prefix[1:]) + out.String(string(in.FooString)) + } + if in.FooI32 != nil { + const prefix string = ",\"fooI32\":" + out.RawString(prefix) + out.Int32(int32(*in.FooI32)) + } + if in.FooI16 != nil { + const prefix string = ",\"fooI16\":" + out.RawString(prefix) + out.Int16(int16(*in.FooI16)) + } + if in.FooDouble != nil { + const prefix string = ",\"fooDouble\":" + out.RawString(prefix) + out.Float64(float64(*in.FooDouble)) + } + if in.FooBool != nil { + const prefix string = ",\"fooBool\":" + out.RawString(prefix) + out.Bool(bool(*in.FooBool)) + } + if len(in.FooMap) != 0 { + const prefix string = ",\"fooMap\":" + out.RawString(prefix) + { + out.RawByte('{') + v47First := true + for v47Name, v47Value := range in.FooMap { + if v47First { + v47First = false + } else { + out.RawByte(',') + } + out.String(string(v47Name)) + out.RawByte(':') + out.String(string(v47Value)) + } + out.RawByte('}') + } + } + if in.Message != nil { + const prefix string = ",\"message\":" + out.RawString(prefix) + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(out, *in.Message) + } + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(in *jlexer.Lexer, out *base.Message) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var BodySet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + out.Body = string(in.String()) + BodySet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !BodySet { + in.AddError(fmt.Errorf("key 'body' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(out *jwriter.Writer, in base.Message) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"body\":" + out.RawString(prefix[1:]) + out.String(string(in.Body)) + } + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(in *jlexer.Lexer, out *Bar_Normal_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(out *jwriter.Writer, in Bar_Normal_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_Normal_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_Normal_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_Normal_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_Normal_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(in *jlexer.Lexer, out *Bar_Normal_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + if in.IsNull() { + in.Skip() + out.Request = nil + } else { + if out.Request == nil { + out.Request = new(BarRequest) + } + (*out.Request).UnmarshalEasyJSON(in) + } + RequestSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(out *jwriter.Writer, in Bar_Normal_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + if in.Request == nil { + out.RawString("null") + } else { + (*in.Request).MarshalEasyJSON(out) + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_Normal_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_Normal_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_Normal_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_Normal_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormal1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(in *jlexer.Lexer, out *Bar_NormalRecur_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponseRecur) + } + (*out.Success).UnmarshalEasyJSON(in) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(out *jwriter.Writer, in Bar_NormalRecur_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_NormalRecur_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_NormalRecur_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_NormalRecur_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_NormalRecur_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(in *jlexer.Lexer, out *Bar_NormalRecur_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + if in.IsNull() { + in.Skip() + out.Request = nil + } else { + if out.Request == nil { + out.Request = new(BarRequestRecur) + } + (*out.Request).UnmarshalEasyJSON(in) + } + RequestSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(out *jwriter.Writer, in Bar_NormalRecur_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + if in.Request == nil { + out.RawString("null") + } else { + (*in.Request).MarshalEasyJSON(out) + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_NormalRecur_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_NormalRecur_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_NormalRecur_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_NormalRecur_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNormalRecur1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(in *jlexer.Lexer, out *Bar_NoRequest_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(out *jwriter.Writer, in Bar_NoRequest_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_NoRequest_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_NoRequest_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_NoRequest_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_NoRequest_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(in *jlexer.Lexer, out *Bar_NoRequest_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(out *jwriter.Writer, in Bar_NoRequest_Args) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_NoRequest_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_NoRequest_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_NoRequest_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_NoRequest_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarNoRequest1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(in *jlexer.Lexer, out *Bar_MissingArg_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(out *jwriter.Writer, in Bar_MissingArg_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_MissingArg_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_MissingArg_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_MissingArg_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_MissingArg_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(in *jlexer.Lexer, out *Bar_MissingArg_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(out *jwriter.Writer, in Bar_MissingArg_Args) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_MissingArg_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_MissingArg_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_MissingArg_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_MissingArg_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarMissingArg1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(in *jlexer.Lexer, out *Bar_ListAndEnum_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(string) + } + *out.Success = string(in.String()) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(out *jwriter.Writer, in Bar_ListAndEnum_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.Success)) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ListAndEnum_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ListAndEnum_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ListAndEnum_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ListAndEnum_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(in *jlexer.Lexer, out *Bar_ListAndEnum_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var DemoIdsSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "demoIds": + if in.IsNull() { + in.Skip() + out.DemoIds = nil + } else { + in.Delim('[') + if out.DemoIds == nil { + if !in.IsDelim(']') { + out.DemoIds = make([]string, 0, 4) + } else { + out.DemoIds = []string{} + } + } else { + out.DemoIds = (out.DemoIds)[:0] + } + for !in.IsDelim(']') { + var v48 string + v48 = string(in.String()) + out.DemoIds = append(out.DemoIds, v48) + in.WantComma() + } + in.Delim(']') + } + DemoIdsSet = true + case "demoType": + if in.IsNull() { + in.Skip() + out.DemoType = nil + } else { + if out.DemoType == nil { + out.DemoType = new(DemoType) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.DemoType).UnmarshalJSON(data)) + } + } + case "demos": + if in.IsNull() { + in.Skip() + out.Demos = nil + } else { + in.Delim('[') + if out.Demos == nil { + if !in.IsDelim(']') { + out.Demos = make([]DemoType, 0, 16) + } else { + out.Demos = []DemoType{} + } + } else { + out.Demos = (out.Demos)[:0] + } + for !in.IsDelim(']') { + var v49 DemoType + if data := in.Raw(); in.Ok() { + in.AddError((v49).UnmarshalJSON(data)) + } + out.Demos = append(out.Demos, v49) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !DemoIdsSet { + in.AddError(fmt.Errorf("key 'demoIds' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(out *jwriter.Writer, in Bar_ListAndEnum_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"demoIds\":" + out.RawString(prefix[1:]) + if in.DemoIds == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v50, v51 := range in.DemoIds { + if v50 > 0 { + out.RawByte(',') + } + out.String(string(v51)) + } + out.RawByte(']') + } + } + if in.DemoType != nil { + const prefix string = ",\"demoType\":" + out.RawString(prefix) + out.Raw((*in.DemoType).MarshalJSON()) + } + if len(in.Demos) != 0 { + const prefix string = ",\"demos\":" + out.RawString(prefix) + { + out.RawByte('[') + for v52, v53 := range in.Demos { + if v52 > 0 { + out.RawByte(',') + } + out.Raw((v53).MarshalJSON()) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ListAndEnum_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ListAndEnum_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ListAndEnum_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ListAndEnum_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarListAndEnum1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(in *jlexer.Lexer, out *Bar_HelloWorld_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(string) + } + *out.Success = string(in.String()) + } + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(out *jwriter.Writer, in Bar_HelloWorld_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.Success)) + } + if in.BarException != nil { + const prefix string = ",\"barException\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_HelloWorld_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_HelloWorld_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_HelloWorld_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_HelloWorld_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(in *jlexer.Lexer, out *Bar_HelloWorld_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(out *jwriter.Writer, in Bar_HelloWorld_Args) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_HelloWorld_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_HelloWorld_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_HelloWorld_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_HelloWorld_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarHelloWorld1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(in *jlexer.Lexer, out *Bar_DeleteWithQueryParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(out *jwriter.Writer, in Bar_DeleteWithQueryParams_Result) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_DeleteWithQueryParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_DeleteWithQueryParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_DeleteWithQueryParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_DeleteWithQueryParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(in *jlexer.Lexer, out *Bar_DeleteWithQueryParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var FilterSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "filter": + out.Filter = string(in.String()) + FilterSet = true + case "count": + if in.IsNull() { + in.Skip() + out.Count = nil + } else { + if out.Count == nil { + out.Count = new(int32) + } + *out.Count = int32(in.Int32()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !FilterSet { + in.AddError(fmt.Errorf("key 'filter' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(out *jwriter.Writer, in Bar_DeleteWithQueryParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"filter\":" + out.RawString(prefix[1:]) + out.String(string(in.Filter)) + } + if in.Count != nil { + const prefix string = ",\"count\":" + out.RawString(prefix) + out.Int32(int32(*in.Count)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_DeleteWithQueryParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_DeleteWithQueryParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_DeleteWithQueryParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_DeleteWithQueryParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteWithQueryParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(in *jlexer.Lexer, out *Bar_DeleteFoo_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(out *jwriter.Writer, in Bar_DeleteFoo_Result) { + out.RawByte('{') + first := true + _ = first + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_DeleteFoo_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_DeleteFoo_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_DeleteFoo_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_DeleteFoo_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(in *jlexer.Lexer, out *Bar_DeleteFoo_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var UserUUIDSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userUUID": + out.UserUUID = string(in.String()) + UserUUIDSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !UserUUIDSet { + in.AddError(fmt.Errorf("key 'userUUID' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(out *jwriter.Writer, in Bar_DeleteFoo_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"userUUID\":" + out.RawString(prefix[1:]) + out.String(string(in.UserUUID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_DeleteFoo_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_DeleteFoo_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_DeleteFoo_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_DeleteFoo_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarDeleteFoo1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(in *jlexer.Lexer, out *Bar_ArgWithQueryParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(out *jwriter.Writer, in Bar_ArgWithQueryParams_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithQueryParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithQueryParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithQueryParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithQueryParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(in *jlexer.Lexer, out *Bar_ArgWithQueryParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var NameSet bool + var BarSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "name": + out.Name = string(in.String()) + NameSet = true + case "userUUID": + if in.IsNull() { + in.Skip() + out.UserUUID = nil + } else { + if out.UserUUID == nil { + out.UserUUID = new(string) + } + *out.UserUUID = string(in.String()) + } + case "foo": + if in.IsNull() { + in.Skip() + out.Foo = nil + } else { + in.Delim('[') + if out.Foo == nil { + if !in.IsDelim(']') { + out.Foo = make([]string, 0, 4) + } else { + out.Foo = []string{} + } + } else { + out.Foo = (out.Foo)[:0] + } + for !in.IsDelim(']') { + var v54 string + v54 = string(in.String()) + out.Foo = append(out.Foo, v54) + in.WantComma() + } + in.Delim(']') + } + case "bar": + if in.IsNull() { + in.Skip() + out.Bar = nil + } else { + in.Delim('[') + if out.Bar == nil { + if !in.IsDelim(']') { + out.Bar = make([]int8, 0, 64) + } else { + out.Bar = []int8{} + } + } else { + out.Bar = (out.Bar)[:0] + } + for !in.IsDelim(']') { + var v55 int8 + v55 = int8(in.Int8()) + out.Bar = append(out.Bar, v55) + in.WantComma() + } + in.Delim(']') + } + BarSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !NameSet { + in.AddError(fmt.Errorf("key 'name' is required")) + } + if !BarSet { + in.AddError(fmt.Errorf("key 'bar' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(out *jwriter.Writer, in Bar_ArgWithQueryParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"name\":" + out.RawString(prefix[1:]) + out.String(string(in.Name)) + } + if in.UserUUID != nil { + const prefix string = ",\"userUUID\":" + out.RawString(prefix) + out.String(string(*in.UserUUID)) + } + if len(in.Foo) != 0 { + const prefix string = ",\"foo\":" + out.RawString(prefix) + { + out.RawByte('[') + for v56, v57 := range in.Foo { + if v56 > 0 { + out.RawByte(',') + } + out.String(string(v57)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"bar\":" + out.RawString(prefix) + if in.Bar == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v58, v59 := range in.Bar { + if v58 > 0 { + out.RawByte(',') + } + out.Int8(int8(v59)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithQueryParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithQueryParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithQueryParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithQueryParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(in *jlexer.Lexer, out *Bar_ArgWithQueryHeader_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(out *jwriter.Writer, in Bar_ArgWithQueryHeader_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithQueryHeader_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithQueryHeader_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithQueryHeader_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithQueryHeader_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(in *jlexer.Lexer, out *Bar_ArgWithQueryHeader_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userUUID": + if in.IsNull() { + in.Skip() + out.UserUUID = nil + } else { + if out.UserUUID == nil { + out.UserUUID = new(string) + } + *out.UserUUID = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(out *jwriter.Writer, in Bar_ArgWithQueryHeader_Args) { + out.RawByte('{') + first := true + _ = first + if in.UserUUID != nil { + const prefix string = ",\"userUUID\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.UserUUID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithQueryHeader_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithQueryHeader_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithQueryHeader_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithQueryHeader_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithQueryHeader1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(in *jlexer.Lexer, out *Bar_ArgWithParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(out *jwriter.Writer, in Bar_ArgWithParams_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(in *jlexer.Lexer, out *Bar_ArgWithParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var UUIDSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "uuid": + out.UUID = string(in.String()) + UUIDSet = true + case "params": + if in.IsNull() { + in.Skip() + out.Params = nil + } else { + if out.Params == nil { + out.Params = new(ParamsStruct) + } + (*out.Params).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !UUIDSet { + in.AddError(fmt.Errorf("key 'uuid' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(out *jwriter.Writer, in Bar_ArgWithParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"uuid\":" + out.RawString(prefix[1:]) + out.String(string(in.UUID)) + } + if in.Params != nil { + const prefix string = ",\"params\":" + out.RawString(prefix) + (*in.Params).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(in *jlexer.Lexer, out *Bar_ArgWithParamsAndDuplicateFields_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(out *jwriter.Writer, in Bar_ArgWithParamsAndDuplicateFields_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithParamsAndDuplicateFields_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithParamsAndDuplicateFields_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithParamsAndDuplicateFields_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(in *jlexer.Lexer, out *Bar_ArgWithParamsAndDuplicateFields_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + var EntityUUIDSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + if in.IsNull() { + in.Skip() + out.Request = nil + } else { + if out.Request == nil { + out.Request = new(RequestWithDuplicateType) + } + (*out.Request).UnmarshalEasyJSON(in) + } + RequestSet = true + case "entityUUID": + out.EntityUUID = string(in.String()) + EntityUUIDSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } + if !EntityUUIDSet { + in.AddError(fmt.Errorf("key 'entityUUID' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(out *jwriter.Writer, in Bar_ArgWithParamsAndDuplicateFields_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + if in.Request == nil { + out.RawString("null") + } else { + (*in.Request).MarshalEasyJSON(out) + } + } + { + const prefix string = ",\"entityUUID\":" + out.RawString(prefix) + out.String(string(in.EntityUUID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithParamsAndDuplicateFields_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithParamsAndDuplicateFields_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithParamsAndDuplicateFields_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithParamsAndDuplicateFields1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(in *jlexer.Lexer, out *Bar_ArgWithNestedQueryParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(out *jwriter.Writer, in Bar_ArgWithNestedQueryParams_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithNestedQueryParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithNestedQueryParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithNestedQueryParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithNestedQueryParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(in *jlexer.Lexer, out *Bar_ArgWithNestedQueryParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + if in.IsNull() { + in.Skip() + out.Request = nil + } else { + if out.Request == nil { + out.Request = new(QueryParamsStruct) + } + (*out.Request).UnmarshalEasyJSON(in) + } + RequestSet = true + case "opt": + if in.IsNull() { + in.Skip() + out.Opt = nil + } else { + if out.Opt == nil { + out.Opt = new(QueryParamsOptsStruct) + } + (*out.Opt).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(out *jwriter.Writer, in Bar_ArgWithNestedQueryParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + if in.Request == nil { + out.RawString("null") + } else { + (*in.Request).MarshalEasyJSON(out) + } + } + if in.Opt != nil { + const prefix string = ",\"opt\":" + out.RawString(prefix) + (*in.Opt).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithNestedQueryParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithNestedQueryParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithNestedQueryParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithNestedQueryParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNestedQueryParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(in *jlexer.Lexer, out *Bar_ArgWithNearDupQueryParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(out *jwriter.Writer, in Bar_ArgWithNearDupQueryParams_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithNearDupQueryParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithNearDupQueryParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithNearDupQueryParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithNearDupQueryParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(in *jlexer.Lexer, out *Bar_ArgWithNearDupQueryParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var OneSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "one": + out.One = string(in.String()) + OneSet = true + case "two": + if in.IsNull() { + in.Skip() + out.Two = nil + } else { + if out.Two == nil { + out.Two = new(int32) + } + *out.Two = int32(in.Int32()) + } + case "three": + if in.IsNull() { + in.Skip() + out.Three = nil + } else { + if out.Three == nil { + out.Three = new(string) + } + *out.Three = string(in.String()) + } + case "four": + if in.IsNull() { + in.Skip() + out.Four = nil + } else { + if out.Four == nil { + out.Four = new(string) + } + *out.Four = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !OneSet { + in.AddError(fmt.Errorf("key 'one' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(out *jwriter.Writer, in Bar_ArgWithNearDupQueryParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"one\":" + out.RawString(prefix[1:]) + out.String(string(in.One)) + } + if in.Two != nil { + const prefix string = ",\"two\":" + out.RawString(prefix) + out.Int32(int32(*in.Two)) + } + if in.Three != nil { + const prefix string = ",\"three\":" + out.RawString(prefix) + out.String(string(*in.Three)) + } + if in.Four != nil { + const prefix string = ",\"four\":" + out.RawString(prefix) + out.String(string(*in.Four)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithNearDupQueryParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithNearDupQueryParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithNearDupQueryParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithNearDupQueryParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithNearDupQueryParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(in *jlexer.Lexer, out *Bar_ArgWithManyQueryParams_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(out *jwriter.Writer, in Bar_ArgWithManyQueryParams_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithManyQueryParams_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithManyQueryParams_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithManyQueryParams_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithManyQueryParams_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(in *jlexer.Lexer, out *Bar_ArgWithManyQueryParams_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var AStrSet bool + var ABoolSet bool + var AInt8Set bool + var AInt16Set bool + var AInt32Set bool + var AInt64Set bool + var AFloat64Set bool + var AUUIDSet bool + var AListUUIDSet bool + var AStringListSet bool + var AUUIDListSet bool + var ATsSet bool + var AReqDemoSet bool + var AReqFruitsSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "aStr": + out.AStr = string(in.String()) + AStrSet = true + case "anOptStr": + if in.IsNull() { + in.Skip() + out.AnOptStr = nil + } else { + if out.AnOptStr == nil { + out.AnOptStr = new(string) + } + *out.AnOptStr = string(in.String()) + } + case "aBool": + out.ABool = bool(in.Bool()) + ABoolSet = true + case "anOptBool": + if in.IsNull() { + in.Skip() + out.AnOptBool = nil + } else { + if out.AnOptBool == nil { + out.AnOptBool = new(bool) + } + *out.AnOptBool = bool(in.Bool()) + } + case "aInt8": + out.AInt8 = int8(in.Int8()) + AInt8Set = true + case "anOptInt8": + if in.IsNull() { + in.Skip() + out.AnOptInt8 = nil + } else { + if out.AnOptInt8 == nil { + out.AnOptInt8 = new(int8) + } + *out.AnOptInt8 = int8(in.Int8()) + } + case "aInt16": + out.AInt16 = int16(in.Int16()) + AInt16Set = true + case "anOptInt16": + if in.IsNull() { + in.Skip() + out.AnOptInt16 = nil + } else { + if out.AnOptInt16 == nil { + out.AnOptInt16 = new(int16) + } + *out.AnOptInt16 = int16(in.Int16()) + } + case "aInt32": + out.AInt32 = int32(in.Int32()) + AInt32Set = true + case "anOptInt32": + if in.IsNull() { + in.Skip() + out.AnOptInt32 = nil + } else { + if out.AnOptInt32 == nil { + out.AnOptInt32 = new(int32) + } + *out.AnOptInt32 = int32(in.Int32()) + } + case "aInt64": + out.AInt64 = int64(in.Int64()) + AInt64Set = true + case "anOptInt64": + if in.IsNull() { + in.Skip() + out.AnOptInt64 = nil + } else { + if out.AnOptInt64 == nil { + out.AnOptInt64 = new(int64) + } + *out.AnOptInt64 = int64(in.Int64()) + } + case "aFloat64": + out.AFloat64 = float64(in.Float64()) + AFloat64Set = true + case "anOptFloat64": + if in.IsNull() { + in.Skip() + out.AnOptFloat64 = nil + } else { + if out.AnOptFloat64 == nil { + out.AnOptFloat64 = new(float64) + } + *out.AnOptFloat64 = float64(in.Float64()) + } + case "aUUID": + out.AUUID = UUID(in.String()) + AUUIDSet = true + case "anOptUUID": + if in.IsNull() { + in.Skip() + out.AnOptUUID = nil + } else { + if out.AnOptUUID == nil { + out.AnOptUUID = new(UUID) + } + *out.AnOptUUID = UUID(in.String()) + } + case "aListUUID": + if in.IsNull() { + in.Skip() + out.AListUUID = nil + } else { + in.Delim('[') + if out.AListUUID == nil { + if !in.IsDelim(']') { + out.AListUUID = make([]UUID, 0, 4) + } else { + out.AListUUID = []UUID{} + } + } else { + out.AListUUID = (out.AListUUID)[:0] + } + for !in.IsDelim(']') { + var v60 UUID + v60 = UUID(in.String()) + out.AListUUID = append(out.AListUUID, v60) + in.WantComma() + } + in.Delim(']') + } + AListUUIDSet = true + case "anOptListUUID": + if in.IsNull() { + in.Skip() + out.AnOptListUUID = nil + } else { + in.Delim('[') + if out.AnOptListUUID == nil { + if !in.IsDelim(']') { + out.AnOptListUUID = make([]UUID, 0, 4) + } else { + out.AnOptListUUID = []UUID{} + } + } else { + out.AnOptListUUID = (out.AnOptListUUID)[:0] + } + for !in.IsDelim(']') { + var v61 UUID + v61 = UUID(in.String()) + out.AnOptListUUID = append(out.AnOptListUUID, v61) + in.WantComma() + } + in.Delim(']') + } + case "aStringList": + if in.IsNull() { + in.Skip() + out.AStringList = nil + } else { + in.Delim('[') + if out.AStringList == nil { + if !in.IsDelim(']') { + out.AStringList = make(StringList, 0, 4) + } else { + out.AStringList = StringList{} + } + } else { + out.AStringList = (out.AStringList)[:0] + } + for !in.IsDelim(']') { + var v62 string + v62 = string(in.String()) + out.AStringList = append(out.AStringList, v62) + in.WantComma() + } + in.Delim(']') + } + AStringListSet = true + case "anOptStringList": + if in.IsNull() { + in.Skip() + out.AnOptStringList = nil + } else { + in.Delim('[') + if out.AnOptStringList == nil { + if !in.IsDelim(']') { + out.AnOptStringList = make(StringList, 0, 4) + } else { + out.AnOptStringList = StringList{} + } + } else { + out.AnOptStringList = (out.AnOptStringList)[:0] + } + for !in.IsDelim(']') { + var v63 string + v63 = string(in.String()) + out.AnOptStringList = append(out.AnOptStringList, v63) + in.WantComma() + } + in.Delim(']') + } + case "aUUIDList": + if in.IsNull() { + in.Skip() + out.AUUIDList = nil + } else { + in.Delim('[') + if out.AUUIDList == nil { + if !in.IsDelim(']') { + out.AUUIDList = make(UUIDList, 0, 4) + } else { + out.AUUIDList = UUIDList{} + } + } else { + out.AUUIDList = (out.AUUIDList)[:0] + } + for !in.IsDelim(']') { + var v64 UUID + v64 = UUID(in.String()) + out.AUUIDList = append(out.AUUIDList, v64) + in.WantComma() + } + in.Delim(']') + } + AUUIDListSet = true + case "anOptUUIDList": + if in.IsNull() { + in.Skip() + out.AnOptUUIDList = nil + } else { + in.Delim('[') + if out.AnOptUUIDList == nil { + if !in.IsDelim(']') { + out.AnOptUUIDList = make(UUIDList, 0, 4) + } else { + out.AnOptUUIDList = UUIDList{} + } + } else { + out.AnOptUUIDList = (out.AnOptUUIDList)[:0] + } + for !in.IsDelim(']') { + var v65 UUID + v65 = UUID(in.String()) + out.AnOptUUIDList = append(out.AnOptUUIDList, v65) + in.WantComma() + } + in.Delim(']') + } + case "aTs": + if data := in.Raw(); in.Ok() { + in.AddError((out.ATs).UnmarshalJSON(data)) + } + ATsSet = true + case "anOptTs": + if in.IsNull() { + in.Skip() + out.AnOptTs = nil + } else { + if out.AnOptTs == nil { + out.AnOptTs = new(Timestamp) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.AnOptTs).UnmarshalJSON(data)) + } + } + case "aReqDemo": + if data := in.Raw(); in.Ok() { + in.AddError((out.AReqDemo).UnmarshalJSON(data)) + } + AReqDemoSet = true + case "anOptFruit": + if in.IsNull() { + in.Skip() + out.AnOptFruit = nil + } else { + if out.AnOptFruit == nil { + out.AnOptFruit = new(Fruit) + } + if data := in.Raw(); in.Ok() { + in.AddError((*out.AnOptFruit).UnmarshalJSON(data)) + } + } + case "aReqFruits": + if in.IsNull() { + in.Skip() + out.AReqFruits = nil + } else { + in.Delim('[') + if out.AReqFruits == nil { + if !in.IsDelim(']') { + out.AReqFruits = make([]Fruit, 0, 16) + } else { + out.AReqFruits = []Fruit{} + } + } else { + out.AReqFruits = (out.AReqFruits)[:0] + } + for !in.IsDelim(']') { + var v66 Fruit + if data := in.Raw(); in.Ok() { + in.AddError((v66).UnmarshalJSON(data)) + } + out.AReqFruits = append(out.AReqFruits, v66) + in.WantComma() + } + in.Delim(']') + } + AReqFruitsSet = true + case "anOptDemos": + if in.IsNull() { + in.Skip() + out.AnOptDemos = nil + } else { + in.Delim('[') + if out.AnOptDemos == nil { + if !in.IsDelim(']') { + out.AnOptDemos = make([]DemoType, 0, 16) + } else { + out.AnOptDemos = []DemoType{} + } + } else { + out.AnOptDemos = (out.AnOptDemos)[:0] + } + for !in.IsDelim(']') { + var v67 DemoType + if data := in.Raw(); in.Ok() { + in.AddError((v67).UnmarshalJSON(data)) + } + out.AnOptDemos = append(out.AnOptDemos, v67) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !AStrSet { + in.AddError(fmt.Errorf("key 'aStr' is required")) + } + if !ABoolSet { + in.AddError(fmt.Errorf("key 'aBool' is required")) + } + if !AInt8Set { + in.AddError(fmt.Errorf("key 'aInt8' is required")) + } + if !AInt16Set { + in.AddError(fmt.Errorf("key 'aInt16' is required")) + } + if !AInt32Set { + in.AddError(fmt.Errorf("key 'aInt32' is required")) + } + if !AInt64Set { + in.AddError(fmt.Errorf("key 'aInt64' is required")) + } + if !AFloat64Set { + in.AddError(fmt.Errorf("key 'aFloat64' is required")) + } + if !AUUIDSet { + in.AddError(fmt.Errorf("key 'aUUID' is required")) + } + if !AListUUIDSet { + in.AddError(fmt.Errorf("key 'aListUUID' is required")) + } + if !AStringListSet { + in.AddError(fmt.Errorf("key 'aStringList' is required")) + } + if !AUUIDListSet { + in.AddError(fmt.Errorf("key 'aUUIDList' is required")) + } + if !ATsSet { + in.AddError(fmt.Errorf("key 'aTs' is required")) + } + if !AReqDemoSet { + in.AddError(fmt.Errorf("key 'aReqDemo' is required")) + } + if !AReqFruitsSet { + in.AddError(fmt.Errorf("key 'aReqFruits' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(out *jwriter.Writer, in Bar_ArgWithManyQueryParams_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"aStr\":" + out.RawString(prefix[1:]) + out.String(string(in.AStr)) + } + if in.AnOptStr != nil { + const prefix string = ",\"anOptStr\":" + out.RawString(prefix) + out.String(string(*in.AnOptStr)) + } + { + const prefix string = ",\"aBool\":" + out.RawString(prefix) + out.Bool(bool(in.ABool)) + } + if in.AnOptBool != nil { + const prefix string = ",\"anOptBool\":" + out.RawString(prefix) + out.Bool(bool(*in.AnOptBool)) + } + { + const prefix string = ",\"aInt8\":" + out.RawString(prefix) + out.Int8(int8(in.AInt8)) + } + if in.AnOptInt8 != nil { + const prefix string = ",\"anOptInt8\":" + out.RawString(prefix) + out.Int8(int8(*in.AnOptInt8)) + } + { + const prefix string = ",\"aInt16\":" + out.RawString(prefix) + out.Int16(int16(in.AInt16)) + } + if in.AnOptInt16 != nil { + const prefix string = ",\"anOptInt16\":" + out.RawString(prefix) + out.Int16(int16(*in.AnOptInt16)) + } + { + const prefix string = ",\"aInt32\":" + out.RawString(prefix) + out.Int32(int32(in.AInt32)) + } + if in.AnOptInt32 != nil { + const prefix string = ",\"anOptInt32\":" + out.RawString(prefix) + out.Int32(int32(*in.AnOptInt32)) + } + { + const prefix string = ",\"aInt64\":" + out.RawString(prefix) + out.Int64(int64(in.AInt64)) + } + if in.AnOptInt64 != nil { + const prefix string = ",\"anOptInt64\":" + out.RawString(prefix) + out.Int64(int64(*in.AnOptInt64)) + } + { + const prefix string = ",\"aFloat64\":" + out.RawString(prefix) + out.Float64(float64(in.AFloat64)) + } + if in.AnOptFloat64 != nil { + const prefix string = ",\"anOptFloat64\":" + out.RawString(prefix) + out.Float64(float64(*in.AnOptFloat64)) + } + { + const prefix string = ",\"aUUID\":" + out.RawString(prefix) + out.String(string(in.AUUID)) + } + if in.AnOptUUID != nil { + const prefix string = ",\"anOptUUID\":" + out.RawString(prefix) + out.String(string(*in.AnOptUUID)) + } + { + const prefix string = ",\"aListUUID\":" + out.RawString(prefix) + if in.AListUUID == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v68, v69 := range in.AListUUID { + if v68 > 0 { + out.RawByte(',') + } + out.String(string(v69)) + } + out.RawByte(']') + } + } + if len(in.AnOptListUUID) != 0 { + const prefix string = ",\"anOptListUUID\":" + out.RawString(prefix) + { + out.RawByte('[') + for v70, v71 := range in.AnOptListUUID { + if v70 > 0 { + out.RawByte(',') + } + out.String(string(v71)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"aStringList\":" + out.RawString(prefix) + if in.AStringList == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v72, v73 := range in.AStringList { + if v72 > 0 { + out.RawByte(',') + } + out.String(string(v73)) + } + out.RawByte(']') + } + } + if len(in.AnOptStringList) != 0 { + const prefix string = ",\"anOptStringList\":" + out.RawString(prefix) + { + out.RawByte('[') + for v74, v75 := range in.AnOptStringList { + if v74 > 0 { + out.RawByte(',') + } + out.String(string(v75)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"aUUIDList\":" + out.RawString(prefix) + if in.AUUIDList == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v76, v77 := range in.AUUIDList { + if v76 > 0 { + out.RawByte(',') + } + out.String(string(v77)) + } + out.RawByte(']') + } + } + if len(in.AnOptUUIDList) != 0 { + const prefix string = ",\"anOptUUIDList\":" + out.RawString(prefix) + { + out.RawByte('[') + for v78, v79 := range in.AnOptUUIDList { + if v78 > 0 { + out.RawByte(',') + } + out.String(string(v79)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"aTs\":" + out.RawString(prefix) + out.Raw((in.ATs).MarshalJSON()) + } + if in.AnOptTs != nil { + const prefix string = ",\"anOptTs\":" + out.RawString(prefix) + out.Raw((*in.AnOptTs).MarshalJSON()) + } + { + const prefix string = ",\"aReqDemo\":" + out.RawString(prefix) + out.Raw((in.AReqDemo).MarshalJSON()) + } + if in.AnOptFruit != nil { + const prefix string = ",\"anOptFruit\":" + out.RawString(prefix) + out.Raw((*in.AnOptFruit).MarshalJSON()) + } + { + const prefix string = ",\"aReqFruits\":" + out.RawString(prefix) + if in.AReqFruits == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v80, v81 := range in.AReqFruits { + if v80 > 0 { + out.RawByte(',') + } + out.Raw((v81).MarshalJSON()) + } + out.RawByte(']') + } + } + if len(in.AnOptDemos) != 0 { + const prefix string = ",\"anOptDemos\":" + out.RawString(prefix) + { + out.RawByte('[') + for v82, v83 := range in.AnOptDemos { + if v82 > 0 { + out.RawByte(',') + } + out.Raw((v83).MarshalJSON()) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithManyQueryParams_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithManyQueryParams_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithManyQueryParams_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithManyQueryParams_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithManyQueryParams1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(in *jlexer.Lexer, out *Bar_ArgWithHeaders_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "success": + if in.IsNull() { + in.Skip() + out.Success = nil + } else { + if out.Success == nil { + out.Success = new(BarResponse) + } + (*out.Success).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(out *jwriter.Writer, in Bar_ArgWithHeaders_Result) { + out.RawByte('{') + first := true + _ = first + if in.Success != nil { + const prefix string = ",\"success\":" + first = false + out.RawString(prefix[1:]) + (*in.Success).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithHeaders_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithHeaders_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithHeaders_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithHeaders_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(in *jlexer.Lexer, out *Bar_ArgWithHeaders_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "paramsStruct": + if in.IsNull() { + in.Skip() + out.ParamsStruct = nil + } else { + if out.ParamsStruct == nil { + out.ParamsStruct = new(OptionalParamsStruct) + } + (*out.ParamsStruct).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(out *jwriter.Writer, in Bar_ArgWithHeaders_Args) { + out.RawByte('{') + first := true + _ = first + if in.ParamsStruct != nil { + const prefix string = ",\"paramsStruct\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + (*in.ParamsStruct).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgWithHeaders_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgWithHeaders_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgWithHeaders_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgWithHeaders_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgWithHeaders1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(in *jlexer.Lexer, out *Bar_ArgNotStruct_Result) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "barException": + if in.IsNull() { + in.Skip() + out.BarException = nil + } else { + if out.BarException == nil { + out.BarException = new(BarException) + } + (*out.BarException).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(out *jwriter.Writer, in Bar_ArgNotStruct_Result) { + out.RawByte('{') + first := true + _ = first + if in.BarException != nil { + const prefix string = ",\"barException\":" + first = false + out.RawString(prefix[1:]) + (*in.BarException).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgNotStruct_Result) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgNotStruct_Result) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgNotStruct_Result) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgNotStruct_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(in *jlexer.Lexer, out *Bar_ArgNotStruct_Args) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var RequestSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "request": + out.Request = string(in.String()) + RequestSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !RequestSet { + in.AddError(fmt.Errorf("key 'request' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(out *jwriter.Writer, in Bar_ArgNotStruct_Args) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"request\":" + out.RawString(prefix[1:]) + out.String(string(in.Request)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Bar_ArgNotStruct_Args) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Bar_ArgNotStruct_Args) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Bar_ArgNotStruct_Args) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Bar_ArgNotStruct_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBarBarArgNotStruct1(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(in *jlexer.Lexer, out *BarResponseRecur) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var NodesSet bool + var HeightSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "nodes": + if in.IsNull() { + in.Skip() + out.Nodes = nil + } else { + in.Delim('[') + if out.Nodes == nil { + if !in.IsDelim(']') { + out.Nodes = make([]string, 0, 4) + } else { + out.Nodes = []string{} + } + } else { + out.Nodes = (out.Nodes)[:0] + } + for !in.IsDelim(']') { + var v84 string + v84 = string(in.String()) + out.Nodes = append(out.Nodes, v84) + in.WantComma() + } + in.Delim(']') + } + NodesSet = true + case "height": + out.Height = int32(in.Int32()) + HeightSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !NodesSet { + in.AddError(fmt.Errorf("key 'nodes' is required")) + } + if !HeightSet { + in.AddError(fmt.Errorf("key 'height' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(out *jwriter.Writer, in BarResponseRecur) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"nodes\":" + out.RawString(prefix[1:]) + if in.Nodes == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v85, v86 := range in.Nodes { + if v85 > 0 { + out.RawByte(',') + } + out.String(string(v86)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"height\":" + out.RawString(prefix) + out.Int32(int32(in.Height)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v BarResponseRecur) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v BarResponseRecur) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *BarResponseRecur) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *BarResponseRecur) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar5(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(in *jlexer.Lexer, out *BarResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var StringFieldSet bool + var IntWithRangeSet bool + var IntWithoutRangeSet bool + var MapIntWithRangeSet bool + var MapIntWithoutRangeSet bool + var BinaryFieldSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "stringField": + out.StringField = string(in.String()) + StringFieldSet = true + case "intWithRange": + out.IntWithRange = int32(in.Int32()) + IntWithRangeSet = true + case "intWithoutRange": + out.IntWithoutRange = int32(in.Int32()) + IntWithoutRangeSet = true + case "mapIntWithRange": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.MapIntWithRange = make(map[UUID]int32) + for !in.IsDelim('}') { + key := UUID(in.String()) + in.WantColon() + var v87 int32 + v87 = int32(in.Int32()) + (out.MapIntWithRange)[key] = v87 + in.WantComma() + } + in.Delim('}') + } + MapIntWithRangeSet = true + case "mapIntWithoutRange": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + out.MapIntWithoutRange = make(map[string]int32) + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v88 int32 + v88 = int32(in.Int32()) + (out.MapIntWithoutRange)[key] = v88 + in.WantComma() + } + in.Delim('}') + } + MapIntWithoutRangeSet = true + case "binaryField": + if in.IsNull() { + in.Skip() + out.BinaryField = nil + } else { + out.BinaryField = in.Bytes() + } + BinaryFieldSet = true + case "nextResponse": + if in.IsNull() { + in.Skip() + out.NextResponse = nil + } else { + if out.NextResponse == nil { + out.NextResponse = new(BarResponse) + } + (*out.NextResponse).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !StringFieldSet { + in.AddError(fmt.Errorf("key 'stringField' is required")) + } + if !IntWithRangeSet { + in.AddError(fmt.Errorf("key 'intWithRange' is required")) + } + if !IntWithoutRangeSet { + in.AddError(fmt.Errorf("key 'intWithoutRange' is required")) + } + if !MapIntWithRangeSet { + in.AddError(fmt.Errorf("key 'mapIntWithRange' is required")) + } + if !MapIntWithoutRangeSet { + in.AddError(fmt.Errorf("key 'mapIntWithoutRange' is required")) + } + if !BinaryFieldSet { + in.AddError(fmt.Errorf("key 'binaryField' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(out *jwriter.Writer, in BarResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"stringField\":" + out.RawString(prefix[1:]) + out.String(string(in.StringField)) + } + { + const prefix string = ",\"intWithRange\":" + out.RawString(prefix) + out.Int32(int32(in.IntWithRange)) + } + { + const prefix string = ",\"intWithoutRange\":" + out.RawString(prefix) + out.Int32(int32(in.IntWithoutRange)) + } + { + const prefix string = ",\"mapIntWithRange\":" + out.RawString(prefix) + if in.MapIntWithRange == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v90First := true + for v90Name, v90Value := range in.MapIntWithRange { + if v90First { + v90First = false + } else { + out.RawByte(',') + } + out.String(string(v90Name)) + out.RawByte(':') + out.Int32(int32(v90Value)) + } + out.RawByte('}') + } + } + { + const prefix string = ",\"mapIntWithoutRange\":" + out.RawString(prefix) + if in.MapIntWithoutRange == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + out.RawString(`null`) + } else { + out.RawByte('{') + v91First := true + for v91Name, v91Value := range in.MapIntWithoutRange { + if v91First { + v91First = false + } else { + out.RawByte(',') + } + out.String(string(v91Name)) + out.RawByte(':') + out.Int32(int32(v91Value)) + } + out.RawByte('}') + } + } + { + const prefix string = ",\"binaryField\":" + out.RawString(prefix) + out.Base64Bytes(in.BinaryField) + } + if in.NextResponse != nil { + const prefix string = ",\"nextResponse\":" + out.RawString(prefix) + (*in.NextResponse).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v BarResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v BarResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *BarResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *BarResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar6(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(in *jlexer.Lexer, out *BarRequestRecur) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var NameSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "name": + out.Name = string(in.String()) + NameSet = true + case "recur": + if in.IsNull() { + in.Skip() + out.Recur = nil + } else { + if out.Recur == nil { + out.Recur = new(BarRequestRecur) + } + (*out.Recur).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !NameSet { + in.AddError(fmt.Errorf("key 'name' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(out *jwriter.Writer, in BarRequestRecur) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"name\":" + out.RawString(prefix[1:]) + out.String(string(in.Name)) + } + if in.Recur != nil { + const prefix string = ",\"recur\":" + out.RawString(prefix) + (*in.Recur).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v BarRequestRecur) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v BarRequestRecur) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *BarRequestRecur) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *BarRequestRecur) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar7(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(in *jlexer.Lexer, out *BarRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var StringFieldSet bool + var BoolFieldSet bool + var BinaryFieldSet bool + var TimestampSet bool + var EnumFieldSet bool + var LongFieldSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "stringField": + out.StringField = string(in.String()) + StringFieldSet = true + case "boolField": + out.BoolField = bool(in.Bool()) + BoolFieldSet = true + case "binaryField": + if in.IsNull() { + in.Skip() + out.BinaryField = nil + } else { + out.BinaryField = in.Bytes() + } + BinaryFieldSet = true + case "timestamp": + if data := in.Raw(); in.Ok() { + in.AddError((out.Timestamp).UnmarshalJSON(data)) + } + TimestampSet = true + case "enumField": + if data := in.Raw(); in.Ok() { + in.AddError((out.EnumField).UnmarshalJSON(data)) + } + EnumFieldSet = true + case "longField": + if data := in.Raw(); in.Ok() { + in.AddError((out.LongField).UnmarshalJSON(data)) + } + LongFieldSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !StringFieldSet { + in.AddError(fmt.Errorf("key 'stringField' is required")) + } + if !BoolFieldSet { + in.AddError(fmt.Errorf("key 'boolField' is required")) + } + if !BinaryFieldSet { + in.AddError(fmt.Errorf("key 'binaryField' is required")) + } + if !TimestampSet { + in.AddError(fmt.Errorf("key 'timestamp' is required")) + } + if !EnumFieldSet { + in.AddError(fmt.Errorf("key 'enumField' is required")) + } + if !LongFieldSet { + in.AddError(fmt.Errorf("key 'longField' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(out *jwriter.Writer, in BarRequest) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"stringField\":" + out.RawString(prefix[1:]) + out.String(string(in.StringField)) + } + { + const prefix string = ",\"boolField\":" + out.RawString(prefix) + out.Bool(bool(in.BoolField)) + } + { + const prefix string = ",\"binaryField\":" + out.RawString(prefix) + out.Base64Bytes(in.BinaryField) + } + { + const prefix string = ",\"timestamp\":" + out.RawString(prefix) + out.Raw((in.Timestamp).MarshalJSON()) + } + { + const prefix string = ",\"enumField\":" + out.RawString(prefix) + out.Raw((in.EnumField).MarshalJSON()) + } + { + const prefix string = ",\"longField\":" + out.RawString(prefix) + out.Raw((in.LongField).MarshalJSON()) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v BarRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v BarRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *BarRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *BarRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar8(l, v) +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(in *jlexer.Lexer, out *BarException) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var StringFieldSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "stringField": + out.StringField = string(in.String()) + StringFieldSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !StringFieldSet { + in.AddError(fmt.Errorf("key 'stringField' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(out *jwriter.Writer, in BarException) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"stringField\":" + out.RawString(prefix[1:]) + out.String(string(in.StringField)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v BarException) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v BarException) MarshalEasyJSON(w *jwriter.Writer) { + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *BarException) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *BarException) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsBarBar9(l, v) +} diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64.go new file mode 100644 index 000000000..a0ea84026 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64.go @@ -0,0 +1,62 @@ +package bar + +import ( + "encoding/binary" + "encoding/json" + "fmt" + "strconv" + "time" +) + +func (v Long) MarshalJSON() ([]byte, error) { + byteArray := make([]byte, 8, 8) + binary.BigEndian.PutUint64(byteArray, uint64(v)) + high := int32(binary.BigEndian.Uint32(byteArray[:4])) + low := int32(binary.BigEndian.Uint32(byteArray[4:])) + return ([]byte)(fmt.Sprintf("{\"high\":%d,\"low\":%d}", high, low)), nil +} +func (v *Long) UnmarshalJSON(text []byte) error { + firstByte := text[0] + if firstByte == byte('{') { + result := map[string]int32{} + err := json.Unmarshal(text, &result) + if err != nil { + return err + } + byteArray := make([]byte, 8, 8) + binary.BigEndian.PutUint32(byteArray[:4], uint32(result["high"])) + binary.BigEndian.PutUint32(byteArray[4:], uint32(result["low"])) + x := binary.BigEndian.Uint64(byteArray) + *v = Long(int64(x)) + } else { + x, err := strconv.ParseInt(string(text), 10, 64) + if err != nil { + return err + } + *v = Long(x) + } + return nil +} + +func (v Timestamp) MarshalJSON() ([]byte, error) { + x := (int64)(v) + return ([]byte)("\"" + time.Unix(x/1000, 0).UTC().Format(time.RFC3339) + "\""), nil +} + +func (v *Timestamp) UnmarshalJSON(text []byte) error { + firstByte := text[0] + if firstByte == byte('"') { + x, err := time.Parse(time.RFC3339, string(text[1:len(text)-1])) + if err != nil { + return err + } + *v = Timestamp(x.Unix() * 1000) + } else { + x, err := strconv.ParseInt(string(text), 10, 64) + if err != nil { + return err + } + *v = Timestamp(x) + } + return nil +} diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64_easyjson.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64_easyjson.go new file mode 100644 index 000000000..dd77aa1b6 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/types_i64_easyjson.go @@ -0,0 +1,22 @@ +// Code generated by zanzibar +// @generated +// Checksum : gYV3V5yK9HSWyPqj8tv9iA== +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. + +package bar + +import ( + json "encoding/json" + + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" +) + +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) diff --git a/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.go b/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.go new file mode 100644 index 000000000..80ed2ad3d --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.go @@ -0,0 +1,615 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: clients/echo/echo.proto + +package echo + +import ( + fmt "fmt" + io "io" + math "math" + reflect "reflect" + strings "strings" + + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type Request struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *Request) Reset() { *m = Request{} } +func (*Request) ProtoMessage() {} +func (*Request) Descriptor() ([]byte, []int) { + return fileDescriptor_6caa5dd77ae15c91, []int{0} +} +func (m *Request) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Request.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Request.Merge(m, src) +} +func (m *Request) XXX_Size() int { + return m.Size() +} +func (m *Request) XXX_DiscardUnknown() { + xxx_messageInfo_Request.DiscardUnknown(m) +} + +var xxx_messageInfo_Request proto.InternalMessageInfo + +func (m *Request) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type Response struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (m *Response) Reset() { *m = Response{} } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_6caa5dd77ae15c91, []int{1} +} +func (m *Response) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return m.Size() +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +func init() { + proto.RegisterType((*Request)(nil), "echo.Request") + proto.RegisterType((*Response)(nil), "echo.Response") +} + +func init() { proto.RegisterFile("clients/echo/echo.proto", fileDescriptor_6caa5dd77ae15c91) } + +var fileDescriptor_6caa5dd77ae15c91 = []byte{ + // 181 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0x29, 0xd6, 0x4f, 0x4d, 0xce, 0xc8, 0x07, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, + 0x42, 0x2c, 0x20, 0xb6, 0x92, 0x32, 0x17, 0x7b, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, + 0x04, 0x17, 0x7b, 0x6e, 0x6a, 0x71, 0x71, 0x62, 0x7a, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, + 0x10, 0x8c, 0xab, 0xa4, 0xc2, 0xc5, 0x11, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x8a, 0x5b, + 0x95, 0x91, 0x2e, 0x17, 0x8b, 0x6b, 0x72, 0x46, 0xbe, 0x90, 0x2a, 0x94, 0xe6, 0xd5, 0x03, 0xdb, + 0x06, 0x35, 0x5e, 0x8a, 0x0f, 0xc6, 0x85, 0x18, 0xe4, 0x64, 0x72, 0xe1, 0xa1, 0x1c, 0xc3, 0x8d, + 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0x36, 0x3c, 0x92, 0x63, 0x5c, 0xf1, 0x48, 0x8e, 0xf1, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x7c, 0xf1, 0x48, 0x8e, + 0xe1, 0xc3, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, + 0x8e, 0x21, 0x89, 0x0d, 0xec, 0x78, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xda, 0x44, 0x61, + 0x98, 0xd7, 0x00, 0x00, 0x00, +} + +func (this *Request) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Request) + if !ok { + that2, ok := that.(Request) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Message != that1.Message { + return false + } + return true +} +func (this *Response) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Response) + if !ok { + that2, ok := that.(Response) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Message != that1.Message { + return false + } + return true +} +func (this *Request) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&echo.Request{") + s = append(s, "Message: "+fmt.Sprintf("%#v", this.Message)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Response) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&echo.Response{") + s = append(s, "Message: "+fmt.Sprintf("%#v", this.Message)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringEcho(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *Request) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Request) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Message) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintEcho(dAtA, i, uint64(len(m.Message))) + i += copy(dAtA[i:], m.Message) + } + return i, nil +} + +func (m *Response) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Response) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Message) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintEcho(dAtA, i, uint64(len(m.Message))) + i += copy(dAtA[i:], m.Message) + } + return i, nil +} + +func encodeVarintEcho(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Request) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + sovEcho(uint64(l)) + } + return n +} + +func (m *Response) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + sovEcho(uint64(l)) + } + return n +} + +func sovEcho(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozEcho(x uint64) (n int) { + return sovEcho(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *Request) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Request{`, + `Message:` + fmt.Sprintf("%v", this.Message) + `,`, + `}`, + }, "") + return s +} +func (this *Response) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Response{`, + `Message:` + fmt.Sprintf("%v", this.Message) + `,`, + `}`, + }, "") + return s +} +func valueToStringEcho(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *Request) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcho + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcho + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEcho + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEcho + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEcho(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEcho + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEcho + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Response) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcho + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEcho + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEcho + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEcho + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEcho(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthEcho + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthEcho + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEcho(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEcho + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEcho + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEcho + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthEcho + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthEcho + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowEcho + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipEcho(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthEcho + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthEcho = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEcho = fmt.Errorf("proto: integer overflow") +) diff --git a/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.yarpc.go b/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.yarpc.go new file mode 100644 index 000000000..4d43b53e5 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/echo/echo.pb.yarpc.go @@ -0,0 +1,235 @@ +// Code generated by protoc-gen-yarpc-go. DO NOT EDIT. +// source: clients/echo/echo.proto + +package echo + +import ( + "context" + "io/ioutil" + "reflect" + + "github.com/gogo/protobuf/jsonpb" + "github.com/gogo/protobuf/proto" + "go.uber.org/fx" + "go.uber.org/yarpc" + "go.uber.org/yarpc/api/transport" + "go.uber.org/yarpc/encoding/protobuf" + "go.uber.org/yarpc/encoding/protobuf/reflection" +) + +var _ = ioutil.NopCloser + +// EchoYARPCClient is the YARPC client-side interface for the Echo service. +type EchoYARPCClient interface { + Echo(context.Context, *Request, ...yarpc.CallOption) (*Response, error) +} + +func newEchoYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) EchoYARPCClient { + return &_EchoYARPCCaller{protobuf.NewStreamClient( + protobuf.ClientParams{ + ServiceName: "echo.Echo", + ClientConfig: clientConfig, + AnyResolver: anyResolver, + Options: options, + }, + )} +} + +// NewEchoYARPCClient builds a new YARPC client for the Echo service. +func NewEchoYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) EchoYARPCClient { + return newEchoYARPCClient(clientConfig, nil, options...) +} + +// EchoYARPCServer is the YARPC server-side interface for the Echo service. +type EchoYARPCServer interface { + Echo(context.Context, *Request) (*Response, error) +} + +type buildEchoYARPCProceduresParams struct { + Server EchoYARPCServer + AnyResolver jsonpb.AnyResolver +} + +func buildEchoYARPCProcedures(params buildEchoYARPCProceduresParams) []transport.Procedure { + handler := &_EchoYARPCHandler{params.Server} + return protobuf.BuildProcedures( + protobuf.BuildProceduresParams{ + ServiceName: "echo.Echo", + UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{ + { + MethodName: "Echo", + Handler: protobuf.NewUnaryHandler( + protobuf.UnaryHandlerParams{ + Handle: handler.Echo, + NewRequest: newEchoServiceEchoYARPCRequest, + AnyResolver: params.AnyResolver, + }, + ), + }, + }, + OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{}, + StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{}, + }, + ) +} + +// BuildEchoYARPCProcedures prepares an implementation of the Echo service for YARPC registration. +func BuildEchoYARPCProcedures(server EchoYARPCServer) []transport.Procedure { + return buildEchoYARPCProcedures(buildEchoYARPCProceduresParams{Server: server}) +} + +// FxEchoYARPCClientParams defines the input +// for NewFxEchoYARPCClient. It provides the +// paramaters to get a EchoYARPCClient in an +// Fx application. +type FxEchoYARPCClientParams struct { + fx.In + + Provider yarpc.ClientConfig + AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` +} + +// FxEchoYARPCClientResult defines the output +// of NewFxEchoYARPCClient. It provides a +// EchoYARPCClient to an Fx application. +type FxEchoYARPCClientResult struct { + fx.Out + + Client EchoYARPCClient + + // We are using an fx.Out struct here instead of just returning a client + // so that we can add more values or add named versions of the client in + // the future without breaking any existing code. +} + +// NewFxEchoYARPCClient provides a EchoYARPCClient +// to an Fx application using the given name for routing. +// +// fx.Provide( +// echo.NewFxEchoYARPCClient("service-name"), +// ... +// ) +func NewFxEchoYARPCClient(name string, options ...protobuf.ClientOption) interface{} { + return func(params FxEchoYARPCClientParams) FxEchoYARPCClientResult { + return FxEchoYARPCClientResult{ + Client: newEchoYARPCClient(params.Provider.ClientConfig(name), params.AnyResolver, options...), + } + } +} + +// FxEchoYARPCProceduresParams defines the input +// for NewFxEchoYARPCProcedures. It provides the +// paramaters to get EchoYARPCServer procedures in an +// Fx application. +type FxEchoYARPCProceduresParams struct { + fx.In + + Server EchoYARPCServer + AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` +} + +// FxEchoYARPCProceduresResult defines the output +// of NewFxEchoYARPCProcedures. It provides +// EchoYARPCServer procedures to an Fx application. +// +// The procedures are provided to the "yarpcfx" value group. +// Dig 1.2 or newer must be used for this feature to work. +type FxEchoYARPCProceduresResult struct { + fx.Out + + Procedures []transport.Procedure `group:"yarpcfx"` + ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` +} + +// NewFxEchoYARPCProcedures provides EchoYARPCServer procedures to an Fx application. +// It expects a EchoYARPCServer to be present in the container. +// +// fx.Provide( +// echo.NewFxEchoYARPCProcedures(), +// ... +// ) +func NewFxEchoYARPCProcedures() interface{} { + return func(params FxEchoYARPCProceduresParams) FxEchoYARPCProceduresResult { + return FxEchoYARPCProceduresResult{ + Procedures: buildEchoYARPCProcedures(buildEchoYARPCProceduresParams{ + Server: params.Server, + AnyResolver: params.AnyResolver, + }), + ReflectionMeta: reflection.ServerMeta{ + ServiceName: "echo.Echo", + FileDescriptors: yarpcFileDescriptorClosure6caa5dd77ae15c91, + }, + } + } +} + +type _EchoYARPCCaller struct { + streamClient protobuf.StreamClient +} + +func (c *_EchoYARPCCaller) Echo(ctx context.Context, request *Request, options ...yarpc.CallOption) (*Response, error) { + responseMessage, err := c.streamClient.Call(ctx, "Echo", request, newEchoServiceEchoYARPCResponse, options...) + if responseMessage == nil { + return nil, err + } + response, ok := responseMessage.(*Response) + if !ok { + return nil, protobuf.CastError(emptyEchoServiceEchoYARPCResponse, responseMessage) + } + return response, err +} + +type _EchoYARPCHandler struct { + server EchoYARPCServer +} + +func (h *_EchoYARPCHandler) Echo(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { + var request *Request + var ok bool + if requestMessage != nil { + request, ok = requestMessage.(*Request) + if !ok { + return nil, protobuf.CastError(emptyEchoServiceEchoYARPCRequest, requestMessage) + } + } + response, err := h.server.Echo(ctx, request) + if response == nil { + return nil, err + } + return response, err +} + +func newEchoServiceEchoYARPCRequest() proto.Message { + return &Request{} +} + +func newEchoServiceEchoYARPCResponse() proto.Message { + return &Response{} +} + +var ( + emptyEchoServiceEchoYARPCRequest = &Request{} + emptyEchoServiceEchoYARPCResponse = &Response{} +) + +var yarpcFileDescriptorClosure6caa5dd77ae15c91 = [][]byte{ + // clients/echo/echo.proto + []byte{ + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0x29, 0xd6, 0x4f, 0x4d, 0xce, 0xc8, 0x07, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, + 0x42, 0x2c, 0x20, 0xb6, 0x92, 0x32, 0x17, 0x7b, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, + 0x04, 0x17, 0x7b, 0x6e, 0x6a, 0x71, 0x71, 0x62, 0x7a, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, + 0x10, 0x8c, 0xab, 0xa4, 0xc2, 0xc5, 0x11, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x8a, 0x5b, + 0x95, 0x91, 0x2e, 0x17, 0x8b, 0x6b, 0x72, 0x46, 0xbe, 0x90, 0x2a, 0x94, 0xe6, 0xd5, 0x03, 0xdb, + 0x06, 0x35, 0x5e, 0x8a, 0x0f, 0xc6, 0x85, 0x18, 0x94, 0xc4, 0x06, 0x76, 0x86, 0x31, 0x20, 0x00, + 0x00, 0xff, 0xff, 0xe9, 0xcf, 0xa3, 0x1b, 0xa1, 0x00, 0x00, 0x00, + }, +} + +func init() { + yarpc.RegisterClientBuilder( + func(clientConfig transport.ClientConfig, structField reflect.StructField) EchoYARPCClient { + return NewEchoYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...) + }, + ) +} diff --git a/examples/selective-gateway/build/gen-code/clients/foo/base/base/base.go b/examples/selective-gateway/build/gen-code/clients/foo/base/base/base.go new file mode 100644 index 000000000..8177eeda7 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/foo/base/base/base.go @@ -0,0 +1,143 @@ +// Code generated by thriftrw v1.20.2. DO NOT EDIT. +// @generated + +package base + +import ( + errors "errors" + fmt "fmt" + strings "strings" + + wire "go.uber.org/thriftrw/wire" + zapcore "go.uber.org/zap/zapcore" +) + +type Message struct { + Body string `json:"body,required"` +} + +// ToWire translates a Message struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Message) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Body), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Message struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Message struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Message +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Message) FromWire(w wire.Value) error { + var err error + + bodyIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Body, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + bodyIsSet = true + } + } + } + + if !bodyIsSet { + return errors.New("field Body of Message is required") + } + + return nil +} + +// String returns a readable string representation of a Message +// struct. +func (v *Message) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Body: %v", v.Body) + i++ + + return fmt.Sprintf("Message{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Message match the +// provided Message. +// +// This function performs a deep comparison. +func (v *Message) Equals(rhs *Message) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Body == rhs.Body) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Message. +func (v *Message) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("body", v.Body) + return err +} + +// GetBody returns the value of Body if it is set or its +// zero value if it is unset. +func (v *Message) GetBody() (o string) { + if v != nil { + o = v.Body + } + return +} diff --git a/examples/selective-gateway/build/gen-code/clients/foo/base/base/base_easyjson.go b/examples/selective-gateway/build/gen-code/clients/foo/base/base/base_easyjson.go new file mode 100644 index 000000000..9868c4fd9 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/foo/base/base/base_easyjson.go @@ -0,0 +1,95 @@ +// Code generated by zanzibar +// @generated +// Checksum : kOr5FE+JQZqCoXhqQKQSwA== +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. + +package base + +import ( + json "encoding/json" + fmt "fmt" + + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" +) + +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) + +func easyjson25720c23DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(in *jlexer.Lexer, out *Message) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var BodySet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + out.Body = string(in.String()) + BodySet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !BodySet { + in.AddError(fmt.Errorf("key 'body' is required")) + } +} +func easyjson25720c23EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(out *jwriter.Writer, in Message) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"body\":" + out.RawString(prefix[1:]) + out.String(string(in.Body)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Message) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson25720c23EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Message) MarshalEasyJSON(w *jwriter.Writer) { + easyjson25720c23EncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Message) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson25720c23DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Message) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson25720c23DecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooBaseBase(l, v) +} diff --git a/examples/selective-gateway/build/gen-code/clients/foo/foo/foo.go b/examples/selective-gateway/build/gen-code/clients/foo/foo/foo.go new file mode 100644 index 000000000..2238b452f --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/foo/foo/foo.go @@ -0,0 +1,824 @@ +// Code generated by thriftrw v1.20.2. DO NOT EDIT. +// @generated + +package foo + +import ( + errors "errors" + fmt "fmt" + strings "strings" + + base "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/foo/base/base" + multierr "go.uber.org/multierr" + wire "go.uber.org/thriftrw/wire" + zapcore "go.uber.org/zap/zapcore" +) + +type FooException struct { + Teapot string `json:"teapot,required"` +} + +// ToWire translates a FooException struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *FooException) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Teapot), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a FooException struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a FooException struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v FooException +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *FooException) FromWire(w wire.Value) error { + var err error + + teapotIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Teapot, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + teapotIsSet = true + } + } + } + + if !teapotIsSet { + return errors.New("field Teapot of FooException is required") + } + + return nil +} + +// String returns a readable string representation of a FooException +// struct. +func (v *FooException) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Teapot: %v", v.Teapot) + i++ + + return fmt.Sprintf("FooException{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this FooException match the +// provided FooException. +// +// This function performs a deep comparison. +func (v *FooException) Equals(rhs *FooException) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Teapot == rhs.Teapot) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of FooException. +func (v *FooException) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("teapot", v.Teapot) + return err +} + +// GetTeapot returns the value of Teapot if it is set or its +// zero value if it is unset. +func (v *FooException) GetTeapot() (o string) { + if v != nil { + o = v.Teapot + } + return +} + +func (v *FooException) Error() string { + return v.String() +} + +type FooName struct { + Name *string `json:"name,omitempty"` +} + +// ToWire translates a FooName struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *FooName) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Name != nil { + w, err = wire.NewValueString(*(v.Name)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a FooName struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a FooName struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v FooName +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *FooName) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Name = &x + if err != nil { + return err + } + + } + } + } + + return nil +} + +// String returns a readable string representation of a FooName +// struct. +func (v *FooName) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Name != nil { + fields[i] = fmt.Sprintf("Name: %v", *(v.Name)) + i++ + } + + return fmt.Sprintf("FooName{%v}", strings.Join(fields[:i], ", ")) +} + +func _String_EqualsPtr(lhs, rhs *string) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this FooName match the +// provided FooName. +// +// This function performs a deep comparison. +func (v *FooName) Equals(rhs *FooName) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Name, rhs.Name) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of FooName. +func (v *FooName) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Name != nil { + enc.AddString("name", *v.Name) + } + return err +} + +// GetName returns the value of Name if it is set or its +// zero value if it is unset. +func (v *FooName) GetName() (o string) { + if v != nil && v.Name != nil { + return *v.Name + } + + return +} + +// IsSetName returns true if Name is not nil. +func (v *FooName) IsSetName() bool { + return v != nil && v.Name != nil +} + +type FooStruct struct { + FooString string `json:"fooString,required"` + FooI32 *int32 `json:"fooI32,omitempty"` + FooI16 *int16 `json:"fooI16,omitempty"` + FooDouble *float64 `json:"fooDouble,omitempty"` + FooBool *bool `json:"fooBool,omitempty"` + FooMap map[string]string `json:"fooMap,omitempty"` + Message *base.Message `json:"message,omitempty"` +} + +type _Map_String_String_MapItemList map[string]string + +func (m _Map_String_String_MapItemList) ForEach(f func(wire.MapItem) error) error { + for k, v := range m { + kw, err := wire.NewValueString(k), error(nil) + if err != nil { + return err + } + + vw, err := wire.NewValueString(v), error(nil) + if err != nil { + return err + } + err = f(wire.MapItem{Key: kw, Value: vw}) + if err != nil { + return err + } + } + return nil +} + +func (m _Map_String_String_MapItemList) Size() int { + return len(m) +} + +func (_Map_String_String_MapItemList) KeyType() wire.Type { + return wire.TBinary +} + +func (_Map_String_String_MapItemList) ValueType() wire.Type { + return wire.TBinary +} + +func (_Map_String_String_MapItemList) Close() {} + +// ToWire translates a FooStruct struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *FooStruct) ToWire() (wire.Value, error) { + var ( + fields [7]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.FooString), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + if v.FooI32 != nil { + w, err = wire.NewValueI32(*(v.FooI32)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 2, Value: w} + i++ + } + if v.FooI16 != nil { + w, err = wire.NewValueI16(*(v.FooI16)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 3, Value: w} + i++ + } + if v.FooDouble != nil { + w, err = wire.NewValueDouble(*(v.FooDouble)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 4, Value: w} + i++ + } + if v.FooBool != nil { + w, err = wire.NewValueBool(*(v.FooBool)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 5, Value: w} + i++ + } + if v.FooMap != nil { + w, err = wire.NewValueMap(_Map_String_String_MapItemList(v.FooMap)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 6, Value: w} + i++ + } + if v.Message != nil { + w, err = v.Message.ToWire() + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 7, Value: w} + i++ + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +func _Map_String_String_Read(m wire.MapItemList) (map[string]string, error) { + if m.KeyType() != wire.TBinary { + return nil, nil + } + + if m.ValueType() != wire.TBinary { + return nil, nil + } + + o := make(map[string]string, m.Size()) + err := m.ForEach(func(x wire.MapItem) error { + k, err := x.Key.GetString(), error(nil) + if err != nil { + return err + } + + v, err := x.Value.GetString(), error(nil) + if err != nil { + return err + } + + o[k] = v + return nil + }) + m.Close() + return o, err +} + +func _Message_Read(w wire.Value) (*base.Message, error) { + var v base.Message + err := v.FromWire(w) + return &v, err +} + +// FromWire deserializes a FooStruct struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a FooStruct struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v FooStruct +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *FooStruct) FromWire(w wire.Value) error { + var err error + + fooStringIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.FooString, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + fooStringIsSet = true + } + case 2: + if field.Value.Type() == wire.TI32 { + var x int32 + x, err = field.Value.GetI32(), error(nil) + v.FooI32 = &x + if err != nil { + return err + } + + } + case 3: + if field.Value.Type() == wire.TI16 { + var x int16 + x, err = field.Value.GetI16(), error(nil) + v.FooI16 = &x + if err != nil { + return err + } + + } + case 4: + if field.Value.Type() == wire.TDouble { + var x float64 + x, err = field.Value.GetDouble(), error(nil) + v.FooDouble = &x + if err != nil { + return err + } + + } + case 5: + if field.Value.Type() == wire.TBool { + var x bool + x, err = field.Value.GetBool(), error(nil) + v.FooBool = &x + if err != nil { + return err + } + + } + case 6: + if field.Value.Type() == wire.TMap { + v.FooMap, err = _Map_String_String_Read(field.Value.GetMap()) + if err != nil { + return err + } + + } + case 7: + if field.Value.Type() == wire.TStruct { + v.Message, err = _Message_Read(field.Value) + if err != nil { + return err + } + + } + } + } + + if !fooStringIsSet { + return errors.New("field FooString of FooStruct is required") + } + + return nil +} + +// String returns a readable string representation of a FooStruct +// struct. +func (v *FooStruct) String() string { + if v == nil { + return "" + } + + var fields [7]string + i := 0 + fields[i] = fmt.Sprintf("FooString: %v", v.FooString) + i++ + if v.FooI32 != nil { + fields[i] = fmt.Sprintf("FooI32: %v", *(v.FooI32)) + i++ + } + if v.FooI16 != nil { + fields[i] = fmt.Sprintf("FooI16: %v", *(v.FooI16)) + i++ + } + if v.FooDouble != nil { + fields[i] = fmt.Sprintf("FooDouble: %v", *(v.FooDouble)) + i++ + } + if v.FooBool != nil { + fields[i] = fmt.Sprintf("FooBool: %v", *(v.FooBool)) + i++ + } + if v.FooMap != nil { + fields[i] = fmt.Sprintf("FooMap: %v", v.FooMap) + i++ + } + if v.Message != nil { + fields[i] = fmt.Sprintf("Message: %v", v.Message) + i++ + } + + return fmt.Sprintf("FooStruct{%v}", strings.Join(fields[:i], ", ")) +} + +func _I32_EqualsPtr(lhs, rhs *int32) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _I16_EqualsPtr(lhs, rhs *int16) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Double_EqualsPtr(lhs, rhs *float64) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Bool_EqualsPtr(lhs, rhs *bool) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +func _Map_String_String_Equals(lhs, rhs map[string]string) bool { + if len(lhs) != len(rhs) { + return false + } + + for lk, lv := range lhs { + rv, ok := rhs[lk] + if !ok { + return false + } + if !(lv == rv) { + return false + } + } + return true +} + +// Equals returns true if all the fields of this FooStruct match the +// provided FooStruct. +// +// This function performs a deep comparison. +func (v *FooStruct) Equals(rhs *FooStruct) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.FooString == rhs.FooString) { + return false + } + if !_I32_EqualsPtr(v.FooI32, rhs.FooI32) { + return false + } + if !_I16_EqualsPtr(v.FooI16, rhs.FooI16) { + return false + } + if !_Double_EqualsPtr(v.FooDouble, rhs.FooDouble) { + return false + } + if !_Bool_EqualsPtr(v.FooBool, rhs.FooBool) { + return false + } + if !((v.FooMap == nil && rhs.FooMap == nil) || (v.FooMap != nil && rhs.FooMap != nil && _Map_String_String_Equals(v.FooMap, rhs.FooMap))) { + return false + } + if !((v.Message == nil && rhs.Message == nil) || (v.Message != nil && rhs.Message != nil && v.Message.Equals(rhs.Message))) { + return false + } + + return true +} + +type _Map_String_String_Zapper map[string]string + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of _Map_String_String_Zapper. +func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + for k, v := range m { + enc.AddString((string)(k), v) + } + return err +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of FooStruct. +func (v *FooStruct) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("fooString", v.FooString) + if v.FooI32 != nil { + enc.AddInt32("fooI32", *v.FooI32) + } + if v.FooI16 != nil { + enc.AddInt16("fooI16", *v.FooI16) + } + if v.FooDouble != nil { + enc.AddFloat64("fooDouble", *v.FooDouble) + } + if v.FooBool != nil { + enc.AddBool("fooBool", *v.FooBool) + } + if v.FooMap != nil { + err = multierr.Append(err, enc.AddObject("fooMap", (_Map_String_String_Zapper)(v.FooMap))) + } + if v.Message != nil { + err = multierr.Append(err, enc.AddObject("message", v.Message)) + } + return err +} + +// GetFooString returns the value of FooString if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooString() (o string) { + if v != nil { + o = v.FooString + } + return +} + +// GetFooI32 returns the value of FooI32 if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooI32() (o int32) { + if v != nil && v.FooI32 != nil { + return *v.FooI32 + } + + return +} + +// IsSetFooI32 returns true if FooI32 is not nil. +func (v *FooStruct) IsSetFooI32() bool { + return v != nil && v.FooI32 != nil +} + +// GetFooI16 returns the value of FooI16 if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooI16() (o int16) { + if v != nil && v.FooI16 != nil { + return *v.FooI16 + } + + return +} + +// IsSetFooI16 returns true if FooI16 is not nil. +func (v *FooStruct) IsSetFooI16() bool { + return v != nil && v.FooI16 != nil +} + +// GetFooDouble returns the value of FooDouble if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooDouble() (o float64) { + if v != nil && v.FooDouble != nil { + return *v.FooDouble + } + + return +} + +// IsSetFooDouble returns true if FooDouble is not nil. +func (v *FooStruct) IsSetFooDouble() bool { + return v != nil && v.FooDouble != nil +} + +// GetFooBool returns the value of FooBool if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooBool() (o bool) { + if v != nil && v.FooBool != nil { + return *v.FooBool + } + + return +} + +// IsSetFooBool returns true if FooBool is not nil. +func (v *FooStruct) IsSetFooBool() bool { + return v != nil && v.FooBool != nil +} + +// GetFooMap returns the value of FooMap if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetFooMap() (o map[string]string) { + if v != nil && v.FooMap != nil { + return v.FooMap + } + + return +} + +// IsSetFooMap returns true if FooMap is not nil. +func (v *FooStruct) IsSetFooMap() bool { + return v != nil && v.FooMap != nil +} + +// GetMessage returns the value of Message if it is set or its +// zero value if it is unset. +func (v *FooStruct) GetMessage() (o *base.Message) { + if v != nil && v.Message != nil { + return v.Message + } + + return +} + +// IsSetMessage returns true if Message is not nil. +func (v *FooStruct) IsSetMessage() bool { + return v != nil && v.Message != nil +} diff --git a/examples/selective-gateway/build/gen-code/clients/foo/foo/foo_easyjson.go b/examples/selective-gateway/build/gen-code/clients/foo/foo/foo_easyjson.go new file mode 100644 index 000000000..4ca3dca3e --- /dev/null +++ b/examples/selective-gateway/build/gen-code/clients/foo/foo/foo_easyjson.go @@ -0,0 +1,356 @@ +// Code generated by zanzibar +// @generated +// Checksum : HoPQQIrYh2/uIWpXnb1X+w== +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. + +package foo + +import ( + json "encoding/json" + fmt "fmt" + + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" + base "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/foo/base/base" +) + +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) + +func easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(in *jlexer.Lexer, out *FooStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var FooStringSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "fooString": + out.FooString = string(in.String()) + FooStringSet = true + case "fooI32": + if in.IsNull() { + in.Skip() + out.FooI32 = nil + } else { + if out.FooI32 == nil { + out.FooI32 = new(int32) + } + *out.FooI32 = int32(in.Int32()) + } + case "fooI16": + if in.IsNull() { + in.Skip() + out.FooI16 = nil + } else { + if out.FooI16 == nil { + out.FooI16 = new(int16) + } + *out.FooI16 = int16(in.Int16()) + } + case "fooDouble": + if in.IsNull() { + in.Skip() + out.FooDouble = nil + } else { + if out.FooDouble == nil { + out.FooDouble = new(float64) + } + *out.FooDouble = float64(in.Float64()) + } + case "fooBool": + if in.IsNull() { + in.Skip() + out.FooBool = nil + } else { + if out.FooBool == nil { + out.FooBool = new(bool) + } + *out.FooBool = bool(in.Bool()) + } + case "fooMap": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.FooMap = make(map[string]string) + } else { + out.FooMap = nil + } + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v1 string + v1 = string(in.String()) + (out.FooMap)[key] = v1 + in.WantComma() + } + in.Delim('}') + } + case "message": + if in.IsNull() { + in.Skip() + out.Message = nil + } else { + if out.Message == nil { + out.Message = new(base.Message) + } + (*out.Message).UnmarshalEasyJSON(in) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !FooStringSet { + in.AddError(fmt.Errorf("key 'fooString' is required")) + } +} +func easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(out *jwriter.Writer, in FooStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"fooString\":" + out.RawString(prefix[1:]) + out.String(string(in.FooString)) + } + if in.FooI32 != nil { + const prefix string = ",\"fooI32\":" + out.RawString(prefix) + out.Int32(int32(*in.FooI32)) + } + if in.FooI16 != nil { + const prefix string = ",\"fooI16\":" + out.RawString(prefix) + out.Int16(int16(*in.FooI16)) + } + if in.FooDouble != nil { + const prefix string = ",\"fooDouble\":" + out.RawString(prefix) + out.Float64(float64(*in.FooDouble)) + } + if in.FooBool != nil { + const prefix string = ",\"fooBool\":" + out.RawString(prefix) + out.Bool(bool(*in.FooBool)) + } + if len(in.FooMap) != 0 { + const prefix string = ",\"fooMap\":" + out.RawString(prefix) + { + out.RawByte('{') + v2First := true + for v2Name, v2Value := range in.FooMap { + if v2First { + v2First = false + } else { + out.RawByte(',') + } + out.String(string(v2Name)) + out.RawByte(':') + out.String(string(v2Value)) + } + out.RawByte('}') + } + } + if in.Message != nil { + const prefix string = ",\"message\":" + out.RawString(prefix) + (*in.Message).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v FooStruct) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FooStruct) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *FooStruct) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FooStruct) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo(l, v) +} +func easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(in *jlexer.Lexer, out *FooName) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "name": + if in.IsNull() { + in.Skip() + out.Name = nil + } else { + if out.Name == nil { + out.Name = new(string) + } + *out.Name = string(in.String()) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(out *jwriter.Writer, in FooName) { + out.RawByte('{') + first := true + _ = first + if in.Name != nil { + const prefix string = ",\"name\":" + first = false + out.RawString(prefix[1:]) + out.String(string(*in.Name)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v FooName) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FooName) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *FooName) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FooName) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo1(l, v) +} +func easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(in *jlexer.Lexer, out *FooException) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var TeapotSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "teapot": + out.Teapot = string(in.String()) + TeapotSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !TeapotSet { + in.AddError(fmt.Errorf("key 'teapot' is required")) + } +} +func easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(out *jwriter.Writer, in FooException) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"teapot\":" + out.RawString(prefix[1:]) + out.String(string(in.Teapot)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v FooException) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FooException) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonE4de407aEncodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *FooException) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FooException) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonE4de407aDecodeGithubComUberZanzibarExamplesSelectiveGatewayBuildGenCodeClientsFooFoo2(l, v) +} diff --git a/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce/bounce.go b/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce/bounce.go new file mode 100644 index 000000000..6df9f0893 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce/bounce.go @@ -0,0 +1,423 @@ +// Code generated by thriftrw v1.20.2. DO NOT EDIT. +// @generated + +package bounce + +import ( + errors "errors" + fmt "fmt" + strings "strings" + + wire "go.uber.org/thriftrw/wire" + zapcore "go.uber.org/zap/zapcore" +) + +// Bounce_Bounce_Args represents the arguments for the Bounce.bounce function. +// +// The arguments for bounce are sent and received over the wire as this struct. +type Bounce_Bounce_Args struct { + Msg string `json:"msg,required"` +} + +// ToWire translates a Bounce_Bounce_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bounce_Bounce_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Msg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bounce_Bounce_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bounce_Bounce_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bounce_Bounce_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bounce_Bounce_Args) FromWire(w wire.Value) error { + var err error + + msgIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Msg, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + msgIsSet = true + } + } + } + + if !msgIsSet { + return errors.New("field Msg of Bounce_Bounce_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Bounce_Bounce_Args +// struct. +func (v *Bounce_Bounce_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Msg: %v", v.Msg) + i++ + + return fmt.Sprintf("Bounce_Bounce_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Bounce_Bounce_Args match the +// provided Bounce_Bounce_Args. +// +// This function performs a deep comparison. +func (v *Bounce_Bounce_Args) Equals(rhs *Bounce_Bounce_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Msg == rhs.Msg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bounce_Bounce_Args. +func (v *Bounce_Bounce_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("msg", v.Msg) + return err +} + +// GetMsg returns the value of Msg if it is set or its +// zero value if it is unset. +func (v *Bounce_Bounce_Args) GetMsg() (o string) { + if v != nil { + o = v.Msg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "bounce" for this struct. +func (v *Bounce_Bounce_Args) MethodName() string { + return "bounce" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Bounce_Bounce_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Bounce_Bounce_Helper provides functions that aid in handling the +// parameters and return values of the Bounce.bounce +// function. +var Bounce_Bounce_Helper = struct { + // Args accepts the parameters of bounce in-order and returns + // the arguments struct for the function. + Args func( + msg string, + ) *Bounce_Bounce_Args + + // IsException returns true if the given error can be thrown + // by bounce. + // + // An error can be thrown by bounce only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for bounce + // given its return value and error. + // + // This allows mapping values and errors returned by + // bounce into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by bounce + // + // value, err := bounce(args) + // result, err := Bounce_Bounce_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from bounce: %v", err) + // } + // serialize(result) + WrapResponse func(string, error) (*Bounce_Bounce_Result, error) + + // UnwrapResponse takes the result struct for bounce + // and returns the value or error returned by it. + // + // The error is non-nil only if bounce threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Bounce_Bounce_Helper.UnwrapResponse(result) + UnwrapResponse func(*Bounce_Bounce_Result) (string, error) +}{} + +func init() { + Bounce_Bounce_Helper.Args = func( + msg string, + ) *Bounce_Bounce_Args { + return &Bounce_Bounce_Args{ + Msg: msg, + } + } + + Bounce_Bounce_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Bounce_Bounce_Helper.WrapResponse = func(success string, err error) (*Bounce_Bounce_Result, error) { + if err == nil { + return &Bounce_Bounce_Result{Success: &success}, nil + } + + return nil, err + } + Bounce_Bounce_Helper.UnwrapResponse = func(result *Bounce_Bounce_Result) (success string, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Bounce_Bounce_Result represents the result of a Bounce.bounce function call. +// +// The result of a bounce execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Bounce_Bounce_Result struct { + // Value returned by bounce after a successful execution. + Success *string `json:"success,omitempty"` +} + +// ToWire translates a Bounce_Bounce_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Bounce_Bounce_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueString(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Bounce_Bounce_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Bounce_Bounce_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Bounce_Bounce_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Bounce_Bounce_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Bounce_Bounce_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Bounce_Bounce_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Bounce_Bounce_Result +// struct. +func (v *Bounce_Bounce_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Bounce_Bounce_Result{%v}", strings.Join(fields[:i], ", ")) +} + +func _String_EqualsPtr(lhs, rhs *string) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this Bounce_Bounce_Result match the +// provided Bounce_Bounce_Result. +// +// This function performs a deep comparison. +func (v *Bounce_Bounce_Result) Equals(rhs *Bounce_Bounce_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Bounce_Bounce_Result. +func (v *Bounce_Bounce_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Bounce_Bounce_Result) GetSuccess() (o string) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Bounce_Bounce_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "bounce" for this struct. +func (v *Bounce_Bounce_Result) MethodName() string { + return "bounce" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Bounce_Bounce_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} diff --git a/examples/selective-gateway/build/gen-code/endpoints/tchannel/echo/echo/echo.go b/examples/selective-gateway/build/gen-code/endpoints/tchannel/echo/echo/echo.go new file mode 100644 index 000000000..9f1af2e35 --- /dev/null +++ b/examples/selective-gateway/build/gen-code/endpoints/tchannel/echo/echo/echo.go @@ -0,0 +1,423 @@ +// Code generated by thriftrw v1.20.2. DO NOT EDIT. +// @generated + +package echo + +import ( + errors "errors" + fmt "fmt" + strings "strings" + + wire "go.uber.org/thriftrw/wire" + zapcore "go.uber.org/zap/zapcore" +) + +// Echo_Echo_Args represents the arguments for the Echo.echo function. +// +// The arguments for echo are sent and received over the wire as this struct. +type Echo_Echo_Args struct { + Msg string `json:"msg,required"` +} + +// ToWire translates a Echo_Echo_Args struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_Echo_Args) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + w, err = wire.NewValueString(v.Msg), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 1, Value: w} + i++ + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_Echo_Args struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_Echo_Args struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_Echo_Args +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_Echo_Args) FromWire(w wire.Value) error { + var err error + + msgIsSet := false + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 1: + if field.Value.Type() == wire.TBinary { + v.Msg, err = field.Value.GetString(), error(nil) + if err != nil { + return err + } + msgIsSet = true + } + } + } + + if !msgIsSet { + return errors.New("field Msg of Echo_Echo_Args is required") + } + + return nil +} + +// String returns a readable string representation of a Echo_Echo_Args +// struct. +func (v *Echo_Echo_Args) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + fields[i] = fmt.Sprintf("Msg: %v", v.Msg) + i++ + + return fmt.Sprintf("Echo_Echo_Args{%v}", strings.Join(fields[:i], ", ")) +} + +// Equals returns true if all the fields of this Echo_Echo_Args match the +// provided Echo_Echo_Args. +// +// This function performs a deep comparison. +func (v *Echo_Echo_Args) Equals(rhs *Echo_Echo_Args) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !(v.Msg == rhs.Msg) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_Echo_Args. +func (v *Echo_Echo_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + enc.AddString("msg", v.Msg) + return err +} + +// GetMsg returns the value of Msg if it is set or its +// zero value if it is unset. +func (v *Echo_Echo_Args) GetMsg() (o string) { + if v != nil { + o = v.Msg + } + return +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the arguments. +// +// This will always be "echo" for this struct. +func (v *Echo_Echo_Args) MethodName() string { + return "echo" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Call for this struct. +func (v *Echo_Echo_Args) EnvelopeType() wire.EnvelopeType { + return wire.Call +} + +// Echo_Echo_Helper provides functions that aid in handling the +// parameters and return values of the Echo.echo +// function. +var Echo_Echo_Helper = struct { + // Args accepts the parameters of echo in-order and returns + // the arguments struct for the function. + Args func( + msg string, + ) *Echo_Echo_Args + + // IsException returns true if the given error can be thrown + // by echo. + // + // An error can be thrown by echo only if the + // corresponding exception type was mentioned in the 'throws' + // section for it in the Thrift file. + IsException func(error) bool + + // WrapResponse returns the result struct for echo + // given its return value and error. + // + // This allows mapping values and errors returned by + // echo into a serializable result struct. + // WrapResponse returns a non-nil error if the provided + // error cannot be thrown by echo + // + // value, err := echo(args) + // result, err := Echo_Echo_Helper.WrapResponse(value, err) + // if err != nil { + // return fmt.Errorf("unexpected error from echo: %v", err) + // } + // serialize(result) + WrapResponse func(string, error) (*Echo_Echo_Result, error) + + // UnwrapResponse takes the result struct for echo + // and returns the value or error returned by it. + // + // The error is non-nil only if echo threw an + // exception. + // + // result := deserialize(bytes) + // value, err := Echo_Echo_Helper.UnwrapResponse(result) + UnwrapResponse func(*Echo_Echo_Result) (string, error) +}{} + +func init() { + Echo_Echo_Helper.Args = func( + msg string, + ) *Echo_Echo_Args { + return &Echo_Echo_Args{ + Msg: msg, + } + } + + Echo_Echo_Helper.IsException = func(err error) bool { + switch err.(type) { + default: + return false + } + } + + Echo_Echo_Helper.WrapResponse = func(success string, err error) (*Echo_Echo_Result, error) { + if err == nil { + return &Echo_Echo_Result{Success: &success}, nil + } + + return nil, err + } + Echo_Echo_Helper.UnwrapResponse = func(result *Echo_Echo_Result) (success string, err error) { + + if result.Success != nil { + success = *result.Success + return + } + + err = errors.New("expected a non-void result") + return + } + +} + +// Echo_Echo_Result represents the result of a Echo.echo function call. +// +// The result of a echo execution is sent and received over the wire as this struct. +// +// Success is set only if the function did not throw an exception. +type Echo_Echo_Result struct { + // Value returned by echo after a successful execution. + Success *string `json:"success,omitempty"` +} + +// ToWire translates a Echo_Echo_Result struct into a Thrift-level intermediate +// representation. This intermediate representation may be serialized +// into bytes using a ThriftRW protocol implementation. +// +// An error is returned if the struct or any of its fields failed to +// validate. +// +// x, err := v.ToWire() +// if err != nil { +// return err +// } +// +// if err := binaryProtocol.Encode(x, writer); err != nil { +// return err +// } +func (v *Echo_Echo_Result) ToWire() (wire.Value, error) { + var ( + fields [1]wire.Field + i int = 0 + w wire.Value + err error + ) + + if v.Success != nil { + w, err = wire.NewValueString(*(v.Success)), error(nil) + if err != nil { + return w, err + } + fields[i] = wire.Field{ID: 0, Value: w} + i++ + } + + if i != 1 { + return wire.Value{}, fmt.Errorf("Echo_Echo_Result should have exactly one field: got %v fields", i) + } + + return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil +} + +// FromWire deserializes a Echo_Echo_Result struct from its Thrift-level +// representation. The Thrift-level representation may be obtained +// from a ThriftRW protocol implementation. +// +// An error is returned if we were unable to build a Echo_Echo_Result struct +// from the provided intermediate representation. +// +// x, err := binaryProtocol.Decode(reader, wire.TStruct) +// if err != nil { +// return nil, err +// } +// +// var v Echo_Echo_Result +// if err := v.FromWire(x); err != nil { +// return nil, err +// } +// return &v, nil +func (v *Echo_Echo_Result) FromWire(w wire.Value) error { + var err error + + for _, field := range w.GetStruct().Fields { + switch field.ID { + case 0: + if field.Value.Type() == wire.TBinary { + var x string + x, err = field.Value.GetString(), error(nil) + v.Success = &x + if err != nil { + return err + } + + } + } + } + + count := 0 + if v.Success != nil { + count++ + } + if count != 1 { + return fmt.Errorf("Echo_Echo_Result should have exactly one field: got %v fields", count) + } + + return nil +} + +// String returns a readable string representation of a Echo_Echo_Result +// struct. +func (v *Echo_Echo_Result) String() string { + if v == nil { + return "" + } + + var fields [1]string + i := 0 + if v.Success != nil { + fields[i] = fmt.Sprintf("Success: %v", *(v.Success)) + i++ + } + + return fmt.Sprintf("Echo_Echo_Result{%v}", strings.Join(fields[:i], ", ")) +} + +func _String_EqualsPtr(lhs, rhs *string) bool { + if lhs != nil && rhs != nil { + + x := *lhs + y := *rhs + return (x == y) + } + return lhs == nil && rhs == nil +} + +// Equals returns true if all the fields of this Echo_Echo_Result match the +// provided Echo_Echo_Result. +// +// This function performs a deep comparison. +func (v *Echo_Echo_Result) Equals(rhs *Echo_Echo_Result) bool { + if v == nil { + return rhs == nil + } else if rhs == nil { + return false + } + if !_String_EqualsPtr(v.Success, rhs.Success) { + return false + } + + return true +} + +// MarshalLogObject implements zapcore.ObjectMarshaler, enabling +// fast logging of Echo_Echo_Result. +func (v *Echo_Echo_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) { + if v == nil { + return nil + } + if v.Success != nil { + enc.AddString("success", *v.Success) + } + return err +} + +// GetSuccess returns the value of Success if it is set or its +// zero value if it is unset. +func (v *Echo_Echo_Result) GetSuccess() (o string) { + if v != nil && v.Success != nil { + return *v.Success + } + + return +} + +// IsSetSuccess returns true if Success is not nil. +func (v *Echo_Echo_Result) IsSetSuccess() bool { + return v != nil && v.Success != nil +} + +// MethodName returns the name of the Thrift function as specified in +// the IDL, for which this struct represent the result. +// +// This will always be "echo" for this struct. +func (v *Echo_Echo_Result) MethodName() string { + return "echo" +} + +// EnvelopeType returns the kind of value inside this struct. +// +// This will always be Reply for this struct. +func (v *Echo_Echo_Result) EnvelopeType() wire.EnvelopeType { + return wire.Reply +} diff --git a/examples/selective-gateway/build/middlewares/default/default_example/default_example.go b/examples/selective-gateway/build/middlewares/default/default_example/default_example.go new file mode 100644 index 000000000..8d84c49d2 --- /dev/null +++ b/examples/selective-gateway/build/middlewares/default/default_example/default_example.go @@ -0,0 +1,47 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexamplemiddleware + +import ( + module "github.com/uber/zanzibar/examples/selective-gateway/build/middlewares/default/default_example/module" + handle "github.com/uber/zanzibar/examples/selective-gateway/middlewares/default/default_example" + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Middleware is a container for module.Deps and factory for MiddlewareHandle +type Middleware struct { + Deps *module.Dependencies +} + +// NewMiddleware is a factory method for the struct +func NewMiddleware(deps *module.Dependencies) Middleware { + return Middleware{ + Deps: deps, + } +} + +// NewMiddlewareHandle calls back to the custom middleware to build a MiddlewareHandle +func (m *Middleware) NewMiddlewareHandle(o handle.Options) zanzibar.MiddlewareHandle { + return handle.NewMiddleware(m.Deps, o) +} diff --git a/examples/selective-gateway/build/middlewares/default/default_example/module/dependencies.go b/examples/selective-gateway/build/middlewares/default/default_example/module/dependencies.go new file mode 100644 index 000000000..bd9ed750a --- /dev/null +++ b/examples/selective-gateway/build/middlewares/default/default_example/module/dependencies.go @@ -0,0 +1,41 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Dependencies contains dependencies for the default/default_example middleware module +type Dependencies struct { + Default *zanzibar.DefaultDependencies + Client *ClientDependencies +} + +// ClientDependencies contains client dependencies +type ClientDependencies struct { + Echo echoclientgenerated.Client +} diff --git a/examples/selective-gateway/build/middlewares/default/default_example2/default_example2.go b/examples/selective-gateway/build/middlewares/default/default_example2/default_example2.go new file mode 100644 index 000000000..acf09819a --- /dev/null +++ b/examples/selective-gateway/build/middlewares/default/default_example2/default_example2.go @@ -0,0 +1,47 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexample2middleware + +import ( + module "github.com/uber/zanzibar/examples/selective-gateway/build/middlewares/default/default_example2/module" + handle "github.com/uber/zanzibar/examples/selective-gateway/middlewares/default/default_example2" + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Middleware is a container for module.Deps and factory for MiddlewareHandle +type Middleware struct { + Deps *module.Dependencies +} + +// NewMiddleware is a factory method for the struct +func NewMiddleware(deps *module.Dependencies) Middleware { + return Middleware{ + Deps: deps, + } +} + +// NewMiddlewareHandle calls back to the custom middleware to build a MiddlewareHandle +func (m *Middleware) NewMiddlewareHandle(o handle.Options) zanzibar.MiddlewareHandle { + return handle.NewMiddleware(m.Deps, o) +} diff --git a/examples/selective-gateway/build/middlewares/default/default_example2/module/dependencies.go b/examples/selective-gateway/build/middlewares/default/default_example2/module/dependencies.go new file mode 100644 index 000000000..0af7674f9 --- /dev/null +++ b/examples/selective-gateway/build/middlewares/default/default_example2/module/dependencies.go @@ -0,0 +1,41 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Dependencies contains dependencies for the default/default_example2 middleware module +type Dependencies struct { + Default *zanzibar.DefaultDependencies + Client *ClientDependencies +} + +// ClientDependencies contains client dependencies +type ClientDependencies struct { + Echo echoclientgenerated.Client +} diff --git a/examples/selective-gateway/build/services/selective-gateway/main/main.go b/examples/selective-gateway/build/services/selective-gateway/main/main.go new file mode 100644 index 000000000..3ea61d1ee --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/main/main.go @@ -0,0 +1,116 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package main + +import ( + "flag" + "os" + "os/signal" + "strings" + "syscall" + + _ "go.uber.org/automaxprocs" + "go.uber.org/fx" + "go.uber.org/zap" + + "github.com/uber/zanzibar/config" + zanzibar "github.com/uber/zanzibar/runtime" + + app "github.com/uber/zanzibar/examples/selective-gateway" + service "github.com/uber/zanzibar/examples/selective-gateway/build/services/selective-gateway" +) + +var configFiles *string + +func getConfig() *zanzibar.StaticConfig { + var files []string + + if configFiles == nil { + files = []string{} + } else { + files = strings.Split(*configFiles, ";") + } + + return config.NewRuntimeConfigOrDie(files, nil) +} + +func createGateway() (*zanzibar.Gateway, error) { + config := getConfig() + + gateway, _, err := service.CreateGateway(config, app.AppOptions) + if err != nil { + return nil, err + } + + return gateway, nil +} + +func logAndWait(server *zanzibar.Gateway) { + server.Logger.Info("Started Selective-gateway", + zap.String("realHTTPAddr", server.RealHTTPAddr), + zap.String("realTChannelAddr", server.RealTChannelAddr), + zap.Any("config", server.InspectOrDie()), + ) + + go func() { + sig := make(chan os.Signal, 1) + signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) + <-sig + server.WaitGroup.Add(1) + server.Shutdown() + server.WaitGroup.Done() + }() + server.Wait() +} + +func readFlags() { + configFiles = flag.String( + "config", + "", + "an ordered, semi-colon separated list of configuration files to use", + ) + flag.Parse() +} + +func main() { + app := fx.New( + fx.Invoke(zanzibarMain), + ) + app.Run() +} + +func zanzibarMain() { + readFlags() + server, err := createGateway() + if err != nil { + panic(err) + } + + err = server.Bootstrap() + if err != nil { + panic(err) + } + + logAndWait(server) +} diff --git a/examples/selective-gateway/build/services/selective-gateway/main/main_test.go b/examples/selective-gateway/build/services/selective-gateway/main/main_test.go new file mode 100644 index 000000000..432fa00ab --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/main/main_test.go @@ -0,0 +1,93 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package main + +import ( + "os" + "os/signal" + "syscall" + "testing" + + zanzibar "github.com/uber/zanzibar/runtime" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +var cachedServer *zanzibar.Gateway + +func TestMain(m *testing.M) { + readFlags() + if os.Getenv("GATEWAY_RUN_CHILD_PROCESS_TEST") != "" { + listenOnSignals() + + code := m.Run() + os.Exit(code) + } else { + os.Exit(0) + } +} + +func listenOnSignals() { + sigs := make(chan os.Signal, 1) + + signal.Notify(sigs, syscall.SIGUSR2) + + go func() { + <-sigs + + if cachedServer != nil { + cachedServer.Close() + } + }() +} + +func TestStartGateway(t *testing.T) { + testLogger := zap.New( + zapcore.NewCore( + zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()), + os.Stderr, + zap.DebugLevel, + ), + ) + + gateway, err := createGateway() + if err != nil { + testLogger.Error( + "Failed to CreateGateway in TestStartGateway()", + zap.Error(err), + ) + return + } + + cachedServer = gateway + err = gateway.Bootstrap() + if err != nil { + testLogger.Error( + "Failed to Bootstrap in TestStartGateway()", + zap.Error(err), + ) + return + } + logAndWait(gateway) +} diff --git a/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_init.go b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_init.go new file mode 100644 index 000000000..71a5a8892 --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_init.go @@ -0,0 +1,86 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package selectivegatewayservicegeneratedmock + +import ( + "github.com/golang/mock/gomock" + module "github.com/uber/zanzibar/examples/selective-gateway/build/services/selective-gateway/module" + zanzibar "github.com/uber/zanzibar/runtime" + + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo/mock-client" + bounceendpointgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce" + bounceendpointmodule "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" +) + +// MockClientNodes contains mock client dependencies +type MockClientNodes struct { + Echo *echoclientgenerated.MockClient +} + +// InitializeDependenciesMock fully initializes all dependencies in the dep tree +// for the selective-gateway service with leaf nodes being mocks +func InitializeDependenciesMock( + g *zanzibar.Gateway, + ctrl *gomock.Controller, +) (*module.DependenciesTree, *module.Dependencies, *MockClientNodes) { + tree := &module.DependenciesTree{} + + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + ContextExtractor: g.ContextExtractor, + ContextMetrics: g.ContextMetrics, + ContextLogger: g.ContextLogger, + Logger: g.Logger, + Scope: g.RootScope, + Config: g.Config, + Channel: g.Channel, + Tracer: g.Tracer, + GRPCClientDispatcher: g.GRPCClientDispatcher, + JSONWrapper: g.JSONWrapper, + } + + mockClientNodes := &MockClientNodes{ + Echo: echoclientgenerated.NewMockClient(ctrl), + } + initializedClientDependencies := &module.ClientDependenciesNodes{} + tree.Client = initializedClientDependencies + initializedClientDependencies.Echo = mockClientNodes.Echo + + initializedEndpointDependencies := &module.EndpointDependenciesNodes{} + tree.Endpoint = initializedEndpointDependencies + initializedEndpointDependencies.Bounce = bounceendpointgenerated.NewEndpoint(&bounceendpointmodule.Dependencies{ + Default: initializedDefaultDependencies, + Client: &bounceendpointmodule.ClientDependencies{ + Echo: initializedClientDependencies.Echo, + }, + }) + + dependencies := &module.Dependencies{ + Default: initializedDefaultDependencies, + Endpoint: &module.EndpointDependencies{ + Bounce: initializedEndpointDependencies.Bounce, + }, + } + + return tree, dependencies, mockClientNodes +} diff --git a/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go new file mode 100644 index 000000000..cd25ce747 --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go @@ -0,0 +1,215 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package selectivegatewayservicegeneratedmock + +import ( + "context" + "errors" + "io" + "net/http" + "os" + "path/filepath" + "testing" + "time" + + "github.com/golang/mock/gomock" + "github.com/uber/zanzibar/config" + zanzibar "github.com/uber/zanzibar/runtime" + + service "github.com/uber/zanzibar/examples/selective-gateway/build/services/selective-gateway" +) + +// MockService interface +type MockService interface { + MakeHTTPRequest( + method string, + url string, + headers map[string]string, + body io.Reader, + ) (*http.Response, error) + MakeTChannelRequest( + ctx context.Context, + thriftService string, + method string, + headers map[string]string, + req, resp zanzibar.RWTStruct, + ) (bool, map[string]string, error) + MockClients() *MockClientNodes + Server() *zanzibar.Gateway + Start() + Stop() +} + +type mockService struct { + started bool + server *zanzibar.Gateway + ctrl *gomock.Controller + mockClients *MockClientNodes + httpClient *http.Client + tChannelClient zanzibar.TChannelCaller +} + +// MustCreateTestService creates a new MockService, panics if it fails doing so. +// Optional testConfigPaths specifies runtime config files used in tests, it +// should be paths that are relative to "$GOPATH/src". +// If testConfigPaths is absent, a default test config file is used. +// The default test config file is chosen base on existence in order below: +// - "../../config/test.yaml" where current dir is the dir of service-config.yaml for the mocked service +// - "config/test.yaml" where current dir is the project root +func MustCreateTestService(t *testing.T, testConfigPaths ...string) MockService { + if len(testConfigPaths) == 0 { + configPath := filepath.Join("src", "github.com/uber/zanzibar/examples/selective-gateway/config/test.yaml") + defaultPath := filepath.Join(os.Getenv("GOPATH"), configPath) + + // This is a temporary solution for running tests using bazel + // see https://docs.bazel.build/versions/master/test-encyclopedia.html for relevant env vars + // TODO: need long term solution to avoid hardcoding bazel specifics + bazelPath := filepath.Join(os.Getenv("TEST_SRCDIR"), os.Getenv("TEST_WORKSPACE"), configPath) + + testConfigPaths = append( + testConfigPaths, + defaultPath, + bazelPath, + ) + } + c := config.NewRuntimeConfigOrDie(testConfigPaths, nil) + + server, err := zanzibar.CreateGateway(c, nil) + if err != nil { + panic(err) + } + + ctrl := gomock.NewController(t) + _, dependencies, mockNodes := InitializeDependenciesMock(server, ctrl) + registerErr := service.RegisterDeps(server, dependencies) + if registerErr != nil { + panic(registerErr) + } + + httpClient := &http.Client{ + Transport: &http.Transport{ + DisableKeepAlives: false, + MaxIdleConns: 500, + MaxIdleConnsPerHost: 500, + }, + } + + // TChannel clients must have a timeout defined, so defining a long timeout that should not realistically + // be hit in tests. + timeout := time.Duration(5) * time.Minute + timeoutPerAttempt := time.Duration(1) * time.Minute + + tchannelClient := zanzibar.NewRawTChannelClient( + server.Channel, + server.Logger, + server.RootScope, + &zanzibar.TChannelClientOption{ + ServiceName: server.ServiceName, + ClientID: "TestClient", + Timeout: timeout, + TimeoutPerAttempt: timeoutPerAttempt, + }, + ) + + return &mockService{ + server: server, + ctrl: ctrl, + mockClients: mockNodes, + httpClient: httpClient, + tChannelClient: tchannelClient, + } +} + +// Server returns the mock server +func (m *mockService) Server() *zanzibar.Gateway { + return m.server +} + +// Start starts the mock server, panics if fails doing so +func (m *mockService) Start() { + if err := m.server.Bootstrap(); err != nil { + panic(err) + } + m.started = true +} + +// Stop stops the mock server +func (m *mockService) Stop() { + // m.ctrl.Finish() calls runtime.Goexit() on errors + // put it in defer so cleanup is always done + defer func() { + m.server.Shutdown() + m.started = false + }() + m.ctrl.Finish() +} + +// MockClients returns the mock clients +func (m *mockService) MockClients() *MockClientNodes { + return m.mockClients +} + +// MakeHTTPRequest makes a HTTP request to the mock server +func (m *mockService) MakeHTTPRequest( + method string, + url string, + headers map[string]string, + body io.Reader, +) (*http.Response, error) { + if !m.started { + return nil, errors.New("mock server is not started") + } + + client := m.httpClient + + fullURL := "http://" + m.server.RealHTTPAddr + url + + req, err := http.NewRequest(method, fullURL, body) + for headerName, headerValue := range headers { + req.Header.Set(headerName, headerValue) + } + + if err != nil { + return nil, err + } + + return client.Do(req) +} + +// MakeTChannelRequest makes a TChannel request to the mock server +func (m *mockService) MakeTChannelRequest( + ctx context.Context, + thriftService string, + method string, + headers map[string]string, + req, res zanzibar.RWTStruct, +) (bool, map[string]string, error) { + if !m.started { + return false, nil, errors.New("mock server is not started") + } + + sc := m.server.Channel.GetSubChannel(m.server.ServiceName) + sc.Peers().Add(m.server.RealTChannelAddr) + return m.tChannelClient.Call(ctx, thriftService, method, headers, req, res) +} diff --git a/examples/selective-gateway/build/services/selective-gateway/module/dependencies.go b/examples/selective-gateway/build/services/selective-gateway/module/dependencies.go new file mode 100644 index 000000000..0be7d545a --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/module/dependencies.go @@ -0,0 +1,41 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + bounceendpointgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// Dependencies contains dependencies for the selective-gateway service module +type Dependencies struct { + Default *zanzibar.DefaultDependencies + Endpoint *EndpointDependencies +} + +// EndpointDependencies contains endpoint dependencies +type EndpointDependencies struct { + Bounce bounceendpointgenerated.Endpoint +} diff --git a/examples/selective-gateway/build/services/selective-gateway/module/init.go b/examples/selective-gateway/build/services/selective-gateway/module/init.go new file mode 100644 index 000000000..b39bc5aa3 --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/module/init.go @@ -0,0 +1,95 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package module + +import ( + echoclientgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + echoclientmodule "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo/module" + bounceendpointgenerated "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce" + bounceendpointmodule "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" + + zanzibar "github.com/uber/zanzibar/runtime" +) + +// DependenciesTree contains all deps for this service. +type DependenciesTree struct { + Client *ClientDependenciesNodes + Endpoint *EndpointDependenciesNodes +} + +// ClientDependenciesNodes contains client dependencies +type ClientDependenciesNodes struct { + Echo echoclientgenerated.Client +} + +// EndpointDependenciesNodes contains endpoint dependencies +type EndpointDependenciesNodes struct { + Bounce bounceendpointgenerated.Endpoint +} + +// InitializeDependencies fully initializes all dependencies in the dep tree +// for the selective-gateway service +func InitializeDependencies( + g *zanzibar.Gateway, +) (*DependenciesTree, *Dependencies) { + tree := &DependenciesTree{} + + initializedDefaultDependencies := &zanzibar.DefaultDependencies{ + Logger: g.Logger, + ContextExtractor: g.ContextExtractor, + ContextLogger: g.ContextLogger, + ContextMetrics: zanzibar.NewContextMetrics(g.RootScope), + Scope: g.RootScope, + Tracer: g.Tracer, + Config: g.Config, + Channel: g.Channel, + + GRPCClientDispatcher: g.GRPCClientDispatcher, + JSONWrapper: g.JSONWrapper, + } + + initializedClientDependencies := &ClientDependenciesNodes{} + tree.Client = initializedClientDependencies + initializedClientDependencies.Echo = echoclientgenerated.NewClient(&echoclientmodule.Dependencies{ + Default: initializedDefaultDependencies, + }) + + initializedEndpointDependencies := &EndpointDependenciesNodes{} + tree.Endpoint = initializedEndpointDependencies + initializedEndpointDependencies.Bounce = bounceendpointgenerated.NewEndpoint(&bounceendpointmodule.Dependencies{ + Default: initializedDefaultDependencies, + Client: &bounceendpointmodule.ClientDependencies{ + Echo: initializedClientDependencies.Echo, + }, + }) + + dependencies := &Dependencies{ + Default: initializedDefaultDependencies, + Endpoint: &EndpointDependencies{ + Bounce: initializedEndpointDependencies.Bounce, + }, + } + + return tree, dependencies +} diff --git a/examples/selective-gateway/build/services/selective-gateway/service.go b/examples/selective-gateway/build/services/selective-gateway/service.go new file mode 100644 index 000000000..aa54d8270 --- /dev/null +++ b/examples/selective-gateway/build/services/selective-gateway/service.go @@ -0,0 +1,64 @@ +// Code generated by zanzibar +// @generated + +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package selectivegatewayservicegenerated + +import ( + zanzibar "github.com/uber/zanzibar/runtime" + + module "github.com/uber/zanzibar/examples/selective-gateway/build/services/selective-gateway/module" +) + +// DependenciesTree re-exported for convenience. +type DependenciesTree module.DependenciesTree + +// CreateGateway creates a new instances of the selective-gateway +// service with the specified config +func CreateGateway( + config *zanzibar.StaticConfig, + opts *zanzibar.Options, +) (*zanzibar.Gateway, interface{}, error) { + gateway, err := zanzibar.CreateGateway(config, opts) + if err != nil { + return nil, nil, err + } + + tree, dependencies := module.InitializeDependencies(gateway) + registerErr := RegisterDeps(gateway, dependencies) + if registerErr != nil { + return nil, nil, registerErr + } + + return gateway, (*DependenciesTree)(tree), nil +} + +// RegisterDeps registers direct dependencies of the service +func RegisterDeps(g *zanzibar.Gateway, deps *module.Dependencies) error { + //lint:ignore S1021 allow less concise variable declaration for ease of code generation + var err error + err = deps.Endpoint.Bounce.Register(g) + if err != nil { + return err + } + return nil +} diff --git a/examples/selective-gateway/clients/bar/client-config.json b/examples/selective-gateway/clients/bar/client-config.json new file mode 100644 index 000000000..ad9b8723c --- /dev/null +++ b/examples/selective-gateway/clients/bar/client-config.json @@ -0,0 +1,44 @@ +{ + "name": "bar", + "type": "http", + "config": { + "idlFile": "clients/bar/bar.thrift", + "idlFileSha": "{{placeholder}}", + "exposedMethods": { + "Normal": "Bar::normal", + "NormalRecur": "Bar::normalRecur", + "NoRequest": "Bar::noRequest", + "MissingArg": "Bar::missingArg", + "TooManyArgs": "Bar::tooManyArgs", + "ArgNotStruct": "Bar::argNotStruct", + "ArgWithHeaders": "Bar::argWithHeaders", + "ArgWithQueryParams": "Bar::argWithQueryParams", + "ArgWithNestedQueryParams": "Bar::argWithNestedQueryParams", + "ArgWithNearDupQueryParams": "Bar::argWithNearDupQueryParams", + "ArgWithQueryHeader": "Bar::argWithQueryHeader", + "ArgWithManyQueryParams": "Bar::argWithManyQueryParams", + "ArgWithParams": "Bar::argWithParams", + "ArgWithParamsAndDuplicateFields": "Bar::argWithParamsAndDuplicateFields", + "Hello": "Bar::helloWorld", + "DeleteFoo": "Bar::deleteFoo", + "DeleteWithQueryParams": "Bar::deleteWithQueryParams", + "ListAndEnum": "Bar::listAndEnum", + "EchoI8": "Echo::echoI8", + "EchoI16": "Echo::echoI16", + "EchoI32": "Echo::echoI32", + "EchoI64": "Echo::echoI64", + "EchoDouble": "Echo::echoDouble", + "EchoBool": "Echo::echoBool", + "EchoBinary": "Echo::echoBinary", + "EchoString": "Echo::echoString", + "EchoEnum": "Echo::echoEnum", + "EchoTypedef": "Echo::echoTypedef", + "EchoStringSet": "Echo::echoStringSet", + "EchoStructSet": "Echo::echoStructSet", + "EchoStringList": "Echo::echoStringList", + "EchoStructList": "Echo::echoStructList", + "EchoI32Map": "Echo::echoI32Map", + "EchoStringMap": "Echo::echoStringMap" + } + } +} diff --git a/examples/selective-gateway/clients/echo/client-config.yaml b/examples/selective-gateway/clients/echo/client-config.yaml new file mode 100644 index 000000000..bc27aa61b --- /dev/null +++ b/examples/selective-gateway/clients/echo/client-config.yaml @@ -0,0 +1,6 @@ +name: echo +type: grpc +config: + idlFile: clients/echo/echo.proto + exposedMethods: + "EchoEcho": "Echo::Echo" diff --git a/examples/selective-gateway/config/production.json b/examples/selective-gateway/config/production.json new file mode 100644 index 000000000..e612d3e2c --- /dev/null +++ b/examples/selective-gateway/config/production.json @@ -0,0 +1,30 @@ +{ + "clients.bar.defaultHeaders": { + "X-Client-ID": "bar" + }, + "clients.bar.ip": "127.0.0.1", + "clients.bar.port": 4001, + "clients.bar.timeout": 10000, + "clients.baz.ip": "127.0.0.1", + "clients.baz.port": 4002, + "envVarsToTagInRootScope": [], + "http.port": 7783, + "http.clients.requestUUIDHeaderKey": "x-request-uuid", + "logger.fileName": "/var/log/selective-gateway/selective-gateway.log", + "logger.output": "disk", + "metrics.serviceName": "selective-gateway", + "metrics.m3.includeHost": true, + "service.env.config": {}, + "serviceName": "selective-gateway", + "sidecarRouter.default.http.ip": "127.0.0.1", + "sidecarRouter.default.http.port": 4999, + "sidecarRouter.default.http.calleeHeader": "RPC-Service", + "sidecarRouter.default.http.callerHeader": "RPC-Caller", + "sidecarRouter.default.tchannel.ip": "127.0.0.1", + "sidecarRouter.default.tchannel.port": 5000, + "tchannel.port": 7784, + "tchannel.processName": "selective-gateway", + "tchannel.serviceName": "selective-gateway", + "tchannel.clients.requestUUIDHeaderKey": "x-request-uuid", + "useDatacenter": false +} diff --git a/examples/selective-gateway/config/production.yaml b/examples/selective-gateway/config/production.yaml new file mode 100644 index 000000000..b5cdc0829 --- /dev/null +++ b/examples/selective-gateway/config/production.yaml @@ -0,0 +1,50 @@ +clients.bar.defaultHeaders: + X-Client-ID: bar +clients.bar.ip: 127.0.0.1 +clients.bar.port: 4001 +clients.bar.timeout: 10000 +envVarsToTagInRootScope: [] +http.defaultHeaders: + Accept: application/json + Content-Type: application/json +http.port: 7783 +http.clients.requestUUIDHeaderKey: x-request-uuid +logger.fileName: /var/log/selective-gateway/selective-gateway.log +logger.output: disk +metrics.serviceName: selective-gateway +metrics.m3.includeHost: true +service.env.config: {} +serviceName: selective-gateway +sidecarRouter.default.grpc.ip: 127.0.0.1 +sidecarRouter.default.grpc.port: 4998 +sidecarRouter.default.http.calleeHeader: RPC-Service +sidecarRouter.default.http.callerHeader: RPC-Caller +sidecarRouter.default.http.ip: 127.0.0.1 +sidecarRouter.default.http.port: 4999 +sidecarRouter.default.tchannel.ip: 127.0.0.1 +sidecarRouter.default.tchannel.port: 5000 +tchannel.port: 7784 +tchannel.processName: selective-gateway +tchannel.serviceName: selective-gateway +tchannel.clients.requestUUIDHeaderKey: x-request-uuid +useDatacenter: false +clients.baz.alternates: + routingConfigs: + - headerName: x-container + headerValue: ^sandbox$ + serviceName: basicSandbox + rd: reverse-proxy + - headerName: x-test-env + headerValue: ^sandbox$ + serviceName: nomatch + servicesDetail: + basicSandbox: + ip: 127.0.0.1 + port: 8113 + nomatch: + ip: 127.0.0.1 + port: 8114 +grpc.clientServiceNameMapping: + echo: echo +router.whitelistedPaths: + - /path/whitelisted diff --git a/examples/selective-gateway/config/test.json b/examples/selective-gateway/config/test.json new file mode 100644 index 000000000..0c47ed55a --- /dev/null +++ b/examples/selective-gateway/config/test.json @@ -0,0 +1,31 @@ +{ + "clients.bar.defaultHeaders": { + "X-Client-ID": "bar" + }, + "clients.bar.ip": "127.0.0.1", + "clients.bar.port": 4001, + "clients.bar.timeout": 10000, + "envVarsToTagInRootScope": [], + "env": "test", + "http.port": 0, + "http.clients.requestUUIDHeaderKey": "x-request-uuid", + "logger.fileName": "/tmp/selective-gateway.log", + "logger.output": "disk", + "logger.level": "debug", + "metrics.serviceName": "selective-gateway", + "metrics.m3.includeHost": true, + "service.env.config": {}, + "serviceName": "selective-gateway", + "sidecarRouter.default.http.ip": "127.0.0.1", + "sidecarRouter.default.http.port": 4999, + "sidecarRouter.default.http.calleeHeader": "RPC-Service", + "sidecarRouter.default.http.callerHeader": "RPC-Caller", + "sidecarRouter.default.tchannel.ip": "127.0.0.1", + "sidecarRouter.default.tchannel.port": 5000, + "tchannel.port": 0, + "tchannel.processName": "selective-gateway", + "tchannel.serviceName": "selective-gateway", + "tchannel.clients.requestUUIDHeaderKey": "x-request-uuid", + "useDatacenter": false, + "shutdown.pollInterval": 10 +} diff --git a/examples/selective-gateway/config/test.yaml b/examples/selective-gateway/config/test.yaml new file mode 100644 index 000000000..22a2f6aa2 --- /dev/null +++ b/examples/selective-gateway/config/test.yaml @@ -0,0 +1,50 @@ +clients.bar.defaultHeaders: + X-Client-ID: bar +clients.bar.ip: 127.0.0.1 +clients.bar.port: 4001 +clients.bar.timeout: 10000 +env: test +envVarsToTagInRootScope: [] +http.defaultHeaders: + Accept: application/json + Content-Type: application/json +http.port: 0 +http.clients.requestUUIDHeaderKey: x-request-uuid +logger.fileName: /tmp/selective-gateway.log +logger.output: disk +logger.level: debug +metrics.serviceName: selective-gateway +metrics.m3.includeHost: false +service.env.config: {} +serviceName: selective-gateway +shutdown.pollInterval: 10 +sidecarRouter.default.grpc.ip: 127.0.0.1 +sidecarRouter.default.grpc.port: 4998 +sidecarRouter.default.http.calleeHeader: RPC-Service +sidecarRouter.default.http.callerHeader: RPC-Caller +sidecarRouter.default.http.ip: 127.0.0.1 +sidecarRouter.default.http.port: 4999 +sidecarRouter.default.tchannel.ip: 127.0.0.1 +sidecarRouter.default.tchannel.port: 5000 +tchannel.port: 0 +tchannel.processName: selective-gateway +tchannel.serviceName: selective-gateway +tchannel.clients.requestUUIDHeaderKey: x-request-uuid +useDatacenter: false +clients.baz.alternates: + routingConfigs: + - headerName: x-container + headerValue: ^sandbox$ + serviceName: basicSandbox + - headerName: x-test-env + headerValue: ^sandbox$ + serviceName: nomatch + servicesDetail: + basicSandbox: + ip: 127.0.0.1 + port: 8113 + nomatch: + ip: 127.0.0.1 + port: 8114 +grpc.clientServiceNameMapping: + echo: echo diff --git a/examples/selective-gateway/copyright_header.txt b/examples/selective-gateway/copyright_header.txt new file mode 100644 index 000000000..2505b5140 --- /dev/null +++ b/examples/selective-gateway/copyright_header.txt @@ -0,0 +1,19 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. \ No newline at end of file diff --git a/examples/selective-gateway/endpoints/bounce/bounce.go b/examples/selective-gateway/endpoints/bounce/bounce.go new file mode 100644 index 000000000..599f243c7 --- /dev/null +++ b/examples/selective-gateway/endpoints/bounce/bounce.go @@ -0,0 +1,56 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package bounce + +import ( + "context" + + echoclient "github.com/uber/zanzibar/examples/selective-gateway/build/clients/echo" + "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/module" + "github.com/uber/zanzibar/examples/selective-gateway/build/endpoints/bounce/workflow" + "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/echo" + "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce" + zanzibar "github.com/uber/zanzibar/runtime" +) + +// NewBounceBounceWorkflow ... +func NewBounceBounceWorkflow(deps *module.Dependencies) workflow.BounceBounceWorkflow { + return &bounceWorkflow{ + echo: deps.Client.Echo, + } +} + +type bounceWorkflow struct { + echo echoclient.Client +} + +// Handle ... +func (w bounceWorkflow) Handle( + ctx context.Context, + reqHeaders zanzibar.Header, + req *bounce.Bounce_Bounce_Args, +) (string, zanzibar.Header, error) { + res, err := w.echo.Echo(ctx, &echo.Request{Message: req.Msg}) + if err != nil { + return "", nil, err + } + return res.Message, nil, nil +} diff --git a/examples/selective-gateway/endpoints/bounce/bounce.yaml b/examples/selective-gateway/endpoints/bounce/bounce.yaml new file mode 100644 index 000000000..bec4bd2b6 --- /dev/null +++ b/examples/selective-gateway/endpoints/bounce/bounce.yaml @@ -0,0 +1,8 @@ +endpointId: bounce +endpointType: tchannel +handleId: bounce +thriftFile: endpoints/bounce/bounce.thrift +thriftFileSha: '{{placeholder}}' +thriftMethodName: Bounce::bounce +workflowImportPath: github.com/uber/zanzibar/examples/selective-gateway/endpoints/bounce +workflowType: custom \ No newline at end of file diff --git a/examples/selective-gateway/endpoints/bounce/bounce_test.go b/examples/selective-gateway/endpoints/bounce/bounce_test.go new file mode 100644 index 000000000..797c4e264 --- /dev/null +++ b/examples/selective-gateway/endpoints/bounce/bounce_test.go @@ -0,0 +1,40 @@ +package bounce_test + +import ( + "context" + "testing" + + mock "github.com/uber/zanzibar/examples/selective-gateway/build/services/selective-gateway/mock-service" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/clients/echo" + "github.com/uber/zanzibar/examples/selective-gateway/build/gen-code/endpoints/bounce/bounce" +) + +func TestEcho(t *testing.T) { + ms := mock.MustCreateTestService(t) + ms.Start() + defer ms.Stop() + + message := "hello" + args := &bounce.Bounce_Bounce_Args{ + Msg: message, + } + + ctx := context.Background() + var result bounce.Bounce_Bounce_Result + + ms.MockClients().Echo.EXPECT().Echo(gomock.Any(), &echo.Request{Message: message}). + Return(&echo.Response{Message: message}, nil) + + success, resHeaders, err := ms.MakeTChannelRequest( + ctx, "Bounce", "bounce", nil, args, &result, + ) + require.NoError(t, err, "got tchannel error") + + assert.True(t, success) + assert.Nil(t, resHeaders) + assert.Equal(t, message, *result.Success) +} diff --git a/examples/selective-gateway/endpoints/bounce/endpoint-config.yaml b/examples/selective-gateway/endpoints/bounce/endpoint-config.yaml new file mode 100644 index 000000000..172c859de --- /dev/null +++ b/examples/selective-gateway/endpoints/bounce/endpoint-config.yaml @@ -0,0 +1,8 @@ +name: bounce +type: tchannel +config: + endpoints: + - ./bounce.yaml +dependencies: + client: + - echo diff --git a/examples/selective-gateway/endpoints/tchannel/echo/echo.yaml b/examples/selective-gateway/endpoints/tchannel/echo/echo.yaml new file mode 100644 index 000000000..f7359faba --- /dev/null +++ b/examples/selective-gateway/endpoints/tchannel/echo/echo.yaml @@ -0,0 +1,8 @@ +endpointId: echo +endpointType: tchannel +handleId: echo +thriftFile: endpoints/tchannel/echo/echo.thrift +thriftFileSha: '{{placeholder}}' +thriftMethodName: Echo::echo +workflowImportPath: github.com/uber/zanzibar/examples/selective-gateway/endpoints/tchannel/echo +workflowType: custom diff --git a/examples/selective-gateway/endpoints/tchannel/echo/endpoint-config.yaml b/examples/selective-gateway/endpoints/tchannel/echo/endpoint-config.yaml new file mode 100644 index 000000000..d8fc32bb6 --- /dev/null +++ b/examples/selective-gateway/endpoints/tchannel/echo/endpoint-config.yaml @@ -0,0 +1,8 @@ +config: + endpoints: + - echo.yaml +dependencies: + client: + - bar +name: echo +type: tchannel diff --git a/examples/selective-gateway/idl/clients/bar/bar.thrift b/examples/selective-gateway/idl/clients/bar/bar.thrift new file mode 100644 index 000000000..ffed2bdec --- /dev/null +++ b/examples/selective-gateway/idl/clients/bar/bar.thrift @@ -0,0 +1,456 @@ +namespace java com.uber.zanzibar.clients.bar + +include "../foo/foo.thrift" + +typedef string UUID +typedef i64 (json.type = 'Date') Timestamp +typedef i64 (json.type = "Long") Long +typedef list StringList +typedef list UUIDList + +enum Fruit { + APPLE, + BANANA +} + +struct BarRequest { + 1: required string stringField + 2: required bool boolField + 3: required binary binaryField + 4: required Timestamp timestamp + 5: required Fruit enumField + 6: required Long longField +} + +struct RequestWithDuplicateType { + 1: optional BarRequest request1 + 2: optional BarRequest request2 +} + +struct BarResponse { + 1: required string stringField ( + zanzibar.http.ref = "headers.some-header-field" + zanzibar.validation.type = "object,number" + ) + 2: required i32 intWithRange + 3: required i32 intWithoutRange (zanzibar.ignore.integer.range = "true") + 4: required map mapIntWithRange + 5: required map mapIntWithoutRange ( + zanzibar.ignore.integer.range = "true" + ) + 6: required binary binaryField + 7: optional BarResponse nextResponse +} + +struct BarRequestRecur { + 1: required string name + 2: optional BarRequestRecur recur +} + +struct BarResponseRecur { + 1: required list nodes + 2: required i32 height +} + +struct QueryParamsStruct { + 1: required string name + 2: optional string userUUID + // TODO: support header annotation + 3: optional string authUUID + 4: optional string authUUID2 (zanzibar.http.ref = "query.myuuid") + 5: required list foo +} + +struct QueryParamsOptsStruct { + 1: required string name + 2: optional string userUUID + 3: optional string authUUID + 4: optional string authUUID2 +} + +struct ParamsStruct { + 1: required string userUUID (zanzibar.http.ref = "params.user-uuid") +} + +struct OptionalParamsStruct { + 1: optional string userID (zanzibar.http.ref = "headers.user-id") +} + + +enum DemoType { + FIRST, + SECOND +} + +exception BarException { + 1: required string stringField (zanzibar.http.ref = "headers.another-header-field") +} + +service Bar { + string helloWorld( + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/hello" + zanzibar.http.status = "200" + ) + + string listAndEnum ( + 1: required list demoIds + 2: optional DemoType demoType + 3: optional list demos + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/list-and-enum" + zanzibar.http.status = "200" + ) + + BarResponse normal ( + 1: required BarRequest request + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/bar-path" + zanzibar.http.status = "200" + ) + + BarResponseRecur normalRecur ( + 1: required BarRequestRecur request + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/bar/recur" + zanzibar.http.status = "200" + ) + + BarResponse noRequest ( + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/no-request-path" + zanzibar.http.status = "200" + ) + BarResponse missingArg ( + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/missing-arg-path" + zanzibar.http.status = "200" + ) + BarResponse tooManyArgs ( + 1: required BarRequest request + 2: optional foo.FooStruct foo + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + 2: foo.FooException fooException (zanzibar.http.status = "418") + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/too-many-args-path" + zanzibar.http.status = "200" + ) + void argNotStruct ( + 1: required string request + ) throws ( + 1: BarException barException (zanzibar.http.status = "403") + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/arg-not-struct-path" + zanzibar.http.status = "200" + ) + + // TODO: support headers annotation + BarResponse argWithHeaders ( + 1: required string name ( + zanzibar.http.ref = "headers.name" + go.tag = "json:\"-\"" + ) + 2: optional string userUUID ( + zanzibar.http.ref = "headers.x-uuid" + go.tag = "json:\"-\"" + ) + 3: optional OptionalParamsStruct paramsStruct + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/bar/argWithHeaders" + zanzibar.http.status = "200" + ) + + BarResponse argWithQueryParams( + 1: required string name (zanzibar.http.ref = "query.name") + 2: optional string userUUID (zanzibar.http.ref = "query.userUUID") + 3: optional list foo (zanzibar.http.ref = "query.foo") + 4: required list bar (zanzibar.http.ref = "query.bar") + // TODO(argouber): Actually allow sets - preferably with go.tag of slice + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/argWithQueryParams" + zanzibar.http.status = "200" + ) + + BarResponse argWithNestedQueryParams( + 1: required QueryParamsStruct request + 2: optional QueryParamsOptsStruct opt + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/argWithNestedQueryParams" + zanzibar.http.status = "200" + ) + + // TODO: support headers annotation + BarResponse argWithQueryHeader( + 1: optional string userUUID + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/bar/argWithQueryHeader" + zanzibar.http.status = "200" + ) + + BarResponse argWithParams( + 1: required string uuid (zanzibar.http.ref = "params.uuid") + 2: optional ParamsStruct params + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/argWithParams/:uuid/segment/:user-uuid" + zanzibar.http.status = "200" + ) + + BarResponse argWithManyQueryParams( + 1: required string aStr (zanzibar.http.ref = "query.aStr") + 2: optional string anOptStr (zanzibar.http.ref = "query.anOptStr") + 3: required bool aBool (zanzibar.http.ref = "query.aBoolean") + 4: optional bool anOptBool (zanzibar.http.ref = "query.anOptBool") + 5: required i8 aInt8 (zanzibar.http.ref = "query.aInt8") + 6: optional i8 anOptInt8 (zanzibar.http.ref = "query.anOptInt8") + 7: required i16 aInt16 (zanzibar.http.ref = "query.aInt16") + 8: optional i16 anOptInt16 (zanzibar.http.ref = "query.anOptInt16") + 9: required i32 aInt32 (zanzibar.http.ref = "query.aInt32") + 10: optional i32 anOptInt32 (zanzibar.http.ref = "query.anOptInt32") + 11: required i64 aInt64 (zanzibar.http.ref = "query.aInt64") + 12: optional i64 anOptInt64 (zanzibar.http.ref = "query.anOptInt64") + 13: required double aFloat64 (zanzibar.http.ref = "query.aFloat64") + 14: optional double anOptFloat64 (zanzibar.http.ref = "query.anOptFloat64") + 15: required UUID aUUID (zanzibar.http.ref = "query.aUUID") + 16: optional UUID anOptUUID (zanzibar.http.ref = "query.anOptUUID") + 17: required list aListUUID (zanzibar.http.ref = "query.aListUUID") + 18: optional list anOptListUUID (zanzibar.http.ref = "query.anOptListUUID") + 19: required StringList aStringList (zanzibar.http.ref = "query.aStringList") + 20: optional StringList anOptStringList (zanzibar.http.ref = "query.anOptStringList") + 21: required UUIDList aUUIDList (zanzibar.http.ref = "query.aUUIDList") + 22: optional UUIDList anOptUUIDList (zanzibar.http.ref = "query.anOptUUIDList") + 23: required Timestamp aTs (zanzibar.http.ref = "query.aTs") + 24: optional Timestamp anOptTs (zanzibar.http.ref = "query.anOptTs") + 25: required DemoType aReqDemo + 26: optional Fruit anOptFruit + 27: required list aReqFruits + 28: optional list anOptDemos + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/argWithManyQueryParams" + zanzibar.http.status = "200" + ) + + BarResponse argWithParamsAndDuplicateFields( + 1: required RequestWithDuplicateType request + 2: required string entityUUID (zanzibar.http.ref = "params.uuid") + ) ( + zanzibar.http.method = "POST" + zanzibar.http.path = "/bar/argWithParamsAndDuplicateFields/:uuid/segment" + zanzibar.http.status = "200" + ) + + BarResponse argWithNearDupQueryParams( + 1: required string one + 2: optional i32 two + 3: string three (zanzibar.http.ref = "query.One_NamE") + 4: optional string four (zanzibar.http.ref = "query.one-Name") + ) ( + zanzibar.http.method = "GET" + zanzibar.http.path = "/bar/clientArgWithNearDupQueryParams" + zanzibar.http.status = "200" + ) + + void deleteFoo( + 1: required string userUUID (zanzibar.http.ref = "headers.x-uuid") + ) ( + zanzibar.http.method = "DELETE" + zanzibar.http.path = "/bar/foo" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.status = "200" + ) + + void deleteWithQueryParams( + 2: required string filter (zanzibar.http.ref = "query.filter") + 3: optional i32 count (zanzibar.http.ref = "query.count") + ) ( + zanzibar.http.method = "DELETE" + zanzibar.http.path = "/bar/withQueryParams" + zanzibar.http.status = "200" + ) + +} + +service Echo { + i8 echoI8 ( + 1: required i8 arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/i8" + zanzibar.http.status = "200" + ) + + i16 echoI16( + 1: required i16 arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/i16" + zanzibar.http.status = "200" + ) + + i32 echoI32( + 1: required i32 arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/i32" + zanzibar.http.status = "200" + ) + + i64 echoI64( + 1: required i64 arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/i64" + zanzibar.http.status = "200" + ) + + double echoDouble( + 1: required double arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/double" + zanzibar.http.status = "200" + ) + + bool echoBool ( + 1: required bool arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/bool" + zanzibar.http.status = "200" + ) + + binary echoBinary ( + 1: required binary arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/binary" + zanzibar.http.status = "200" + ) + + string echoString( + 1: required string arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/string" + zanzibar.http.status = "200" + ) + + Fruit echoEnum ( + 1: required Fruit arg = Fruit.APPLE + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/enum" + zanzibar.http.status = "200" + ) + + UUID echoTypedef( + 1: required UUID arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/typedef" + zanzibar.http.status = "200" + ) + + set echoStringSet( + 1: required set arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/string-set" + zanzibar.http.status = "200" + ) + + // value is unhashable + set echoStructSet( + 1: required set arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/struct-set" + zanzibar.http.status = "200" + ) + + list echoStringList ( + 1: required list arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/string-list" + zanzibar.http.status = "200" + ) + + list echoStructList ( + 1: required list arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/struct-list" + zanzibar.http.status = "200" + ) + + map echoI32Map ( + 1: required map arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/i32-map" + zanzibar.http.status = "200" + ) + + map echoStringMap ( + 1: required map arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/string-map" + zanzibar.http.status = "200" + ) + + // key is unhashable + // TODO: mockgen can't deal this, https://github.com/golang/mock/issues/153 + map echoStructMap ( + 1: required map arg + ) ( + zanzibar.http.method = "POST" + zanzibar.http.reqHeaders = "x-uuid" + zanzibar.http.path = "/echo/struct-map" + zanzibar.http.status = "200" + ) +} diff --git a/examples/selective-gateway/idl/clients/echo/echo.proto b/examples/selective-gateway/idl/clients/echo/echo.proto new file mode 100644 index 000000000..b9cecbe79 --- /dev/null +++ b/examples/selective-gateway/idl/clients/echo/echo.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package echo; + +message Request { + string message = 1; +} + +message Response { + string message = 1; +} + +service Echo { + rpc Echo(Request) returns (Response); +} \ No newline at end of file diff --git a/examples/selective-gateway/idl/clients/foo/base/base.thrift b/examples/selective-gateway/idl/clients/foo/base/base.thrift new file mode 100644 index 000000000..2dafd1230 --- /dev/null +++ b/examples/selective-gateway/idl/clients/foo/base/base.thrift @@ -0,0 +1,5 @@ +namespace java com.uber.zanzibar.clients.foo.base + +struct Message { + 1: required string body +} diff --git a/examples/selective-gateway/idl/clients/foo/foo.thrift b/examples/selective-gateway/idl/clients/foo/foo.thrift new file mode 100644 index 000000000..b1705faaa --- /dev/null +++ b/examples/selective-gateway/idl/clients/foo/foo.thrift @@ -0,0 +1,21 @@ +namespace java com.uber.zanzibar.clients.foo + +include "base/base.thrift" + +struct FooName { + 1: optional string name +} + +struct FooStruct { + 1: required string fooString + 2: optional i32 fooI32 + 3: optional i16 fooI16 + 4: optional double fooDouble + 5: optional bool fooBool + 6: optional map fooMap + 7: optional base.Message message +} + +exception FooException { + 1: required string teapot +} \ No newline at end of file diff --git a/examples/selective-gateway/idl/endpoints/bounce/bounce.thrift b/examples/selective-gateway/idl/endpoints/bounce/bounce.thrift new file mode 100644 index 000000000..ab6be4021 --- /dev/null +++ b/examples/selective-gateway/idl/endpoints/bounce/bounce.thrift @@ -0,0 +1,7 @@ +namespace java com.uber.zanzibar.endpoint.bounce + +service Bounce { + string bounce( + 1: required string msg + ) +} diff --git a/examples/selective-gateway/idl/endpoints/tchannel/echo/echo.thrift b/examples/selective-gateway/idl/endpoints/tchannel/echo/echo.thrift new file mode 100644 index 000000000..fcb154af9 --- /dev/null +++ b/examples/selective-gateway/idl/endpoints/tchannel/echo/echo.thrift @@ -0,0 +1,7 @@ +namespace java com.uber.zanzibar.endpoint.echo + +service Echo { + string echo( + 1: required string msg + ) +} diff --git a/examples/selective-gateway/middlewares/default.yaml b/examples/selective-gateway/middlewares/default.yaml new file mode 100644 index 000000000..562fb5ef8 --- /dev/null +++ b/examples/selective-gateway/middlewares/default.yaml @@ -0,0 +1,4 @@ +# Middlewares in the ./middlewares/default folder will be executed in the order listed here +http: + - default_example2 + - default_example diff --git a/examples/selective-gateway/middlewares/default/default_example/default_example.go b/examples/selective-gateway/middlewares/default/default_example/default_example.go new file mode 100644 index 000000000..0745a5246 --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example/default_example.go @@ -0,0 +1,77 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexample + +import ( + "context" + + "github.com/mcuadros/go-jsonschema-generator" + "github.com/uber/zanzibar/examples/selective-gateway/build/middlewares/default/default_example/module" + zanzibar "github.com/uber/zanzibar/runtime" +) + +type defaultExampleMiddleware struct { + deps *module.Dependencies + options Options +} + +// Options for middleware configuration +type Options struct{} + +// NewMiddleware creates a new middleware that executes the next middleware +// after performing it's operations. +func NewMiddleware( + deps *module.Dependencies, + options Options, +) zanzibar.MiddlewareHandle { + return &defaultExampleMiddleware{ + deps: deps, + options: options, + } +} + +// HandleRequest handles the requests before calling lower level middlewares. +func (m *defaultExampleMiddleware) HandleRequest( + ctx context.Context, + req *zanzibar.ServerHTTPRequest, + res *zanzibar.ServerHTTPResponse, + shared zanzibar.SharedState, +) bool { + return true +} + +func (m *defaultExampleMiddleware) HandleResponse( + ctx context.Context, + res *zanzibar.ServerHTTPResponse, + shared zanzibar.SharedState, +) { +} + +// JSONSchema returns a schema definition of the configuration options for a middlware +func (m *defaultExampleMiddleware) JSONSchema() *jsonschema.Document { + s := &jsonschema.Document{} + s.Read(&Options{}) + return s +} + +func (m *defaultExampleMiddleware) Name() string { + return "default_example" +} diff --git a/examples/selective-gateway/middlewares/default/default_example/default_example_schema.json b/examples/selective-gateway/middlewares/default/default_example/default_example_schema.json new file mode 100644 index 000000000..6c345916a --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example/default_example_schema.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": {} +} diff --git a/examples/selective-gateway/middlewares/default/default_example/default_example_test.go b/examples/selective-gateway/middlewares/default/default_example/default_example_test.go new file mode 100644 index 000000000..d01b31d79 --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example/default_example_test.go @@ -0,0 +1,40 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexample + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNoRequestSuccessfulRequestOKResponse(t *testing.T) { + schema := (&defaultExampleMiddleware{}).JSONSchema() + + expected := "{\n" + + " \"$schema\": \"http://json-schema.org/schema#\",\n" + + " \"type\": \"object\"\n" + + "}" + + json, err := schema.Marshal() + assert.Nil(t, err) + assert.Equal(t, expected, string(json)) +} diff --git a/examples/selective-gateway/middlewares/default/default_example/middleware-config.yaml b/examples/selective-gateway/middlewares/default/default_example/middleware-config.yaml new file mode 100644 index 000000000..3398ac5c5 --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example/middleware-config.yaml @@ -0,0 +1,8 @@ +config: + path: github.com/uber/zanzibar/examples/selective-gateway/middlewares/default/default_example + schema: ./middlewares/default/default_example/default_example_schema.json +dependencies: + client: + - echo +name: default_example +type: http diff --git a/examples/selective-gateway/middlewares/default/default_example2/default_example2.go b/examples/selective-gateway/middlewares/default/default_example2/default_example2.go new file mode 100644 index 000000000..ca03ca3d1 --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example2/default_example2.go @@ -0,0 +1,77 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexample2 + +import ( + "context" + + "github.com/mcuadros/go-jsonschema-generator" + "github.com/uber/zanzibar/examples/selective-gateway/build/middlewares/default/default_example2/module" + zanzibar "github.com/uber/zanzibar/runtime" +) + +type defaultExample2Middleware struct { + deps *module.Dependencies + options Options +} + +// Options for middleware configuration +type Options struct{} + +// NewMiddleware creates a new middleware that executes the next middleware +// after performing it's operations. +func NewMiddleware( + deps *module.Dependencies, + options Options, +) zanzibar.MiddlewareHandle { + return &defaultExample2Middleware{ + deps: deps, + options: options, + } +} + +// HandleRequest handles the requests before calling lower level middlewares. +func (m *defaultExample2Middleware) HandleRequest( + ctx context.Context, + req *zanzibar.ServerHTTPRequest, + res *zanzibar.ServerHTTPResponse, + shared zanzibar.SharedState, +) bool { + return true +} + +func (m *defaultExample2Middleware) HandleResponse( + ctx context.Context, + res *zanzibar.ServerHTTPResponse, + shared zanzibar.SharedState, +) { +} + +// JSONSchema returns a schema definition of the configuration options for a middlware +func (m *defaultExample2Middleware) JSONSchema() *jsonschema.Document { + s := &jsonschema.Document{} + s.Read(&Options{}) + return s +} + +func (m *defaultExample2Middleware) Name() string { + return "default_example2" +} diff --git a/examples/selective-gateway/middlewares/default/default_example2/default_example2_schema.json b/examples/selective-gateway/middlewares/default/default_example2/default_example2_schema.json new file mode 100644 index 000000000..6c345916a --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example2/default_example2_schema.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": {} +} diff --git a/examples/selective-gateway/middlewares/default/default_example2/default_example2_test.go b/examples/selective-gateway/middlewares/default/default_example2/default_example2_test.go new file mode 100644 index 000000000..fea42b77b --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example2/default_example2_test.go @@ -0,0 +1,40 @@ +// Copyright (c) 2018 Uber Technologies, Inc. +// +// 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. + +package defaultexample2 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestNoRequestSuccessfulRequestOKResponse(t *testing.T) { + schema := (&defaultExample2Middleware{}).JSONSchema() + + expected := "{\n" + + " \"$schema\": \"http://json-schema.org/schema#\",\n" + + " \"type\": \"object\"\n" + + "}" + + json, err := schema.Marshal() + assert.Nil(t, err) + assert.Equal(t, expected, string(json)) +} diff --git a/examples/selective-gateway/middlewares/default/default_example2/middleware-config.yaml b/examples/selective-gateway/middlewares/default/default_example2/middleware-config.yaml new file mode 100644 index 000000000..3574af3cf --- /dev/null +++ b/examples/selective-gateway/middlewares/default/default_example2/middleware-config.yaml @@ -0,0 +1,8 @@ +config: + path: github.com/uber/zanzibar/examples/selective-gateway/middlewares/default/default_example2 + schema: ./middlewares/default/default_example2/default_example2_schema.json +dependencies: + client: + - echo +name: default_example2 +type: http diff --git a/examples/selective-gateway/services/selective-gateway/service-config.yaml b/examples/selective-gateway/services/selective-gateway/service-config.yaml new file mode 100644 index 000000000..3cf7afb55 --- /dev/null +++ b/examples/selective-gateway/services/selective-gateway/service-config.yaml @@ -0,0 +1,8 @@ +name: selective-gateway +type: gateway +config: {} +dependencies: + endpoint: + - tchannel/echo + - bounce +selectiveBuilding: true diff --git a/scripts/generate.sh b/scripts/generate.sh index eb3fe656e..c250c7b52 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -14,6 +14,10 @@ else go run codegen/runner/runner.go -config="$PREFIX/build.json" fi +PREFIX=examples/selective-gateway +bash ./codegen/runner/pre-steps.sh "$PREFIX/build" "$PREFIX" "$ANNOPREFIX" +go run codegen/runner/runner.go -config="$PREFIX/build.yaml" -selective + end=`date +%s` runtime=$((end - start)) echo "Generated build : +$runtime" From 2f136d2e3cdbf4de67486f66dd16461c720285f7 Mon Sep 17 00:00:00 2001 From: Abhishek Parwal Date: Sun, 26 Apr 2020 09:48:31 -0700 Subject: [PATCH 3/5] check-generatte --- .../gen-code/clients/bar/bar/bar_easyjson.go | 456 ++++++++++++++---- 1 file changed, 356 insertions(+), 100 deletions(-) diff --git a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go index 114423bb8..516e85e25 100644 --- a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go +++ b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go @@ -12,6 +12,7 @@ import ( easyjson "github.com/mailru/easyjson" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" + base "github.com/uber/zanzibar/examples/example-gateway/build/gen-code/clients/foo/base/base" foo "github.com/uber/zanzibar/examples/example-gateway/build/gen-code/clients/foo/foo" ) @@ -3843,7 +3844,7 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if out.FooException == nil { out.FooException = new(foo.FooException) } - (*out.FooException).UnmarshalEasyJSON(in) + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(in, out.FooException) } default: in.SkipRecursive() @@ -3883,7 +3884,7 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo } else { out.RawString(prefix) } - (*in.FooException).MarshalEasyJSON(out) + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(out, *in.FooException) } out.RawByte('}') } @@ -3911,6 +3912,53 @@ func (v *Bar_TooManyArgs_Result) UnmarshalJSON(data []byte) error { func (v *Bar_TooManyArgs_Result) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs(l, v) } +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(in *jlexer.Lexer, out *foo.FooException) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var TeapotSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "teapot": + out.Teapot = string(in.String()) + TeapotSet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !TeapotSet { + in.AddError(fmt.Errorf("key 'teapot' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo(out *jwriter.Writer, in foo.FooException) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"teapot\":" + out.RawString(prefix[1:]) + out.String(string(in.Teapot)) + } + out.RawByte('}') +} func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(in *jlexer.Lexer, out *Bar_TooManyArgs_Args) { isTopLevel := in.IsStart() if in.IsNull() { @@ -3950,7 +3998,7 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if out.Foo == nil { out.Foo = new(foo.FooStruct) } - (*out.Foo).UnmarshalEasyJSON(in) + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(in, out.Foo) } default: in.SkipRecursive() @@ -3981,7 +4029,7 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo if in.Foo != nil { const prefix string = ",\"foo\":" out.RawString(prefix) - (*in.Foo).MarshalEasyJSON(out) + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(out, *in.Foo) } out.RawByte('}') } @@ -4009,6 +4057,214 @@ func (v *Bar_TooManyArgs_Args) UnmarshalJSON(data []byte) error { func (v *Bar_TooManyArgs_Args) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarTooManyArgs1(l, v) } +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(in *jlexer.Lexer, out *foo.FooStruct) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var FooStringSet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "fooString": + out.FooString = string(in.String()) + FooStringSet = true + case "fooI32": + if in.IsNull() { + in.Skip() + out.FooI32 = nil + } else { + if out.FooI32 == nil { + out.FooI32 = new(int32) + } + *out.FooI32 = int32(in.Int32()) + } + case "fooI16": + if in.IsNull() { + in.Skip() + out.FooI16 = nil + } else { + if out.FooI16 == nil { + out.FooI16 = new(int16) + } + *out.FooI16 = int16(in.Int16()) + } + case "fooDouble": + if in.IsNull() { + in.Skip() + out.FooDouble = nil + } else { + if out.FooDouble == nil { + out.FooDouble = new(float64) + } + *out.FooDouble = float64(in.Float64()) + } + case "fooBool": + if in.IsNull() { + in.Skip() + out.FooBool = nil + } else { + if out.FooBool == nil { + out.FooBool = new(bool) + } + *out.FooBool = bool(in.Bool()) + } + case "fooMap": + if in.IsNull() { + in.Skip() + } else { + in.Delim('{') + if !in.IsDelim('}') { + out.FooMap = make(map[string]string) + } else { + out.FooMap = nil + } + for !in.IsDelim('}') { + key := string(in.String()) + in.WantColon() + var v46 string + v46 = string(in.String()) + (out.FooMap)[key] = v46 + in.WantComma() + } + in.Delim('}') + } + case "message": + if in.IsNull() { + in.Skip() + out.Message = nil + } else { + if out.Message == nil { + out.Message = new(base.Message) + } + easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(in, out.Message) + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !FooStringSet { + in.AddError(fmt.Errorf("key 'fooString' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooFoo1(out *jwriter.Writer, in foo.FooStruct) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"fooString\":" + out.RawString(prefix[1:]) + out.String(string(in.FooString)) + } + if in.FooI32 != nil { + const prefix string = ",\"fooI32\":" + out.RawString(prefix) + out.Int32(int32(*in.FooI32)) + } + if in.FooI16 != nil { + const prefix string = ",\"fooI16\":" + out.RawString(prefix) + out.Int16(int16(*in.FooI16)) + } + if in.FooDouble != nil { + const prefix string = ",\"fooDouble\":" + out.RawString(prefix) + out.Float64(float64(*in.FooDouble)) + } + if in.FooBool != nil { + const prefix string = ",\"fooBool\":" + out.RawString(prefix) + out.Bool(bool(*in.FooBool)) + } + if len(in.FooMap) != 0 { + const prefix string = ",\"fooMap\":" + out.RawString(prefix) + { + out.RawByte('{') + v47First := true + for v47Name, v47Value := range in.FooMap { + if v47First { + v47First = false + } else { + out.RawByte(',') + } + out.String(string(v47Name)) + out.RawByte(':') + out.String(string(v47Value)) + } + out.RawByte('}') + } + } + if in.Message != nil { + const prefix string = ",\"message\":" + out.RawString(prefix) + easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(out, *in.Message) + } + out.RawByte('}') +} +func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(in *jlexer.Lexer, out *base.Message) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + var BodySet bool + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "body": + out.Body = string(in.String()) + BodySet = true + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } + if !BodySet { + in.AddError(fmt.Errorf("key 'body' is required")) + } +} +func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsFooBaseBase(out *jwriter.Writer, in base.Message) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"body\":" + out.RawString(prefix[1:]) + out.String(string(in.Body)) + } + out.RawByte('}') +} func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCodeClientsBarBarBarNormal(in *jlexer.Lexer, out *Bar_Normal_Result) { isTopLevel := in.IsStart() if in.IsNull() { @@ -4804,9 +5060,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.DemoIds = (out.DemoIds)[:0] } for !in.IsDelim(']') { - var v46 string - v46 = string(in.String()) - out.DemoIds = append(out.DemoIds, v46) + var v48 string + v48 = string(in.String()) + out.DemoIds = append(out.DemoIds, v48) in.WantComma() } in.Delim(']') @@ -4840,11 +5096,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Demos = (out.Demos)[:0] } for !in.IsDelim(']') { - var v47 DemoType + var v49 DemoType if data := in.Raw(); in.Ok() { - in.AddError((v47).UnmarshalJSON(data)) + in.AddError((v49).UnmarshalJSON(data)) } - out.Demos = append(out.Demos, v47) + out.Demos = append(out.Demos, v49) in.WantComma() } in.Delim(']') @@ -4873,11 +5129,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v48, v49 := range in.DemoIds { - if v48 > 0 { + for v50, v51 := range in.DemoIds { + if v50 > 0 { out.RawByte(',') } - out.String(string(v49)) + out.String(string(v51)) } out.RawByte(']') } @@ -4892,11 +5148,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v50, v51 := range in.Demos { - if v50 > 0 { + for v52, v53 := range in.Demos { + if v52 > 0 { out.RawByte(',') } - out.Raw((v51).MarshalJSON()) + out.Raw((v53).MarshalJSON()) } out.RawByte(']') } @@ -5481,9 +5737,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Foo = (out.Foo)[:0] } for !in.IsDelim(']') { - var v52 string - v52 = string(in.String()) - out.Foo = append(out.Foo, v52) + var v54 string + v54 = string(in.String()) + out.Foo = append(out.Foo, v54) in.WantComma() } in.Delim(']') @@ -5504,9 +5760,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Bar = (out.Bar)[:0] } for !in.IsDelim(']') { - var v53 int8 - v53 = int8(in.Int8()) - out.Bar = append(out.Bar, v53) + var v55 int8 + v55 = int8(in.Int8()) + out.Bar = append(out.Bar, v55) in.WantComma() } in.Delim(']') @@ -5547,11 +5803,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v54, v55 := range in.Foo { - if v54 > 0 { + for v56, v57 := range in.Foo { + if v56 > 0 { out.RawByte(',') } - out.String(string(v55)) + out.String(string(v57)) } out.RawByte(']') } @@ -5563,11 +5819,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v56, v57 := range in.Bar { - if v56 > 0 { + for v58, v59 := range in.Bar { + if v58 > 0 { out.RawByte(',') } - out.Int8(int8(v57)) + out.Int8(int8(v59)) } out.RawByte(']') } @@ -6671,9 +6927,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AListUUID = (out.AListUUID)[:0] } for !in.IsDelim(']') { - var v58 UUID - v58 = UUID(in.String()) - out.AListUUID = append(out.AListUUID, v58) + var v60 UUID + v60 = UUID(in.String()) + out.AListUUID = append(out.AListUUID, v60) in.WantComma() } in.Delim(']') @@ -6695,9 +6951,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptListUUID = (out.AnOptListUUID)[:0] } for !in.IsDelim(']') { - var v59 UUID - v59 = UUID(in.String()) - out.AnOptListUUID = append(out.AnOptListUUID, v59) + var v61 UUID + v61 = UUID(in.String()) + out.AnOptListUUID = append(out.AnOptListUUID, v61) in.WantComma() } in.Delim(']') @@ -6718,9 +6974,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AStringList = (out.AStringList)[:0] } for !in.IsDelim(']') { - var v60 string - v60 = string(in.String()) - out.AStringList = append(out.AStringList, v60) + var v62 string + v62 = string(in.String()) + out.AStringList = append(out.AStringList, v62) in.WantComma() } in.Delim(']') @@ -6742,9 +6998,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptStringList = (out.AnOptStringList)[:0] } for !in.IsDelim(']') { - var v61 string - v61 = string(in.String()) - out.AnOptStringList = append(out.AnOptStringList, v61) + var v63 string + v63 = string(in.String()) + out.AnOptStringList = append(out.AnOptStringList, v63) in.WantComma() } in.Delim(']') @@ -6765,9 +7021,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AUUIDList = (out.AUUIDList)[:0] } for !in.IsDelim(']') { - var v62 UUID - v62 = UUID(in.String()) - out.AUUIDList = append(out.AUUIDList, v62) + var v64 UUID + v64 = UUID(in.String()) + out.AUUIDList = append(out.AUUIDList, v64) in.WantComma() } in.Delim(']') @@ -6789,9 +7045,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptUUIDList = (out.AnOptUUIDList)[:0] } for !in.IsDelim(']') { - var v63 UUID - v63 = UUID(in.String()) - out.AnOptUUIDList = append(out.AnOptUUIDList, v63) + var v65 UUID + v65 = UUID(in.String()) + out.AnOptUUIDList = append(out.AnOptUUIDList, v65) in.WantComma() } in.Delim(']') @@ -6846,11 +7102,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AReqFruits = (out.AReqFruits)[:0] } for !in.IsDelim(']') { - var v64 Fruit + var v66 Fruit if data := in.Raw(); in.Ok() { - in.AddError((v64).UnmarshalJSON(data)) + in.AddError((v66).UnmarshalJSON(data)) } - out.AReqFruits = append(out.AReqFruits, v64) + out.AReqFruits = append(out.AReqFruits, v66) in.WantComma() } in.Delim(']') @@ -6872,11 +7128,11 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.AnOptDemos = (out.AnOptDemos)[:0] } for !in.IsDelim(']') { - var v65 DemoType + var v67 DemoType if data := in.Raw(); in.Ok() { - in.AddError((v65).UnmarshalJSON(data)) + in.AddError((v67).UnmarshalJSON(data)) } - out.AnOptDemos = append(out.AnOptDemos, v65) + out.AnOptDemos = append(out.AnOptDemos, v67) in.WantComma() } in.Delim(']') @@ -7024,11 +7280,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v66, v67 := range in.AListUUID { - if v66 > 0 { + for v68, v69 := range in.AListUUID { + if v68 > 0 { out.RawByte(',') } - out.String(string(v67)) + out.String(string(v69)) } out.RawByte(']') } @@ -7038,11 +7294,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v68, v69 := range in.AnOptListUUID { - if v68 > 0 { + for v70, v71 := range in.AnOptListUUID { + if v70 > 0 { out.RawByte(',') } - out.String(string(v69)) + out.String(string(v71)) } out.RawByte(']') } @@ -7054,11 +7310,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v70, v71 := range in.AStringList { - if v70 > 0 { + for v72, v73 := range in.AStringList { + if v72 > 0 { out.RawByte(',') } - out.String(string(v71)) + out.String(string(v73)) } out.RawByte(']') } @@ -7068,11 +7324,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v72, v73 := range in.AnOptStringList { - if v72 > 0 { + for v74, v75 := range in.AnOptStringList { + if v74 > 0 { out.RawByte(',') } - out.String(string(v73)) + out.String(string(v75)) } out.RawByte(']') } @@ -7084,11 +7340,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v74, v75 := range in.AUUIDList { - if v74 > 0 { + for v76, v77 := range in.AUUIDList { + if v76 > 0 { out.RawByte(',') } - out.String(string(v75)) + out.String(string(v77)) } out.RawByte(']') } @@ -7098,11 +7354,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v76, v77 := range in.AnOptUUIDList { - if v76 > 0 { + for v78, v79 := range in.AnOptUUIDList { + if v78 > 0 { out.RawByte(',') } - out.String(string(v77)) + out.String(string(v79)) } out.RawByte(']') } @@ -7134,11 +7390,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v78, v79 := range in.AReqFruits { - if v78 > 0 { + for v80, v81 := range in.AReqFruits { + if v80 > 0 { out.RawByte(',') } - out.Raw((v79).MarshalJSON()) + out.Raw((v81).MarshalJSON()) } out.RawByte(']') } @@ -7148,11 +7404,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(prefix) { out.RawByte('[') - for v80, v81 := range in.AnOptDemos { - if v80 > 0 { + for v82, v83 := range in.AnOptDemos { + if v82 > 0 { out.RawByte(',') } - out.Raw((v81).MarshalJSON()) + out.Raw((v83).MarshalJSON()) } out.RawByte(']') } @@ -7520,9 +7776,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.Nodes = (out.Nodes)[:0] } for !in.IsDelim(']') { - var v82 string - v82 = string(in.String()) - out.Nodes = append(out.Nodes, v82) + var v84 string + v84 = string(in.String()) + out.Nodes = append(out.Nodes, v84) in.WantComma() } in.Delim(']') @@ -7558,11 +7814,11 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString("null") } else { out.RawByte('[') - for v83, v84 := range in.Nodes { - if v83 > 0 { + for v85, v86 := range in.Nodes { + if v85 > 0 { out.RawByte(',') } - out.String(string(v84)) + out.String(string(v86)) } out.RawByte(']') } @@ -7641,9 +7897,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo for !in.IsDelim('}') { key := UUID(in.String()) in.WantColon() - var v85 int32 - v85 = int32(in.Int32()) - (out.MapIntWithRange)[key] = v85 + var v87 int32 + v87 = int32(in.Int32()) + (out.MapIntWithRange)[key] = v87 in.WantComma() } in.Delim('}') @@ -7658,9 +7914,9 @@ func easyjson4347b5c1DecodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v86 int32 - v86 = int32(in.Int32()) - (out.MapIntWithoutRange)[key] = v86 + var v88 int32 + v88 = int32(in.Int32()) + (out.MapIntWithoutRange)[key] = v88 in.WantComma() } in.Delim('}') @@ -7738,16 +7994,16 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(`null`) } else { out.RawByte('{') - v88First := true - for v88Name, v88Value := range in.MapIntWithRange { - if v88First { - v88First = false + v90First := true + for v90Name, v90Value := range in.MapIntWithRange { + if v90First { + v90First = false } else { out.RawByte(',') } - out.String(string(v88Name)) + out.String(string(v90Name)) out.RawByte(':') - out.Int32(int32(v88Value)) + out.Int32(int32(v90Value)) } out.RawByte('}') } @@ -7759,16 +8015,16 @@ func easyjson4347b5c1EncodeGithubComUberZanzibarExamplesExampleGatewayBuildGenCo out.RawString(`null`) } else { out.RawByte('{') - v89First := true - for v89Name, v89Value := range in.MapIntWithoutRange { - if v89First { - v89First = false + v91First := true + for v91Name, v91Value := range in.MapIntWithoutRange { + if v91First { + v91First = false } else { out.RawByte(',') } - out.String(string(v89Name)) + out.String(string(v91Name)) out.RawByte(':') - out.Int32(int32(v89Value)) + out.Int32(int32(v91Value)) } out.RawByte('}') } From 1f4e8971d2195ac671751a1bdb7758750589ad5c Mon Sep 17 00:00:00 2001 From: Abhishek Parwal Date: Mon, 27 Apr 2020 09:16:13 -0700 Subject: [PATCH 4/5] gen-code --- examples/example-gateway/build/gen-code/clients/bar/bar/bar.go | 2 ++ .../build/gen-code/clients/bar/bar/bar_easyjson.go | 2 +- .../selective-gateway/build/gen-code/clients/bar/bar/bar.go | 2 ++ .../build/gen-code/clients/bar/bar/bar_easyjson.go | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go b/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go index 1a0ecfe52..1029d2a77 100644 --- a/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go +++ b/examples/example-gateway/build/gen-code/clients/bar/bar/bar.go @@ -19178,10 +19178,12 @@ func init() { Key *BarResponse Value string }, err error) { + if result.Success != nil { success = result.Success return } + err = errors.New("expected a non-void result") return } diff --git a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go index 516e85e25..81c71c069 100644 --- a/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go +++ b/examples/example-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go @@ -1,6 +1,6 @@ // Code generated by zanzibar // @generated -// Checksum : g2CDkggDo3mVcd4T4A3CPQ== +// Checksum : 9zgP5K2Lb0boF4QiOt3OzQ== // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. package bar diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go index 268e9542c..c9b6968db 100644 --- a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar.go @@ -19178,10 +19178,12 @@ func init() { Key *BarResponse Value string }, err error) { + if result.Success != nil { success = result.Success return } + err = errors.New("expected a non-void result") return } diff --git a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go index 5991198e2..5745d127f 100644 --- a/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go +++ b/examples/selective-gateway/build/gen-code/clients/bar/bar/bar_easyjson.go @@ -1,6 +1,6 @@ // Code generated by zanzibar // @generated -// Checksum : s+6isP8Se05NiVssDsTYNQ== +// Checksum : acIKxtfaienuWBuQz9HwGA== // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. package bar From 67970dfd3d46259721958243c69b315463b66e2d Mon Sep 17 00:00:00 2001 From: Abhishek Parwal Date: Mon, 27 Apr 2020 10:48:14 -0700 Subject: [PATCH 5/5] gen-code --- examples/example-gateway/build/gen-code/clients/baz/baz/baz.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go b/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go index 4e483bbe7..5ff3db320 100644 --- a/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go +++ b/examples/example-gateway/build/gen-code/clients/baz/baz/baz.go @@ -8259,10 +8259,12 @@ func init() { Key *base.BazResponse Value string }, err error) { + if result.Success != nil { success = result.Success return } + err = errors.New("expected a non-void result") return }